diff --git a/src/test/java/ScrollPaneDemo.java b/src/test/java/ScrollPaneDemo.java deleted file mode 100644 index 86b638c1..00000000 --- a/src/test/java/ScrollPaneDemo.java +++ /dev/null @@ -1,34 +0,0 @@ -import com.github.weisj.darklaf.LafManager; -import com.github.weisj.darklaf.util.StringUtil; -import org.jdesktop.swingx.MultiSplitLayout; - -import javax.swing.*; -import java.awt.*; - -/** - * @author Jannis Weis - * @since 2019 - */ -public final class ScrollPaneDemo extends MultiSplitLayout { - - public static void main(final String[] args) { - SwingUtilities.invokeLater(() -> { - LafManager.install(); - final JFrame frame = new JFrame(); - frame.setSize(500, 500); - JTextPane overlayScroll = new JTextPane() {{ - setText(StringUtil.repeat(TestResources.LOREM_IPSUM, 10)); - setFont(Font.getFont(Font.MONOSPACED)); -// setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); -// SimpleAttributeSet attribs = new SimpleAttributeSet(); -// StyleConstants.setAlignment(attribs, StyleConstants.ALIGN_RIGHT); -// setParagraphAttributes(attribs, true); - }}; - frame.setContentPane(new JPanel(new BorderLayout()) {{ - add(overlayScroll, BorderLayout.CENTER); - }}); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.setVisible(true); - }); - } -} diff --git a/src/test/java/TabFrameDemo.java b/src/test/java/TabFrameDemo.java index 273d3104..aba15e98 100644 --- a/src/test/java/TabFrameDemo.java +++ b/src/test/java/TabFrameDemo.java @@ -9,6 +9,7 @@ import com.github.weisj.darklaf.components.text.NumberedTextComponent; import com.github.weisj.darklaf.components.text.NumberingPane; import com.github.weisj.darklaf.icons.IconLoader; import com.github.weisj.darklaf.util.StringUtil; +import demo.DemoResources; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -126,7 +127,7 @@ public class TabFrameDemo { @NotNull private static Component createTextArea() { NumberedTextComponent numberPane = new NumberedTextComponent(new NonWrappingTextPane() {{ - setText(StringUtil.repeat(TestResources.LOREM_IPSUM, 10)); + setText(StringUtil.repeat(DemoResources.LOREM_IPSUM, 10)); setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14)); }}); NumberingPane numbering = numberPane.getNumberingPane(); diff --git a/src/test/java/demo/ComponentDemo.java b/src/test/java/demo/ComponentDemo.java index be169913..600b1633 100644 --- a/src/test/java/demo/ComponentDemo.java +++ b/src/test/java/demo/ComponentDemo.java @@ -34,7 +34,9 @@ public interface ComponentDemo { static void showDemo(final ComponentDemo demo) { SwingUtilities.invokeLater(() -> { LafManager.install(); - JFrame frame = DemoPanel.createFrame(); + JFrame frame = new JFrame(); + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setTitle(demo.getTitle()); frame.setContentPane(demo.createComponent()); frame.pack(); diff --git a/src/test/java/demo/DemoPanel.java b/src/test/java/demo/DemoPanel.java index 413bebd8..35f3e86c 100644 --- a/src/test/java/demo/DemoPanel.java +++ b/src/test/java/demo/DemoPanel.java @@ -43,13 +43,6 @@ public class DemoPanel extends JPanel { add(controls, BorderLayout.SOUTH); } - public static JFrame createFrame() { - JFrame frame = new JFrame(); - frame.setLocationRelativeTo(null); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - return frame; - } - public JPanel getControls() { return controls; } diff --git a/src/test/java/TestResources.java b/src/test/java/demo/DemoResources.java similarity index 97% rename from src/test/java/TestResources.java rename to src/test/java/demo/DemoResources.java index 02a4d6f2..9927807c 100644 --- a/src/test/java/TestResources.java +++ b/src/test/java/demo/DemoResources.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2019 Jannis Weis + * Copyright (c) 2020 Jannis Weis * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -public class TestResources { +package demo; + +public class DemoResources { public static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In tempor quis nibh a semper. Nullam\n" + " auctor, erat non viverra commodo, libero orci aliquam quam, ac interdum nunc est sed\n " diff --git a/src/test/java/demo/SolidColorComponent.java b/src/test/java/demo/SolidColorComponent.java new file mode 100644 index 00000000..274af512 --- /dev/null +++ b/src/test/java/demo/SolidColorComponent.java @@ -0,0 +1,38 @@ +/* + * MIT License + * + * Copyright (c) 2020 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package demo; + +import javax.swing.*; +import java.awt.*; + +public class SolidColorComponent extends JPanel { + + public SolidColorComponent(final Color color, final int width, final int height) { + setBackground(color); + Dimension size = new Dimension(width, height); + setPreferredSize(size); + setMinimumSize(size); + setMaximumSize(size); + } +} diff --git a/src/test/java/demo/scrollPane/ScrollPaneDemo.java b/src/test/java/demo/scrollPane/ScrollPaneDemo.java new file mode 100644 index 00000000..38c91207 --- /dev/null +++ b/src/test/java/demo/scrollPane/ScrollPaneDemo.java @@ -0,0 +1,87 @@ +/* + * MIT License + * + * Copyright (c) 2020 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package demo.scrollPane; + +import demo.ComponentDemo; +import demo.DemoPanel; +import demo.DemoResources; +import demo.SolidColorComponent; + +import javax.swing.*; +import java.awt.*; + +/** + * @author Jannis Weis + * @since 2019 + */ +public final class ScrollPaneDemo implements ComponentDemo { + + public static void main(final String[] args) { + ComponentDemo.showDemo(new ScrollPaneDemo()); + } + + @Override + public JComponent createComponent() { + JScrollPane scrollPane = new JScrollPane(); + scrollPane.setViewportView(new JPanel() {{ + add(new JTextArea() {{ + setText(DemoResources.LOREM_IPSUM); + }}); + }}); + JPanel upperLeft = new SolidColorComponent(Color.RED, 20, 20); + JPanel upperRight = new SolidColorComponent(Color.RED, 20, 20); + JPanel lowerLeft = new SolidColorComponent(Color.RED, 20, 20); + JPanel lowerRight = new SolidColorComponent(Color.RED, 20, 20); + + DemoPanel panel = new DemoPanel(scrollPane); + + + JPanel controlPanel = panel.getControls(); + controlPanel.setLayout(new GridLayout(3, 2)); + controlPanel.add(new JCheckBox("LeftToRight") {{ + setSelected(scrollPane.getComponentOrientation().isLeftToRight()); + addActionListener(e -> scrollPane.setComponentOrientation(isSelected() ? ComponentOrientation.LEFT_TO_RIGHT + : ComponentOrientation.RIGHT_TO_LEFT)); + }}); + controlPanel.add(new JLabel()); + controlPanel.add(new JCheckBox("UpperLeft corner") {{ + addActionListener(e -> scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, isSelected() ? upperLeft : null)); + }}); + controlPanel.add(new JCheckBox("UpperRight corner") {{ + addActionListener(e -> scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, isSelected() ? upperRight : null)); + }}); + controlPanel.add(new JCheckBox("LowerLeft corner") {{ + addActionListener(e -> scrollPane.setCorner(JScrollPane.LOWER_LEFT_CORNER, isSelected() ? lowerLeft : null)); + }}); + controlPanel.add(new JCheckBox("LowerRight corner") {{ + addActionListener(e -> scrollPane.setCorner(JScrollPane.LOWER_RIGHT_CORNER, isSelected() ? lowerRight : null)); + }}); + return panel; + } + + @Override + public String getTitle() { + return "ScrollPane Demo"; + } +}