From 19dd082f7b7bc6c52f40cad30a21cbf989496ede Mon Sep 17 00:00:00 2001 From: VIVIMAN Date: Tue, 19 Apr 2022 16:18:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=20demo=20=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/insigma/demos/DemoModule.java | 28 +- .../java/com/insigma/demos/SwingSet2.java | 393 +++++++----------- .../com/insigma/demos/SwingSet2Applet.java | 47 +++ src/main/java/com/insigma/ui/SwingFrame.java | 3 + 4 files changed, 202 insertions(+), 269 deletions(-) create mode 100644 src/main/java/com/insigma/demos/SwingSet2Applet.java diff --git a/src/main/java/com/insigma/demos/DemoModule.java b/src/main/java/com/insigma/demos/DemoModule.java index 2d04762..439a573 100644 --- a/src/main/java/com/insigma/demos/DemoModule.java +++ b/src/main/java/com/insigma/demos/DemoModule.java @@ -1,26 +1,7 @@ -package com.insigma.demos;/* - * Copyright (C) 2015 Jack Jiang(cngeeker.com) The BeautyEye Project. - * All rights reserved. - * Project URL:https://github.com/JackJiang2011/beautyeye - * Version 3.6 - * - * Jack Jiang PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - * - * DemoModule.java at 2015-2-1 20:25:40, original version by Jack Jiang. - * You can contact author with jb2011@163.com. - */ - -/* - * @(#)DemoModule.java 1.23 05/11/17 - */ +package com.insigma.demos; import java.awt.BorderLayout; import java.awt.Dimension; -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -37,8 +18,6 @@ import javax.swing.border.EmptyBorder; import org.jb2011.lnf.beautyeye.widget.N9ComponentFactory; -// TODO: Auto-generated Javadoc - /** * A generic SwingSet2 demo module. * @@ -47,7 +26,6 @@ import org.jb2011.lnf.beautyeye.widget.N9ComponentFactory; */ public class DemoModule extends JApplet { - // The preferred size of the demo /** * The PREFERRE d_ width. */ @@ -61,10 +39,8 @@ public class DemoModule extends JApplet { /** * The lowered border. */ - Border loweredBorder = //new CompoundBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED), - new EmptyBorder(15, 10, 5, 10);//); + Border loweredBorder = new EmptyBorder(15, 10, 5, 10); - // Premade convenience dimensions, for use wherever you need 'em. /** * The HGA p2. */ diff --git a/src/main/java/com/insigma/demos/SwingSet2.java b/src/main/java/com/insigma/demos/SwingSet2.java index d43b016..3a765e6 100644 --- a/src/main/java/com/insigma/demos/SwingSet2.java +++ b/src/main/java/com/insigma/demos/SwingSet2.java @@ -1,7 +1,7 @@ /* * Copyright (C) 2015 Jack Jiang(cngeeker.com) The BeautyEye Project. * All rights reserved. - * Project URL:https://github.com/JackJiang2011/beautyeye + * Project URL:https: * Version 3.6 * * Jack Jiang PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. @@ -66,35 +66,26 @@ public class SwingSet2 extends JPanel { "com.insigma.demos.TextAreaDemo" }; - // Possible Look & Feels - // private static final String mac = - // "com.sun.java.swing.plaf.mac.MacLookAndFeel"; /** * The Constant metal. */ - private static final String metal = - "javax.swing.plaf.metal.MetalLookAndFeel"; - // private static final String motif = - // "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; + private static final String metal = "javax.swing.plaf.metal.MetalLookAndFeel"; + /** * The Constant windows. */ - private static final String windows = - "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; + private static final String windows = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; /** * The Constant gtk. */ - private static final String gtk = - "org.jb2011.lnf.windows2.Windows2LookAndFeel"; + private static final String gtk = "org.jb2011.lnf.windows2.Windows2LookAndFeel"; - // The current Look & Feel /** * The current look and feel. */ private static String currentLookAndFeel = metal; - // The preferred size of the demo /** * The Constant PREFERRED_WIDTH. */ @@ -105,7 +96,7 @@ public class SwingSet2 extends JPanel { */ private static final int PREFERRED_HEIGHT = 640; - // Box spacers + /** * The HGAP. */ @@ -116,7 +107,7 @@ public class SwingSet2 extends JPanel { */ private Dimension VGAP = new Dimension(5, 1); - // Resource bundle for internationalized and accessible text + /** * The bundle. */ @@ -127,19 +118,19 @@ public class SwingSet2 extends JPanel { */ private JPanel demoPanel = null; - // About Box + /** * The about box. */ private JDialog aboutBox = null; - // Status Bar + /** * The status field. */ private JLabel statusField = null; - // Tool Bar + /** * The toolbar. */ @@ -150,7 +141,6 @@ public class SwingSet2 extends JPanel { */ private ButtonGroup toolbarGroup = new ButtonGroup(); - // Menus /** * The menu bar. */ @@ -191,7 +181,7 @@ public class SwingSet2 extends JPanel { */ private ButtonGroup audioMenuGroup = new ButtonGroup(); - // Popup menu + /** * The popup menu. */ @@ -202,13 +192,11 @@ public class SwingSet2 extends JPanel { */ private ButtonGroup popupMenuGroup = new ButtonGroup(); - // Used only if swingset is an application /** * The frame. */ private JFrame frame = null; - // To debug or not to debug, that is the question /** * The DEBUG. */ @@ -218,8 +206,7 @@ public class SwingSet2 extends JPanel { * The debug counter. */ private int debugCounter = 0; - - // The tab pane that holds the demo + /** * The tabbed pane. */ @@ -230,17 +217,11 @@ public class SwingSet2 extends JPanel { */ private JEditorPane demoSrcPane = null; - - // contentPane cache, saved from the applet or application frame /** * The content pane. */ Container contentPane = null; - - // number of swingsets - for multiscreen - // keep track of the number of SwingSets created - we only want to exit - // the program when the last one has been closed. /** * The num s ss. */ @@ -256,6 +237,10 @@ public class SwingSet2 extends JPanel { */ private boolean dragEnabled = false; + /** + * The applet. + */ + private SwingSet2Applet applet = null; /** * SwingSet2 Main. Called only if we're an application, not an applet. @@ -264,9 +249,13 @@ public class SwingSet2 extends JPanel { * @throws Exception the exception */ public static void main(String[] args) { - - // Create SwingSet on the default monitor + initBeautyStyle(); + SwingSet2 swingset = new SwingSet2(null, GraphicsEnvironment. + getLocalGraphicsEnvironment(). + getDefaultScreenDevice(). + getDefaultConfiguration()); + log.info("启动成功:{}", swingset); } public static void initBeautyStyle() { @@ -280,10 +269,40 @@ public class SwingSet2 extends JPanel { } } - // ******************************************************* - // *************** Demo Loading Methods ****************** - // ******************************************************* + /** + * Instantiates a new swing set2. + * + * @param applet the applet + */ + public SwingSet2(SwingSet2Applet applet) { + this(applet, null); + } + + /** + * SwingSet2 Constructor. + * + * @param applet the applet + * @param gc the gc + */ + public SwingSet2(SwingSet2Applet applet, GraphicsConfiguration gc) { + // Note that applet may be null if this is started as an application + this.applet = applet; + + if (!isApplet()) { + frame = createFrame(gc); + } + + // set the layout + setLayout(new BorderLayout()); + // set the preferred size of the demo + setPreferredSize(new Dimension(PREFERRED_WIDTH,PREFERRED_HEIGHT)); + + initializeDemo(); + + // Show the demo. Must do this on the GUI thread using invokeLater. + SwingUtilities.invokeLater(() -> showSwingSet2()); + } /** * Initialize demo. @@ -292,8 +311,7 @@ public class SwingSet2 extends JPanel { JPanel top = new JPanel(); top.setLayout(new BorderLayout()); - //* 由jb2011修改 - this.setBorder(BorderFactory.createEmptyBorder(2, 0, 4, 0));//2,2,4,2)); + this.setBorder(BorderFactory.createEmptyBorder(2, 0, 4, 0)); add(top, BorderLayout.NORTH); @@ -328,7 +346,7 @@ public class SwingSet2 extends JPanel { demoPanel.setBorder(new DemoPanelBorder()); tabbedPane.addTab("Hi There!", demoPanel); - // Add html src code viewer + demoSrcPane = new JEditorPane("text/html", getString("SourceCode.loading")); demoSrcPane.setEditable(false); @@ -336,7 +354,6 @@ public class SwingSet2 extends JPanel { scroller.getViewport().add(demoSrcPane); tabbedPane.addTab( -// getString("TabbedPane.src_label"), "Java源代码", null, scroller, @@ -351,19 +368,13 @@ public class SwingSet2 extends JPanel { */ public JMenuBar createMenus() { JMenuItem mi; - // ***** create the menubar **** + JMenuBar menuBar = new JMenuBar(); menuBar.getAccessibleContext().setAccessibleName( getString("MenuBar.accessible_description")); - - // ***** create File menu + JMenu fileMenu = (JMenu) menuBar.add(new JMenu(getString("FileMenu.file_label"))); - //TODO 以下代码用来测试项级Menu上设置图标 -// fileMenu.setIcon( -// org.jb2011.lnf.beautyeye.ch9_menu -// .__IconFactory__.getInstance().getRadioButtonMenuItemCheckIcon()); - fileMenu.setMnemonic(getMnemonic("FileMenu.file_mnemonic")); fileMenu.getAccessibleContext().setAccessibleDescription(getString("FileMenu.accessible_description")); @@ -381,15 +392,14 @@ public class SwingSet2 extends JPanel { createMenuItem(fileMenu, "FileMenu.save_as_label", "FileMenu.save_as_mnemonic", "FileMenu.save_as_accessible_description", null); - fileMenu.addSeparator(); createMenuItem(fileMenu, "FileMenu.exit_label", "FileMenu.exit_mnemonic", "FileMenu.exit_accessible_description", new ExitAction(this) ); - // Create these menu items for the first SwingSet only. + if (numSSs == 0) { - // ***** create laf switcher menu + lafMenu = (JMenu) menuBar.add(new JMenu(getString("LafMenu.laf_label"))); lafMenu.setMnemonic(getMnemonic("LafMenu.laf_mnemonic")); lafMenu.getAccessibleContext().setAccessibleDescription( @@ -397,20 +407,20 @@ public class SwingSet2 extends JPanel { mi = createLafMenuItem(lafMenu, "LafMenu.java_label", "LafMenu.java_mnemonic", "LafMenu.java_accessible_description", metal); - mi.setSelected(true); // this is the default l&f + mi.setSelected(true); createLafMenuItem(lafMenu, "LafMenu.windows_label", "LafMenu.windows_mnemonic", "LafMenu.windows_accessible_description", windows); createLafMenuItem(lafMenu, "LafMenu.gtk_label", "LafMenu.gtk_mnemonic", "LafMenu.gtk_accessible_description", gtk); - // ***** create themes menu + themesMenu = (JMenu) menuBar.add(new JMenu(getString("ThemesMenu.themes_label"))); themesMenu.setMnemonic(getMnemonic("ThemesMenu.themes_mnemonic")); themesMenu.getAccessibleContext().setAccessibleDescription( getString("ThemesMenu.themes_accessible_description")); - // ***** create the audio submenu under the theme menu + audioMenu = (JMenu) themesMenu.add(new JMenu(getString("AudioMenu.audio_label"))); audioMenu.setMnemonic(getMnemonic("AudioMenu.audio_mnemonic")); audioMenu.getAccessibleContext().setAccessibleDescription( @@ -425,7 +435,7 @@ public class SwingSet2 extends JPanel { "AudioMenu.default_mnemonic", "AudioMenu.default_accessible_description", new DefaultAudioAction(this)); - mi.setSelected(true); // This is the default feedback setting + mi.setSelected(true); createAudioMenuItem(audioMenu, "AudioMenu.off_label", "AudioMenu.off_mnemonic", @@ -433,7 +443,7 @@ public class SwingSet2 extends JPanel { new OffAudioAction(this)); - // ***** create the font submenu under the theme menu + JMenu fontMenu = (JMenu) themesMenu.add(new JMenu(getString("FontMenu.fonts_label"))); fontMenu.setMnemonic(getMnemonic("FontMenu.fonts_mnemonic")); fontMenu.getAccessibleContext().setAccessibleDescription( @@ -450,26 +460,26 @@ public class SwingSet2 extends JPanel { new ChangeFontAction(this, false), fontButtonGroup); - // *** now back to adding color/font themes to the theme menu + mi = createThemesMenuItem(themesMenu, "ThemesMenu.ocean_label", "ThemesMenu.ocean_mnemonic", "ThemesMenu.ocean_accessible_description", new OceanTheme()); - mi.setSelected(true); // This is the default theme + mi.setSelected(true); createThemesMenuItem(themesMenu, "ThemesMenu.steel_label", "ThemesMenu.steel_mnemonic", "ThemesMenu.steel_accessible_description", new DefaultMetalTheme()); - // ***** create the options menu + optionsMenu = (JMenu) menuBar.add( new JMenu(getString("OptionsMenu.options_label"))); optionsMenu.setMnemonic(getMnemonic("OptionsMenu.options_mnemonic")); optionsMenu.getAccessibleContext().setAccessibleDescription( getString("OptionsMenu.options_accessible_description")); - // ***** create tool tip submenu item. + mi = createCheckBoxMenuItem(optionsMenu, "OptionsMenu.tooltip_label", "OptionsMenu.tooltip_mnemonic", "OptionsMenu.tooltip_accessible_description", @@ -568,7 +578,7 @@ public class SwingSet2 extends JPanel { String accessibleDescription, Action action) { JMenuItem mi = (JMenuItem) menu.add(new JMenuItem(getString(label))); -// mi.setBorder(BorderFactory.createEmptyBorder()); + mi.setMnemonic(getMnemonic(mnemonic)); mi.getAccessibleContext().setAccessibleDescription(getString(accessibleDescription)); mi.addActionListener(action); @@ -594,7 +604,7 @@ public class SwingSet2 extends JPanel { themesMenuGroup.add(mi); mi.setMnemonic(getMnemonic(mnemonic)); mi.getAccessibleContext().setAccessibleDescription(getString(accessibleDescription)); -// mi.addActionListener(new ChangeThemeAction(this, theme)); + return mi; } @@ -611,13 +621,10 @@ public class SwingSet2 extends JPanel { */ public JMenuItem createLafMenuItem(JMenu menu, String label, String mnemonic, String accessibleDescription, String laf) { - JMenuItem mi = (JRadioButtonMenuItem) menu.add(new JRadioButtonMenuItem(getString(label))); + JMenuItem mi = menu.add(new JRadioButtonMenuItem(getString(label))); lafMenuGroup.add(mi); mi.setMnemonic(getMnemonic(mnemonic)); mi.getAccessibleContext().setAccessibleDescription(getString(accessibleDescription)); -// mi.addActionListener(new ChangeLookAndFeelAction(this, laf)); - -// mi.setEnabled(isAvailableLookAndFeel(laf)); return mi; } @@ -639,7 +646,7 @@ public class SwingSet2 extends JPanel { createPopupMenuItem(popup, "LafMenu.gtk_label", "LafMenu.gtk_mnemonic", "LafMenu.gtk_accessible_description", gtk); - // register key binding to activate popup menu + InputMap map = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); map.put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, InputEvent.SHIFT_MASK), "postMenuAction"); @@ -665,8 +672,8 @@ public class SwingSet2 extends JPanel { popupMenuGroup.add(mi); mi.setMnemonic(getMnemonic(mnemonic)); mi.getAccessibleContext().setAccessibleDescription(getString(accessibleDescription)); -// mi.addActionListener(new ChangeLookAndFeelAction(this, laf)); -// mi.setEnabled(isAvailableLookAndFeel(laf)); + + return mi; } @@ -678,18 +685,18 @@ public class SwingSet2 extends JPanel { */ public void showSwingSet2() { if (getFrame() != null) { - // put swingset in a frame and show it + JFrame f = getFrame(); f.setTitle(getString("Frame.title") + " - BeautyEye L&F v3.6 "); f.getContentPane().add(this, BorderLayout.CENTER); -// f.pack(); + f.setSize(1024, 750); Rectangle screenRect = f.getGraphicsConfiguration().getBounds(); Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets( f.getGraphicsConfiguration()); - // Make sure we don't place the demo off the screen. + int centerWidth = screenRect.width < f.getSize().width ? screenRect.x : screenRect.x + screenRect.width / 2 - f.getSize().width / 2; @@ -706,33 +713,6 @@ public class SwingSet2 extends JPanel { } } - // ******************************************************* - // ****************** Utility Methods ******************** - // ******************************************************* - - /** - * A utility function that layers on top of the LookAndFeel's - * isSupportedLookAndFeel() method. Returns true if the LookAndFeel - * is supported. Returns false if the LookAndFeel is not supported - * and/or if there is any kind of error checking if the LookAndFeel - * is supported. - *

- * The L&F menu will use this method to detemine whether the various - * L&F options should be active or inactive. - * - * @param laf the laf - * @return true, if is available look and feel - */ - protected boolean isAvailableLookAndFeel(String laf) { - try { - Class lnfClass = Class.forName(laf); - LookAndFeel newLAF = (LookAndFeel) (lnfClass.newInstance()); - return newLAF.isSupportedLookAndFeel(); - } catch (Exception e) { // If ANYTHING weird happens, return false - return false; - } - } - /** * Returns the frame instance. * @@ -742,49 +722,6 @@ public class SwingSet2 extends JPanel { return frame; } - /** - * Returns the menubar. - * - * @return the menu bar - */ - public JMenuBar getMenuBar() { - return menuBar; - } - - /** - * Returns the toolbar. - * - * @return the tool bar - */ - public ToggleButtonToolBar getToolBar() { - return toolbar; - } - - /** - * Returns the toolbar button group. - * - * @return the tool bar group - */ - public ButtonGroup getToolBarGroup() { - return toolbarGroup; - } - - - /** - * Set the status. - * - * @param s the new status - */ - public void setStatus(String s) { - // do the following on the gui thread - SwingUtilities.invokeLater(new SwingSetRunnable(this, s) { - @Override - public void run() { - swingset.statusField.setText((String) obj); - } - }); - } - /** * This method returns a string from the demo's resource bundle. @@ -931,9 +868,9 @@ public class SwingSet2 extends JPanel { } } - // ******************************************************* - // ************** ToggleButtonToolbar ***************** - // ******************************************************* + + + /** * The zero insets. */ @@ -950,7 +887,7 @@ public class SwingSet2 extends JPanel { public ToggleButtonToolBar() { super(); this.setFloatable(true); -// this.putClientProperty("ToolBar.isPaintPlainBackground", Boolean.TRUE); + } /** @@ -962,10 +899,10 @@ public class SwingSet2 extends JPanel { JToggleButton addToggleButton(Action a) { JToggleButton tb = new JToggleButton( (String) a.getValue(Action.NAME), null -// (Icon)a.getValue(Action.SMALL_ICON) + ); -// tb.setMargin(zeroInsets); -// tb.setText(null); + + tb.setEnabled(a.isEnabled()); tb.setToolTipText((String) a.getValue(Action.SHORT_DESCRIPTION)); tb.setAction(a); @@ -974,9 +911,9 @@ public class SwingSet2 extends JPanel { } } - // ******************************************************* - // ********* ToolBar Panel / Docking Listener *********** - // ******************************************************* + + + /** * The Class ToolBarPanel. @@ -1022,53 +959,15 @@ public class SwingSet2 extends JPanel { } } - // ******************************************************* - // ****************** Runnables *********************** - // ******************************************************* - /** - * Generic SwingSet2 runnable. This is intended to run on the - * AWT gui event thread so as not to muck things up by doing - * gui work off the gui thread. Accepts a SwingSet2 and an Object - * as arguments, which gives subtypes of this class the two - * "must haves" needed in most runnables for this demo. + * Determines if this is an applet or application. + * + * @return true, if is applet */ - class SwingSetRunnable implements Runnable { - - /** - * The swingset. - */ - protected SwingSet2 swingset; - - /** - * The obj. - */ - protected Object obj; - - /** - * Instantiates a new swing set runnable. - * - * @param swingset the swingset - * @param obj the obj - */ - public SwingSetRunnable(SwingSet2 swingset, Object obj) { - this.swingset = swingset; - this.obj = obj; - } - - /* (non-Javadoc) - * @see java.lang.Runnable#run() - */ - @Override - public void run() { - } + public boolean isApplet() { + return (applet != null); } - - // ******************************************************* - // ******************** Actions *********************** - // ******************************************************* - /** * The Class OkAction. */ @@ -1173,7 +1072,7 @@ public class SwingSet2 extends JPanel { } } - // Turns on all possible auditory feedback + /** * The Class OnAudioAction. @@ -1200,14 +1099,14 @@ public class SwingSet2 extends JPanel { */ @Override public void actionPerformed(ActionEvent e) { - //* Jack Jiang 于2012-09-11日注释掉 -// UIManager.put("AuditoryCues.playList", -// UIManager.get("AuditoryCues.allAuditoryCues")); -// swingset.updateLookAndFeel(); + + + + } } - // Turns on the default amount of auditory feedback + /** * The Class DefaultAudioAction. @@ -1234,14 +1133,14 @@ public class SwingSet2 extends JPanel { */ @Override public void actionPerformed(ActionEvent e) { - //* Jack Jiang 于2012-09-11日注释掉 -// UIManager.put("AuditoryCues.playList", -// UIManager.get("AuditoryCues.defaultCueList")); -// swingset.updateLookAndFeel(); + + + + } } - // Turns off all possible auditory feedback + /** * The Class OffAudioAction. @@ -1268,14 +1167,35 @@ public class SwingSet2 extends JPanel { */ @Override public void actionPerformed(ActionEvent e) { - //* Jack Jiang 于2012-09-11日注释掉 -// UIManager.put("AuditoryCues.playList", -// UIManager.get("AuditoryCues.noAuditoryCues")); -// swingset.updateLookAndFeel(); + } } - // Turns on or off the tool tips for the demo. + /** + * Create a frame for SwingSet2 to reside in if brought up + * as an application. + * + * @param gc the gc + * @return the j frame + */ + public static JFrame createFrame(GraphicsConfiguration gc) { + JFrame frame = new JFrame(gc); + if (numSSs == 0) { + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } else { + WindowListener l = new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + numSSs--; + swingSets.remove(this); + } + }; + frame.addWindowListener(l); + } + + frame.setMinimumSize(new Dimension(100,100)); + return frame; + } /** * The Class ToolTipAction. @@ -1391,7 +1311,7 @@ public class SwingSet2 extends JPanel { @Override public void actionPerformed(ActionEvent e) { if (aboutBox == null) { - // JPanel panel = new JPanel(new BorderLayout()); + JPanel panel = new AboutPanel(swingset); panel.setLayout(new BorderLayout()); @@ -1399,7 +1319,7 @@ public class SwingSet2 extends JPanel { aboutBox.setResizable(false); aboutBox.getContentPane().add(panel, BorderLayout.CENTER); - // JButton button = new JButton(getString("AboutBox.ok_button_text")); + JPanel buttonpanel = new JPanel(); buttonpanel.setBorder(new javax.swing.border.EmptyBorder(0, 0, 3, 0)); buttonpanel.setOpaque(false); @@ -1416,9 +1336,9 @@ public class SwingSet2 extends JPanel { } } - // ******************************************************* - // ********************** Misc ************************* - // ******************************************************* + + + /** * The Class AboutPanel. @@ -1498,21 +1418,13 @@ public class SwingSet2 extends JPanel { */ @Override public void actionPerformed(ActionEvent e) { - //* Jack Jiang 于2012-09-11日注释掉 -// if (plain) { -// UIManager.put("swing.boldMetal", Boolean.FALSE); -// } -// else { -// UIManager.put("swing.boldMetal", Boolean.TRUE); -// } -// // Change the look and feel to force the settings to take effect. -// updateLookAndFeel(); + } } - //------------------------------------------------------------- 由jb2011于2012-06-20实现 - //用于DemoPanel的边框实现,视觉目标是:简洁。 - //原EtchedBorder边框太土,但是没边框将导致整体效果稍显单调,所以做此边框 + + + /** * The Class DemoPanelBorder. @@ -1531,28 +1443,23 @@ public class SwingSet2 extends JPanel { @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { -// g.drawLine(x,y, widthheight); // draw top -// g.drawLine(x,y, x,height-1); // draw left -// g.drawLine(width-1,y, width-1,height-1); // draw right - - //** 绘制border的底线 - //虚线样式 + Stroke oldStroke = ((Graphics2D) g).getStroke(); Stroke sroke = new BasicStroke(1, BasicStroke.CAP_BUTT, - BasicStroke.JOIN_BEVEL, 0, new float[]{1, 2}, 0);//实线,空白 + BasicStroke.JOIN_BEVEL, 0, new float[]{1, 2}, 0); ((Graphics2D) g).setStroke(sroke); - //底边上(浅灰色) + g.setColor(new Color(200, 200, 200)); - g.drawLine(x, height - 2, width - 1, height - 2); // draw bottom1 - //底边下(白色):绘制一条白色虚线的目的是与上面的灰线产生较强对比度从而形成立体效果 - //,本L&F实现中因与Panel的底色对比度不够强烈而立体感不明显(颜色越深的底色最终效果越明显) + g.drawLine(x, height - 2, width - 1, height - 2); + + g.setColor(Color.white); - g.drawLine(x, height - 1, width - 1, height - 1);//draw bottom2 + g.drawLine(x, height - 1, width - 1, height - 1); ((Graphics2D) g).setStroke(oldStroke); } - //border只有底边,且高度为2像素 + /* (non-Javadoc) * @see javax.swing.border.AbstractBorder#getBorderInsets(java.awt.Component) */ @@ -1566,8 +1473,8 @@ public class SwingSet2 extends JPanel { */ @Override public Insets getBorderInsets(Component c, Insets insets) { -// insets.top = insets.left = insets.bottom = insets.right = 1; - return getBorderInsets(c);//insets; + + return getBorderInsets(c); } } } diff --git a/src/main/java/com/insigma/demos/SwingSet2Applet.java b/src/main/java/com/insigma/demos/SwingSet2Applet.java new file mode 100644 index 0000000..fe5b285 --- /dev/null +++ b/src/main/java/com/insigma/demos/SwingSet2Applet.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2015 Jack Jiang(cngeeker.com) The BeautyEye Project. + * All rights reserved. + * Project URL:https://github.com/JackJiang2011/beautyeye + * Version 3.6 + * + * Jack Jiang PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + * + * SwingSet2Applet.java at 2015-2-1 20:25:39, original version by Jack Jiang. + * You can contact author with jb2011@163.com. + */ + +/* + * @(#)SwingSet2Applet.java 1.10 05/11/17 + */ + +package com.insigma.demos; + +import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper; + +import javax.swing.*; +import java.awt.*; +import java.net.URL; + +// TODO: Auto-generated Javadoc + +/** + * The Class SwingSet2Applet. + * + * @version 1.10 11/17/05 + * @author Jeff Dinkins + */ + +public class SwingSet2Applet extends JApplet { + + @Override + public void init() { + try { + BeautyEyeLNFHelper.launchBeautyEyeLNF(); + } catch (Exception e) { + System.err.println("BeautyEyeLNF运行失败,原因是:"+e.getMessage()); + } + + getContentPane().setLayout(new BorderLayout()); + getContentPane().add(new SwingSet2(this), BorderLayout.CENTER); + } +} diff --git a/src/main/java/com/insigma/ui/SwingFrame.java b/src/main/java/com/insigma/ui/SwingFrame.java index 5d4557b..aec94c6 100644 --- a/src/main/java/com/insigma/ui/SwingFrame.java +++ b/src/main/java/com/insigma/ui/SwingFrame.java @@ -36,6 +36,9 @@ import javax.swing.Timer; import javax.swing.JTextPane; import java.awt.Component; +/** + * @author BeiJing-GWY + */ @Slf4j public class SwingFrame extends JFrame implements ActionListener {