From bccc210af52c33f41d266eed2506349597cbfa98 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Sun, 16 Mar 2014 01:33:24 +0100 Subject: [PATCH] fix SwingSet3 demo --- .idea/misc.xml | 2 +- swingset2/TabbedPaneDemo.java | 8 ++++- swingset2/TableDemo.java | 18 ++++++----- swingset2/resources/swingset.properties | 2 +- swingset3/com/sun/swingset3/DemoPanel.java | 32 ++++++------------- swingset3/com/sun/swingset3/SwingSet3.java | 9 +++--- .../com/sun/swingset3/demos/JHyperlink.java | 20 ++++-------- .../sun/swingset3/demos/frame/FrameDemo.java | 21 ++++++------ .../internalframe/InternalFrameDemo.java | 29 +++++++++-------- .../demos/tabbedpane/TabbedPaneDemo.java | 4 +++ .../sun/swingset3/utilities/ArrowIcon.java | 17 +++------- .../sun/swingset3/utilities/RoundedPanel.java | 17 ++++------ swingset3/org/jdesktop/swingx/JXPanel.java | 24 ++++---------- 13 files changed, 86 insertions(+), 117 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 5156efe..3dd2a0c 100755 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -6,7 +6,7 @@ - + diff --git a/swingset2/TabbedPaneDemo.java b/swingset2/TabbedPaneDemo.java index 722a683..9703f7b 100755 --- a/swingset2/TabbedPaneDemo.java +++ b/swingset2/TabbedPaneDemo.java @@ -38,6 +38,8 @@ */ +import com.bulenkov.iconloader.util.UIUtil; + import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; @@ -127,7 +129,11 @@ public class TabbedPaneDemo extends DemoModule implements ActionListener { tabbedpane.add(name, pix); name = getString("TabbedPaneDemo.bounce"); - spin = new HeadSpin(); + if (UIUtil.isUnderDarcula()) { + name = name.replace("color=blue", "color='#589df6'"); + } + + spin = new HeadSpin(); tabbedpane.add(name, spin); tabbedpane.getModel().addChangeListener( diff --git a/swingset2/TableDemo.java b/swingset2/TableDemo.java index a2aa27a..4ca9a31 100755 --- a/swingset2/TableDemo.java +++ b/swingset2/TableDemo.java @@ -38,6 +38,8 @@ */ +import com.bulenkov.iconloader.util.DoubleColor; + import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; @@ -401,23 +403,23 @@ public class TableDemo extends DemoModule { NamedColor beige = new NamedColor(new Color(245, 245, 220), getString("TableDemo.beige")); NamedColor black = new NamedColor(Color.black, getString("TableDemo.black")); NamedColor blue = new NamedColor(new Color(0, 0, 222), getString("TableDemo.blue")); - NamedColor eblue = new NamedColor(Color.blue, getString("TableDemo.eblue")); + NamedColor eblue = new NamedColor(DoubleColor.blue, getString("TableDemo.eblue")); NamedColor jfcblue = new NamedColor(new Color(204, 204, 255), getString("TableDemo.jfcblue")); NamedColor jfcblue2 = new NamedColor(new Color(153, 153, 204), getString("TableDemo.jfcblue2")); - NamedColor cybergreen = new NamedColor(Color.green.darker().brighter(), getString("TableDemo.cybergreen")); + NamedColor cybergreen = new NamedColor(DoubleColor.green.darker().brighter(), getString("TableDemo.cybergreen")); NamedColor darkgreen = new NamedColor(new Color(0, 100, 75), getString("TableDemo.darkgreen")); - NamedColor forestgreen = new NamedColor(Color.green.darker(), getString("TableDemo.forestgreen")); - NamedColor gray = new NamedColor(Color.gray, getString("TableDemo.gray")); - NamedColor green = new NamedColor(Color.green, getString("TableDemo.green")); + NamedColor forestgreen = new NamedColor(DoubleColor.green.darker(), getString("TableDemo.forestgreen")); + NamedColor gray = new NamedColor(DoubleColor.gray, getString("TableDemo.gray")); + NamedColor green = new NamedColor(DoubleColor.green, getString("TableDemo.green")); NamedColor orange = new NamedColor(new Color(255, 165, 0), getString("TableDemo.orange")); NamedColor purple = new NamedColor(new Color(160, 32, 240), getString("TableDemo.purple")); - NamedColor red = new NamedColor(Color.red, getString("TableDemo.red")); - NamedColor rustred = new NamedColor(Color.red.darker(), getString("TableDemo.rustred")); + NamedColor red = new NamedColor(DoubleColor.red, getString("TableDemo.red")); + NamedColor rustred = new NamedColor(DoubleColor.red.darker(), getString("TableDemo.rustred")); NamedColor sunpurple = new NamedColor(new Color(100, 100, 255), getString("TableDemo.sunpurple")); NamedColor suspectpink = new NamedColor(new Color(255, 105, 180), getString("TableDemo.suspectpink")); NamedColor turquoise = new NamedColor(new Color(0, 255, 255), getString("TableDemo.turquoise")); NamedColor violet = new NamedColor(new Color(238, 130, 238), getString("TableDemo.violet")); - NamedColor yellow = new NamedColor(Color.yellow, getString("TableDemo.yellow")); + NamedColor yellow = new NamedColor(DoubleColor.yellow, getString("TableDemo.yellow")); // Create the dummy data (a few rows of names) final Object[][] data = { diff --git a/swingset2/resources/swingset.properties b/swingset2/resources/swingset.properties index 8684bf6..151186d 100755 --- a/swingset2/resources/swingset.properties +++ b/swingset2/resources/swingset.properties @@ -499,7 +499,7 @@ TabbedPaneDemo.accessible_description=This demo shows an example of using the JT TabbedPaneDemo.tooltip=JTabbedPane demo TabbedPaneDemo.name=TabbedPane Demo -TabbedPaneDemo.bounce=
Bouncing Babies!
+TabbedPaneDemo.bounce=
Bouncing Babies!
TabbedPaneDemo.stephen=Stephen TabbedPaneDemo.david=David TabbedPaneDemo.matthew=Matthew diff --git a/swingset3/com/sun/swingset3/DemoPanel.java b/swingset3/com/sun/swingset3/DemoPanel.java index cffb1a3..357bdc5 100644 --- a/swingset3/com/sun/swingset3/DemoPanel.java +++ b/swingset3/com/sun/swingset3/DemoPanel.java @@ -31,33 +31,19 @@ package com.sun.swingset3; -import com.sun.swingset3.utilities.HTMLPanel; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Insets; -import java.awt.Rectangle; -import java.awt.geom.Rectangle2D; -import java.io.IOException; -import java.net.URL; -import javax.swing.JComponent; -import javax.swing.JEditorPane; -import javax.swing.UIManager; -import javax.swing.border.Border; - +import com.sun.swingset3.utilities.*; import org.jdesktop.animation.timing.Animator; import org.jdesktop.animation.timing.interpolation.PropertySetter; import org.jdesktop.animation.timing.triggers.TimingTrigger; import org.jdesktop.animation.timing.triggers.TimingTriggerEvent; import org.jdesktop.swingx.JXPanel; -import com.sun.swingset3.utilities.RoundedBorder; -import com.sun.swingset3.utilities.RoundedPanel; -import com.sun.swingset3.utilities.RoundedTitleBorder; -import com.sun.swingset3.utilities.Utilities; + +import javax.swing.*; +import javax.swing.border.Border; +import java.awt.*; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.net.URL; /** * @@ -123,7 +109,7 @@ public class DemoPanel extends JXPanel { } } // Fader - private static class LoadAnimationPanel extends RoundedPanel { + public static class LoadAnimationPanel extends RoundedPanel { private String message; private int triState = 0; private boolean animating = false; diff --git a/swingset3/com/sun/swingset3/SwingSet3.java b/swingset3/com/sun/swingset3/SwingSet3.java index 8339645..e2ba859 100644 --- a/swingset3/com/sun/swingset3/SwingSet3.java +++ b/swingset3/com/sun/swingset3/SwingSet3.java @@ -33,6 +33,7 @@ package com.sun.swingset3; import com.bulenkov.darcula.DarculaLaf; import com.bulenkov.darcula.DarculaLookAndFeelInfo; +import com.bulenkov.iconloader.util.DoubleColor; import com.sun.swingset3.codeview.CodeViewer; import com.sun.swingset3.utilities.AnimatingSplitPane; import com.sun.swingset3.utilities.RoundedBorder; @@ -85,7 +86,7 @@ public class SwingSet3 extends SingleFrameApplication { public static final int MAIN_FRAME_WIDTH = 880; public static final int MAIN_FRAME_HEIGHT = 640; - public static final int DEMO_SELECTOR_WIDTH = 186; + public static final int DEMO_SELECTOR_WIDTH = 230; public static final int DEMO_PANEL_HEIGHT = 400; public static final int DEMO_PANEL_WIDTH = MAIN_FRAME_WIDTH - DEMO_SELECTOR_WIDTH; @@ -309,11 +310,11 @@ public class SwingSet3 extends SingleFrameApplication { float hsb[] = Color.RGBtoHSB( titleColor.getRed(), titleColor.getGreen(), titleColor.getBlue(), null); UIManager.put(TITLE_GRADIENT_COLOR1_KEY, - Color.getHSBColor(hsb[0]-.013f, .15f, .85f)); + new DoubleColor(Color.getHSBColor(hsb[0]-.013f, .15f, .85f), new Color(0, 79, 114))); UIManager.put(TITLE_GRADIENT_COLOR2_KEY, - Color.getHSBColor(hsb[0]-.005f, .24f, .80f)); + new DoubleColor(Color.getHSBColor(hsb[0]-.005f, .24f, .80f), new Color(49, 113, 164))); UIManager.put(TITLE_FOREGROUND_KEY, - Color.getHSBColor(hsb[0], .54f, .40f)); + new DoubleColor(Color.getHSBColor(hsb[0], .54f, .40f), new Color(0xbbbbbb))); // Calculate highlight color for code pane UIManager.put(CODE_HIGHLIGHT_KEY, diff --git a/swingset3/com/sun/swingset3/demos/JHyperlink.java b/swingset3/com/sun/swingset3/demos/JHyperlink.java index 418f7a2..2e245b8 100644 --- a/swingset3/com/sun/swingset3/demos/JHyperlink.java +++ b/swingset3/com/sun/swingset3/demos/JHyperlink.java @@ -31,21 +31,13 @@ package com.sun.swingset3.demos; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Graphics; -import java.awt.Insets; -import java.awt.Rectangle; +import com.bulenkov.iconloader.util.DoubleColor; + +import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.net.URI; import java.net.URISyntaxException; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.ButtonModel; -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; /** @@ -71,8 +63,8 @@ public class JHyperlink extends JButton { private boolean drawUnderline = true; static { - UIManager.put("Hyperlink.foreground", Color.blue); - UIManager.put("Hyperlink.activeForeground", Color.red); + UIManager.put("Hyperlink.foreground", DoubleColor.blue); + UIManager.put("Hyperlink.activeForeground", DoubleColor.red); UIManager.put("Hyperlink.visitedForeground", new Color(85, 145, 90)); } diff --git a/swingset3/com/sun/swingset3/demos/frame/FrameDemo.java b/swingset3/com/sun/swingset3/demos/frame/FrameDemo.java index fe9d369..b36f297 100644 --- a/swingset3/com/sun/swingset3/demos/frame/FrameDemo.java +++ b/swingset3/com/sun/swingset3/demos/frame/FrameDemo.java @@ -31,22 +31,19 @@ package com.sun.swingset3.demos.frame; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.EventQueue; -import java.awt.Image; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.net.URL; +import com.bulenkov.iconloader.util.DoubleColor; +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.DemoUtilities; + import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; - -import com.sun.swingset3.DemoProperties; -import com.sun.swingset3.demos.DemoUtilities; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.URL; /** * Demo for Swing's JFrame toplevel component. @@ -166,7 +163,7 @@ public class FrameDemo extends JPanel { JLabel label = new JLabel("I'm content but a little blue."); label.setHorizontalAlignment(JLabel.CENTER); label.setPreferredSize(new Dimension(300, 160)); - label.setBackground(new Color(197, 216, 236)); + label.setBackground(new DoubleColor(new Color(197, 216, 236), new Color(102, 117, 136))); label.setOpaque(true); // labels non-opaque by default frame.add(label); //snip diff --git a/swingset3/com/sun/swingset3/demos/internalframe/InternalFrameDemo.java b/swingset3/com/sun/swingset3/demos/internalframe/InternalFrameDemo.java index e2194cf..8afc313 100644 --- a/swingset3/com/sun/swingset3/demos/internalframe/InternalFrameDemo.java +++ b/swingset3/com/sun/swingset3/demos/internalframe/InternalFrameDemo.java @@ -31,18 +31,18 @@ package com.sun.swingset3.demos.internalframe; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import javax.swing.*; - -import javax.swing.border.EmptyBorder; - +import com.bulenkov.iconloader.util.DoubleColor; +import com.bulenkov.iconloader.util.Gray; +import com.bulenkov.iconloader.util.UIUtil; import com.sun.swingset3.DemoProperties; import com.sun.swingset3.demos.ResourceManager; +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import javax.swing.border.LineBorder; +import java.awt.*; +import java.awt.event.ActionEvent; + /** * Internal Frames Demo @@ -297,7 +297,7 @@ public class InternalFrameDemo extends JPanel { palette.getContentPane().add(p, BorderLayout.CENTER); - // ************************************ + // ************************************ // * Create Frame title textfield * // ************************************ p = new JPanel(); @@ -314,8 +314,11 @@ public class InternalFrameDemo extends JPanel { p.add(Box.createRigidArea(HGAP5)); palette.getContentPane().add(p, BorderLayout.SOUTH); - - palette.show(); + final JComponent panel = (JComponent) palette.getContentPane(); + if (UIUtil.isUnderDarcula()) { + panel.setBorder(new LineBorder(Gray._80)); + } + palette.show(); } @@ -342,7 +345,7 @@ public class InternalFrameDemo extends JPanel { public ImageScroller(Icon icon) { super(); JPanel p = new JPanel(); - p.setBackground(Color.white); + p.setBackground(new DoubleColor(Color.white, Gray._80)); p.setLayout(new BorderLayout()); p.add(new JLabel(icon), BorderLayout.CENTER); diff --git a/swingset3/com/sun/swingset3/demos/tabbedpane/TabbedPaneDemo.java b/swingset3/com/sun/swingset3/demos/tabbedpane/TabbedPaneDemo.java index 88f84ba..57c996a 100644 --- a/swingset3/com/sun/swingset3/demos/tabbedpane/TabbedPaneDemo.java +++ b/swingset3/com/sun/swingset3/demos/tabbedpane/TabbedPaneDemo.java @@ -39,6 +39,7 @@ import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import com.bulenkov.iconloader.util.UIUtil; import com.sun.swingset3.DemoProperties; import com.sun.swingset3.demos.ResourceManager; @@ -142,6 +143,9 @@ public class TabbedPaneDemo extends JPanel implements ActionListener { tabbedpane.add(name, pix); name = resourceManager.getString("TabbedPaneDemo.bounce"); + if (UIUtil.isUnderDarcula()) { + name = name.replace("color=blue", "color='#589df6'"); + } spin = new HeadSpin(); tabbedpane.add(name, spin); diff --git a/swingset3/com/sun/swingset3/utilities/ArrowIcon.java b/swingset3/com/sun/swingset3/utilities/ArrowIcon.java index e5ac088..62e8c9c 100644 --- a/swingset3/com/sun/swingset3/utilities/ArrowIcon.java +++ b/swingset3/com/sun/swingset3/utilities/ArrowIcon.java @@ -31,19 +31,12 @@ package com.sun.swingset3.utilities; -import java.awt.Color; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; +import com.bulenkov.iconloader.util.DoubleColor; + +import javax.swing.*; +import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; -import javax.swing.Icon; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.SwingConstants; -import javax.swing.UIManager; /** * @@ -168,7 +161,7 @@ public class ArrowIcon implements Icon, SwingConstants { panel.add(new JLabel("west", new ArrowIcon(ArrowIcon.WEST), JLabel.CENTER)); panel.add(new JLabel("south", new ArrowIcon(ArrowIcon.SOUTH), JLabel.CENTER)); panel.add(new JLabel("east", new ArrowIcon(ArrowIcon.EAST), JLabel.CENTER)); - panel.add(new JLabel("east-20", new ArrowIcon(ArrowIcon.EAST, 20, Color.blue), JLabel.CENTER)); + panel.add(new JLabel("east-20", new ArrowIcon(ArrowIcon.EAST, 20, DoubleColor.blue), JLabel.CENTER)); frame.pack(); frame.setVisible(true); diff --git a/swingset3/com/sun/swingset3/utilities/RoundedPanel.java b/swingset3/com/sun/swingset3/utilities/RoundedPanel.java index 9b1276b..10f37fc 100644 --- a/swingset3/com/sun/swingset3/utilities/RoundedPanel.java +++ b/swingset3/com/sun/swingset3/utilities/RoundedPanel.java @@ -31,18 +31,13 @@ package com.sun.swingset3.utilities; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.LayoutManager; -import java.awt.geom.RoundRectangle2D; -import javax.swing.JFrame; -import javax.swing.JPanel; +import com.bulenkov.iconloader.util.DoubleColor; import org.jdesktop.swingx.JXPanel; +import javax.swing.*; +import java.awt.*; +import java.awt.geom.RoundRectangle2D; + /** * * @author Administrator @@ -99,7 +94,7 @@ public class RoundedPanel extends JXPanel { JFrame frame = new JFrame(); RoundedPanel p = new RoundedPanel(new BorderLayout(), 16); JPanel p2 = new JPanel(); - p2.setBackground(Color.blue); + p2.setBackground(DoubleColor.blue); p.add(p2); frame.add(p); frame.setSize(200, 200); diff --git a/swingset3/org/jdesktop/swingx/JXPanel.java b/swingset3/org/jdesktop/swingx/JXPanel.java index 19cd51a..1eba666 100644 --- a/swingset3/org/jdesktop/swingx/JXPanel.java +++ b/swingset3/org/jdesktop/swingx/JXPanel.java @@ -21,21 +21,11 @@ package org.jdesktop.swingx; -import java.awt.AlphaComposite; -import java.awt.Composite; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.LayoutManager; -import java.awt.Rectangle; +import org.jdesktop.swingx.graphics.GraphicsUtilities; +import javax.swing.*; +import java.awt.*; import java.awt.image.BufferedImage; -import javax.swing.JPanel; -import javax.swing.RepaintManager; -import javax.swing.Scrollable; -import org.jdesktop.swingx.RepaintManagerX; -import org.jdesktop.swingx.TranslucentRepaintManager; -import org.jdesktop.swingx.graphics.GraphicsUtilities; /** * A simple JPanel extension that adds translucency support. @@ -122,10 +112,10 @@ public class JXPanel extends JPanel implements Scrollable { //replacing the repaint manager. In retrospect, I'd probably //opt for making this a manual choice. There really isn't a clear //win, no matter the approach. - RepaintManager manager = RepaintManager.currentManager(this); - if (!manager.getClass().isAnnotationPresent(TranslucentRepaintManager.class)) { - RepaintManager.setCurrentManager(new RepaintManagerX()); - } +// RepaintManager manager = RepaintManager.currentManager(this); +// if (!manager.getClass().isAnnotationPresent(TranslucentRepaintManager.class)) { +// RepaintManager.setCurrentManager(new RepaintManagerX()); +// } } else if (alpha == 1) { //restore the oldOpaque if it was true (since opaque is false now) if (oldOpaque) {