Browse Source

Updated demos.

pull/139/head
weisj 5 years ago
parent
commit
64d2098873
  1. 4
      core/src/test/java/UIDemo.java
  2. 5
      core/src/test/java/icon/RotatableIconDemo.java
  3. 12
      core/src/test/java/ui/ComponentDemo.java
  4. 10
      core/src/test/java/ui/DemoPanel.java
  5. 8
      core/src/test/java/ui/DemoResources.java
  6. 4
      core/src/test/java/ui/button/ButtonDemo.java
  7. 4
      core/src/test/java/ui/button/ToggleButtonDemo.java
  8. 4
      core/src/test/java/ui/label/LabelDemo.java
  9. 4
      core/src/test/java/ui/popupMenu/PopupMenuDemo.java
  10. 2
      core/src/test/java/ui/scrollPane/OverlayScrollPaneDemo.java
  11. 11
      core/src/test/java/ui/scrollPane/ScrollPaneDemo.java
  12. 2
      core/src/test/java/ui/tabFrame/TabFrameDemo.java

4
core/src/test/java/UIDemo.java

@ -2,13 +2,13 @@ import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.components.text.SearchTextField;
import com.github.weisj.darklaf.components.text.SearchTextFieldWithHistory;
import com.github.weisj.darklaf.components.tristate.TristateCheckBox;
import com.github.weisj.darklaf.icons.IconLoader;
import com.github.weisj.darklaf.theme.HighContrastDarkTheme;
import com.github.weisj.darklaf.ui.button.DarkButtonUI;
import com.github.weisj.darklaf.ui.slider.DarkSliderUI;
import org.jdesktop.swingx.JXStatusBar;
import org.jdesktop.swingx.JXTaskPane;
import org.jdesktop.swingx.JXTaskPaneContainer;
import ui.DemoResources;
import javax.swing.*;
import java.awt.*;
@ -45,7 +45,7 @@ public final class UIDemo {
UIDemo.class.getClassLoader().getResource("mima.png")
));
Icon folderIcon = IconLoader.get().getIcon("files/folder.svg", 19, 19, true);
Icon folderIcon = DemoResources.FOLDER_ICON;
JPanel panel = new JPanel(new GridLayout(3, 4));
JPanel content = new JPanel(new BorderLayout());

5
core/src/test/java/icon/RotatableIconDemo.java

