mirror of https://github.com/weisJ/darklaf.git
weisj
5 years ago
7 changed files with 134 additions and 45 deletions
@ -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); |
|
||||||
}); |
|
||||||
} |
|
||||||
} |
|
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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"; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue