Debian Codegraph @

substance-swingx/src/tools/java/docrobot/StatusBarFrame.java

raw symbols SCIP
1 /*
2 * Copyright 2005-2008 Kirill Grouchnikov, based on work by
3 * Sun Microsystems, Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 package docrobot;
20
21 import java.awt.BorderLayout;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import java.net.URL;
25 import java.text.SimpleDateFormat;
26 import java.util.Date;
27
28 import javax.swing.*;
29
30 import org.jdesktop.swingx.JXStatusBar;
31 import org.pushingpixels.substance.api.SubstanceLookAndFeel;
32 import org.pushingpixels.substance.api.skin.TwilightSkin;
33
34 public class StatusBarFrame extends JFrame {
35 public StatusBarFrame() {
36 super("JXStatusBar example");
37
38 this.setLayout(new BorderLayout());
39
40 JMenuBar jmb = new JMenuBar();
41 jmb.add(new JMenu("File"));
42 jmb.add(new JMenu("Edit"));
43 jmb.add(new JMenu("Source"));
44 jmb.add(new JMenu("Refactor"));
45 jmb.add(new JMenu("Navigate"));
46 jmb.add(new JMenu("Search"));
47 jmb.add(new JMenu("Project"));
48 this.setJMenuBar(jmb);
49
50 this.add(getToolbar("", 22), BorderLayout.NORTH);
51
52 JXStatusBar statusBar = new JXStatusBar();
53 this.add(statusBar, BorderLayout.SOUTH);
54
55 JLabel statusLabel = new JLabel("Smart Insert");
56 JXStatusBar.Constraint c1 = new JXStatusBar.Constraint();
57 c1.setFixedWidth(100);
58 statusBar.add(statusLabel, c1);
59
60 JXStatusBar.Constraint c2 = new JXStatusBar.Constraint(
61 JXStatusBar.Constraint.ResizeBehavior.FILL);
62 SimpleDateFormat sdf = new SimpleDateFormat("MMMMM dd, yyyy hh:mm aaa");
63 final JLabel tabLabel = new JLabel("Created on "
64 + sdf.format(new Date()));
65 statusBar.add(tabLabel, c2);
66
67 JLabel statusLabel2 = new JLabel("5 new messages");
68 JXStatusBar.Constraint c3 = new JXStatusBar.Constraint();
69 c3.setFixedWidth(90);
70 statusBar.add(statusLabel2, c3);
71
72 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
73 this.setSize(500, 350);
74 this.setLocationRelativeTo(null);
75 }
76
77 public static JToolBar getToolbar(String label, int size) {
78 JToolBar toolBar = new JToolBar();
79 // toolBar.setLayout(new BoxLayout(toolBar,BoxLayout.LINE_AXIS));
80 // toolBar.setFloatable(false);
81
82 JButton buttonCut = new JButton(getIcon(size + "/edit-cut"));
83 toolBar.add(buttonCut);
84 JButton buttonCopy = new JButton(getIcon(size + "/edit-copy"));
85 toolBar.add(buttonCopy);
86 JButton buttonPaste = new JButton(getIcon(size + "/edit-paste"));
87 toolBar.add(buttonPaste);
88 JButton buttonSelectAll = new JButton(
89 getIcon(size + "/edit-select-all"));
90 toolBar.add(buttonSelectAll);
91 JButton buttonDelete = new JButton(getIcon(size + "/edit-delete"));
92 toolBar.add(buttonDelete);
93 toolBar.addSeparator();
94
95 JToggleButton buttonFormatCenter = new JToggleButton(getIcon(size
96 + "/format-justify-center"));
97 toolBar.add(buttonFormatCenter);
98 JToggleButton buttonFormatLeft = new JToggleButton(getIcon(size
99 + "/format-justify-left"));
100 toolBar.add(buttonFormatLeft);
101 JToggleButton buttonFormatRight = new JToggleButton(getIcon(size
102 + "/format-justify-right"));
103 toolBar.add(buttonFormatRight);
104 JToggleButton buttonFormatFill = new JToggleButton(getIcon(size
105 + "/format-justify-fill"));
106 toolBar.add(buttonFormatFill);
107 toolBar.addSeparator();
108
109 toolBar.add(Box.createGlue());
110 JButton buttonExit = new JButton(getIcon(size + "/process-stop"));
111 buttonExit.addActionListener(new ActionListener() {
112 public void actionPerformed(ActionEvent e) {
113 System.exit(0);
114 }
115 });
116 toolBar.add(buttonExit);
117
118 return toolBar;
119 }
120
121 public static Icon getIcon(String iconName) {
122 ClassLoader cl = Thread.currentThread().getContextClassLoader();
123 URL url = cl.getResource("test/check/icons/" + iconName + ".gif");
124 if (url != null)
125 return new ImageIcon(url);
126 url = cl.getResource("test/check/icons/" + iconName + ".png");
127 if (url != null)
128 return new ImageIcon(url);
129 return null;
130 }
131
132 public static void main(String[] args) throws Exception {
133 JFrame.setDefaultLookAndFeelDecorated(true);
134 SubstanceLookAndFeel.setSkin(new TwilightSkin());
135 // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
136 SwingUtilities.invokeLater(new Runnable() {
137 public void run() {
138 new StatusBarFrame().setVisible(true);
139 }
140 });
141 }
142 }