@ -23,10 +23,10 @@
*/
package icon;
import com.github.weisj.darklaf.icons.IconLoader;
import com.github.weisj.darklaf.icons.RotatableIcon;
import ui.ComponentDemo;
import ui.DemoPanel;
import ui.DemoResources;
import javax.swing.*;
@ -38,8 +38,7 @@ public class RotatableIconDemo implements ComponentDemo {
@Override
public JComponent createComponent() {
RotatableIcon folderIcon = new RotatableIcon(
IconLoader.get().getIcon("files/folder.svg", 19, 19, true));
RotatableIcon folderIcon = new RotatableIcon(DemoResources.FOLDER_ICON);
JLabel label = new JLabel(folderIcon);
SwingUtilities.invokeLater(() -> {
Timer timer = new Timer(1000, e -> {

12
core/src/test/java/ui/ComponentDemo.java

@ -55,7 +55,17 @@ public interface ComponentDemo {
frame.setContentPane(demo.createComponent());
frame.setJMenuBar(demo.createMenuBar());
frame.pack();
if (dimension != null) frame.setSize(dimension);
if (dimension == null) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension dim = new Dimension(screenSize.width / 2,
screenSize.height / 2);
Dimension targetSize = frame.getSize();
targetSize.width = Math.min(targetSize.width, dim.width);
targetSize.height = Math.min(targetSize.height, dim.height);
frame.setSize(targetSize);
} else {
frame.setSize(dimension);
}
frame.setVisible(true);
frame.setLocationRelativeTo(null);
});

10
core/src/test/java/ui/DemoPanel.java

@ -44,10 +44,14 @@ public class DemoPanel extends JPanel {
public DemoPanel(final JComponent component, final LayoutManager layoutManager, final int hGap) {
super(new BorderLayout());
JPanel contentHolder = new JPanel(new BorderLayout());
contentHolder.add(Box.createVerticalStrut(hGap), BorderLayout.NORTH);
contentHolder.add(Box.createVerticalStrut(hGap), BorderLayout.SOUTH);
JPanel content = new JPanel(layoutManager);
content.add(component);
if (layoutManager instanceof BorderLayout) {
content.add(component, BorderLayout.CENTER);
} else {
contentHolder.add(Box.createVerticalStrut(hGap), BorderLayout.NORTH);
contentHolder.add(Box.createVerticalStrut(hGap), BorderLayout.SOUTH);
content.add(component);
}
contentHolder.add(content, BorderLayout.CENTER);
add(contentHolder, BorderLayout.CENTER);

8
core/src/test/java/ui/DemoResources.java

@ -23,14 +23,17 @@
*/
package ui;
import com.github.weisj.darklaf.icons.IconLoader;
import javax.swing.*;
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 "
+ "ligula. Aliquam vel velit non dolor accumsan blandit id eu metus. Aenean iaculis urna in\n "
+ "placerat aliquam. Aliquam dui quam, bibendum sed magna in, cursus ornare est. Quisque\n "
+ "tempor nunc quis nunc tempor convallis. Vestibulum tristique luctus ante, ac hendrerit dui\n"
+ ".\n\n"
+ "tempor nunc quis nunc tempor convallis. Vestibulum tristique luctus ante, ac hendrerit dui.\n\n"
+ "Donec ut maximus augue. Nam eleifend maximus scelerisque. Duis varius accumsan est, non\n "
+ "aliquam dolor. Aenean iaculis nibh in aliquam viverra. Sed laoreet, urna ut facilisis\n "
+ "convallis, arcu turpis vestibulum augue, id convallis tellus metus nec orci. Lorem ipsum\n "
@ -49,4 +52,5 @@ public class DemoResources {
+ "elementum ligula at, porta turpis. Praesent feugiat dolor diam, at facilisis metus gravida\n"
+ " non. Aliquam quis pellentesque nibh. Sed vestibulum porttitor nisi. In vitae malesuada\n "
+ "sapien.";
public static Icon FOLDER_ICON = IconLoader.get().getIcon("files/folder.svg", 19, 19, true);
}

4
core/src/test/java/ui/button/ButtonDemo.java

@ -23,11 +23,11 @@
*/
package ui.button;
import com.github.weisj.darklaf.icons.IconLoader;
import com.github.weisj.darklaf.ui.button.DarkButtonUI;
import com.github.weisj.darklaf.util.AlignmentExt;
import ui.ComponentDemo;
import ui.DemoPanel;
import ui.DemoResources;
import ui.QuickColorChooser;
import javax.swing.*;
@ -41,7 +41,7 @@ public class ButtonDemo implements ComponentDemo {
@Override
public JComponent createComponent() {
Icon icon = IconLoader.get().getIcon("files/folder.svg", 19, 19, true);
Icon icon = DemoResources.FOLDER_ICON;
JButton button = new JButton("Test Button", icon);
DemoPanel panel = new DemoPanel(button);
JPanel controlPanel = panel.addControls();

4
core/src/test/java/ui/button/ToggleButtonDemo.java

@ -23,11 +23,11 @@
*/
package ui.button;
import com.github.weisj.darklaf.icons.IconLoader;
import com.github.weisj.darklaf.ui.togglebutton.DarkToggleButtonUI;
import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants;
import ui.ComponentDemo;
import ui.DemoPanel;
import ui.DemoResources;
import javax.swing.*;
import java.awt.*;
@ -40,7 +40,7 @@ public class ToggleButtonDemo implements ComponentDemo {
@Override
public JComponent createComponent() {
Icon icon = IconLoader.get().getIcon("files/folder.svg", 19, 19, true);
Icon icon = DemoResources.FOLDER_ICON;
JToggleButton button = new JToggleButton("Test ToggleButton", icon);
DemoPanel panel = new DemoPanel(button);

4
core/src/test/java/ui/label/LabelDemo.java

@ -23,9 +23,9 @@
*/
package ui.label;
import com.github.weisj.darklaf.icons.IconLoader;
import ui.ComponentDemo;
import ui.DemoPanel;
import ui.DemoResources;
import javax.swing.*;
import java.awt.*;
@ -38,7 +38,7 @@ public class LabelDemo implements ComponentDemo {
@Override
public JComponent createComponent() {
Icon icon = IconLoader.get().getIcon("files/folder.svg", 19, 19, true);
Icon icon = DemoResources.FOLDER_ICON;
JLabel label = new JLabel("Test Label", icon, JLabel.LEFT);
DemoPanel panel = new DemoPanel(label);

4
core/src/test/java/ui/popupMenu/PopupMenuDemo.java

@ -23,8 +23,8 @@
*/
package ui.popupMenu;
import com.github.weisj.darklaf.icons.IconLoader;
import ui.ComponentDemo;
import ui.DemoResources;
import javax.swing.*;
import java.awt.*;
@ -39,7 +39,7 @@ public class PopupMenuDemo implements ComponentDemo {
public JComponent createComponent() {
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
Icon icon = IconLoader.get().getIcon("files/folder.svg", 19, 19, true);
Icon icon = DemoResources.FOLDER_ICON;
panel.add(new JLabel("Right click anywhere to open menu.") {{
setInheritsPopupMenu(true);
}});

2
core/src/test/java/ui/scrollPane/OverlayScrollPaneDemo.java

@ -35,7 +35,7 @@ import java.awt.*;
public class OverlayScrollPaneDemo implements ComponentDemo {
public static void main(final String[] args) {
ComponentDemo.showDemo(new OverlayScrollPaneDemo(), new Dimension(500, 1000));
ComponentDemo.showDemo(new OverlayScrollPaneDemo());
}
@Override

11
core/src/test/java/ui/scrollPane/ScrollPaneDemo.java

@ -23,6 +23,7 @@
*/
package ui.scrollPane;
import com.github.weisj.darklaf.util.StringUtil;
import ui.ComponentDemo;
import ui.DemoPanel;
import ui.DemoResources;
@ -43,19 +44,15 @@ public final class ScrollPaneDemo implements ComponentDemo {
@Override
public JComponent createComponent() {
JScrollPane scrollPane = new JScrollPane();
scrollPane.setViewportView(new JPanel() {{
add(new JTextArea() {{
setText(DemoResources.LOREM_IPSUM);
}});
JScrollPane scrollPane = new JScrollPane(new JTextArea() {{
setText(StringUtil.repeat(DemoResources.LOREM_IPSUM, 10));
}});
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);
DemoPanel panel = new DemoPanel(scrollPane, new BorderLayout(), 10);
JPanel controlPanel = panel.addControls();
controlPanel.add(new JCheckBox("LeftToRight") {{

2
core/src/test/java/ui/tabFrame/TabFrameDemo.java

@ -64,7 +64,7 @@ public class TabFrameDemo implements ComponentDemo {
@Override
public JComponent createComponent() {
Icon folderIcon = IconLoader.get().getIcon("files/folder.svg", 19, 19, true);
Icon folderIcon = DemoResources.FOLDER_ICON;
JTabFrame tabFrame = new JTabFrame();
for (Alignment o : Alignment.values()) {
if (o != Alignment.CENTER) {

Loading…
Cancel
Save