Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrolling panel with toolbar at top example. #159

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}