Skip to content

Commit

Permalink
Scrolling panel with toolbar at top example. (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewauclair committed Jan 1, 2024
1 parent 9b0a0d3 commit 881467b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions demo-single-app/src/basic/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public void setVisible(boolean visible) {
ToolPanel explorer = new ToolPanel("Explorer", "explorer", DockableStyle.VERTICAL, new ImageIcon(Objects.requireNonNull(getClass().getResource("/icons/light/icons8-vga-16.png"))));
ToolPanel output = new OutputPanel("Output", "output", DockableStyle.HORIZONTAL, new ImageIcon(Objects.requireNonNull(getClass().getResource("/icons/light/icons8-vga-16.png"))));
AlwaysDisplayedPanel alwaysDisplayed = new AlwaysDisplayedPanel("always displayed", "always-displayed");
ScrollingWithToolbarPanel scrolling = new ScrollingWithToolbarPanel();

PropertiesDemoPanel propertiesDemoPanel = new PropertiesDemoPanel();

Expand Down Expand Up @@ -224,6 +225,7 @@ public void setVisible(boolean visible) {
view.add(new DockableMenuItem(() -> ((Dockable) alwaysDisplayed).getPersistentID(), ((Dockable) alwaysDisplayed).getTabText()));
view.add(changeText);
view.add(actionListenDock(themes));
view.add(actionListenDock(scrolling));

JMenuItem storeCurrentLayout = new JMenuItem("Store Current Layout...");
storeCurrentLayout.addActionListener(e -> {
Expand Down
46 changes: 46 additions & 0 deletions demo-single-app/src/basic/ScrollingWithToolbarPanel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package basic;

import javax.swing.*;
import java.awt.*;

public class ScrollingWithToolbarPanel extends BasePanel {
public ScrollingWithToolbarPanel() {
super("Scrolling With Toolbar", "scroll-with-toolbar");

setLayout(new GridBagLayout());

JToolBar toolBar = new JToolBar();
toolBar.add(new JButton("Add"));
toolBar.add(new JButton("Remove"));

JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());

GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;

for (int i = 0; i < 30; i++) {
panel.add(new JLabel("label " + i), gbc);
gbc.gridy++;
}

gbc.gridy = 0;
add(toolBar, gbc);

gbc.gridy++;
gbc.weightx = 1;
gbc.weighty = 1;
gbc.fill = GridBagConstraints.BOTH;

add(new JScrollPane(panel), gbc);
}

@Override
public boolean isWrappableInScrollpane() {
return false;
}
}

0 comments on commit 881467b

Please sign in to comment.