24 |
|
|
25 |
import java.awt.*; |
import java.awt.*; |
26 |
import java.awt.event.*; |
import java.awt.event.*; |
|
import java.awt.font.*; |
|
|
import java.awt.geom.*; |
|
|
import java.awt.image.*; |
|
27 |
|
|
28 |
import javax.swing.*; |
import javax.swing.*; |
|
import javax.swing.event.*; |
|
|
import javax.swing.plaf.*; |
|
|
import javax.swing.plaf.basic.*; |
|
|
import javax.swing.plaf.metal.MetalLookAndFeel; |
|
29 |
import javax.swing.tree.*; |
import javax.swing.tree.*; |
30 |
import javax.swing.border.*; |
import javax.swing.border.*; |
31 |
|
|
32 |
import java.net.URL; |
import java.net.URL; |
|
import java.util.*; |
|
33 |
|
|
34 |
public class Demo |
public class Demo |
35 |
{ |
{ |
42 |
{ |
{ |
43 |
if (System.getProperty("swing.defaultlaf") == null) |
if (System.getProperty("swing.defaultlaf") == null) |
44 |
{ |
{ |
45 |
|
UIManager.setLookAndFeel(new GNULookAndFeel()); |
46 |
|
|
47 |
StringBuffer text = new StringBuffer(); |
StringBuffer text = new StringBuffer(); |
48 |
text.append("\tYou may change the Look and Feel of this\n"); |
text.append("You may change the Look and Feel of this\n"); |
49 |
text.append("\tDemo by setting the system property\n"); |
text.append("Demo by setting the system property\n"); |
50 |
text.append("\t-Dswing.defaultlaf=<LAFClassName>\n\n"); |
text.append("-Dswing.defaultlaf=<LAFClassName>\n"); |
51 |
text.append("\tPossible values for <LAFClassName> are:\n"); |
text.append("\n"); |
52 |
text.append("\t * javax.swing.plaf.metal.MetalLookAndFeel\n"); |
text.append("Possible values for <LAFClassName> are:\n"); |
53 |
text.append("\t\tthe default Java L&F\n"); |
text.append("\n"); |
54 |
text.append("\t * gnu.classpath.examples.swing.GNULookAndFeel\n"); |
text.append("* javax.swing.plaf.metal.MetalLookAndFeel\n"); |
55 |
text.append("\tthe GNU Look and Feel\n"); |
text.append(" the default GNU Classpath L&F\n"); |
56 |
text.append("\t(derived from javax.swing.plaf.basic.BasicLookAndFeel\n\n"); |
text.append("\n"); |
57 |
text.append("\tthe default is gnu.classpath.examples.swing.GNULookAndFeel\n"); |
text.append("* gnu.classpath.examples.swing.GNULookAndFeel\n"); |
58 |
|
text.append(" the GNU Look and Feel\n"); |
59 |
|
text.append(" (derived from javax.swing.plaf.basic.BasicLookAndFeel)\n"); |
60 |
|
text.append("\n"); |
61 |
|
text.append("the default is gnu.classpath.examples.swing.GNULookAndFeel\n"); |
62 |
JEditorPane textPane = new JEditorPane(); |
JEditorPane textPane = new JEditorPane(); |
63 |
// temporary hack, preferred size should be computed by the |
// temporary hack, preferred size should be computed by the |
64 |
// component |
// component |
67 |
JOptionPane.showMessageDialog(null, textPane, |
JOptionPane.showMessageDialog(null, textPane, |
68 |
"Look and Feel notice", |
"Look and Feel notice", |
69 |
JOptionPane.INFORMATION_MESSAGE); |
JOptionPane.INFORMATION_MESSAGE); |
|
|
|
|
UIManager.setLookAndFeel(new GNULookAndFeel()); |
|
70 |
} |
} |
71 |
} |
} |
72 |
catch (UnsupportedLookAndFeelException e) |
catch (UnsupportedLookAndFeelException e) |
143 |
|
|
144 |
JMenu examples = new JMenu("Examples"); |
JMenu examples = new JMenu("Examples"); |
145 |
new PopUpAction("Buttons", |
new PopUpAction("Buttons", |
146 |
mkPanel(new JComponent[] |
(new ButtonDemo("Button Demo")).createContent(), |
|
{mkBigButton("mango"), |
|
|
mkBigButton("guava"), |
|
|
mkBigButton("lemon")}), |
|
147 |
examples); |
examples); |
148 |
|
|
149 |
new PopUpAction("Toggles", |
new PopUpAction("Toggles", |
174 |
examples); |
examples); |
175 |
|
|
176 |
new PopUpAction("Scrollbar", |
new PopUpAction("Scrollbar", |
177 |
mkScrollBar(), |
(new ScrollBarDemo("ScrollBarDemo")).createContent(), |
178 |
examples); |
examples); |
179 |
|
|
180 |
new PopUpAction("Viewport", |
new PopUpAction("Viewport", |
182 |
examples); |
examples); |
183 |
|
|
184 |
new PopUpAction("ScrollPane", |
new PopUpAction("ScrollPane", |
185 |
mkScrollPane(mkBigButton("Scroll Me!")), |
mkScrollPane(mkBigButton("Scroll Me!")), |
186 |
examples); |
examples); |
187 |
|
|
188 |
new PopUpAction("TabPane", |
new PopUpAction("TabPane", |
189 |
mkTabs(new String[] {"happy", |
mkTabs(new String[] {"happy", |
204 |
examples); |
examples); |
205 |
|
|
206 |
new PopUpAction("ComboBox", |
new PopUpAction("ComboBox", |
207 |
mkComboBox(new String[] {"Stop", |
(new ComboBoxDemo("ComboBox Demo")).createContent(), |
|
"Software", |
|
|
"Hoarders", |
|
|
"Support", |
|
|
"GNU!"}), |
|
208 |
examples); |
examples); |
209 |
|
|
210 |
new PopUpAction("Editor", |
new PopUpAction("Editor", |
306 |
else |
else |
307 |
b = new JButton(title, icon); |
b = new JButton(title, icon); |
308 |
|
|
309 |
|
b.setToolTipText(title); |
310 |
if (hAlign != -1) b.setHorizontalAlignment(hAlign); |
if (hAlign != -1) b.setHorizontalAlignment(hAlign); |
311 |
if (vAlign != -1) b.setVerticalAlignment(vAlign); |
if (vAlign != -1) b.setVerticalAlignment(vAlign); |
312 |
if (hPos != -1) b.setHorizontalTextPosition(hPos); |
if (hPos != -1) b.setHorizontalTextPosition(hPos); |
733 |
return c; |
return c; |
734 |
} |
} |
735 |
|
|
736 |
public static JRadioButton mkRadio(String label) |
public static JPanel mkRadio(String label) |
737 |
{ |
{ |
738 |
|
JPanel p = new JPanel(); |
739 |
JRadioButton c = new JRadioButton(label); |
JRadioButton c = new JRadioButton(label); |
740 |
c.setFont(new Font("Luxi", Font.PLAIN, 14)); |
JRadioButton d = new JRadioButton("not " + label); |
741 |
return c; |
ButtonGroup bg = new ButtonGroup(); |
742 |
|
bg.add(c); |
743 |
|
bg.add(d); |
744 |
|
p.add(c); |
745 |
|
p.add(d); |
746 |
|
return p; |
747 |
} |
} |
748 |
|
|
749 |
public static JList mkList(Object[] elts) |
public static JList mkList(Object[] elts) |
1010 |
panel.setLayout(new FlowLayout()); |
panel.setLayout(new FlowLayout()); |
1011 |
|
|
1012 |
new PopUpAction("Buttons", |
new PopUpAction("Buttons", |
1013 |
mkPanel(new JComponent[] |
(new ButtonDemo("Button Demo")).createContent(), |
|
{mkBigButton("mango"), |
|
|
mkBigButton("guava"), |
|
|
mkBigButton("lemon")}), |
|
1014 |
panel); |
panel); |
1015 |
|
|
1016 |
new PopUpAction("Toggles", |
new PopUpAction("Toggles", |
1026 |
panel); |
panel); |
1027 |
|
|
1028 |
new PopUpAction("Slider", |
new PopUpAction("Slider", |
1029 |
mkSliders(), |
(new SliderDemo("Slider Demo")).createContent(), |
1030 |
panel); |
panel); |
1031 |
|
|
1032 |
new PopUpAction("List", |
new PopUpAction("List", |
1041 |
panel); |
panel); |
1042 |
|
|
1043 |
new PopUpAction("Scrollbar", |
new PopUpAction("Scrollbar", |
1044 |
mkScrollBar(), |
(new ScrollBarDemo("ScrollBar Demo")).createContent(), |
1045 |
panel); |
panel); |
1046 |
|
|
1047 |
new PopUpAction("Viewport", |
new PopUpAction("Viewport", |
1071 |
panel); |
panel); |
1072 |
|
|
1073 |
new PopUpAction("ComboBox", |
new PopUpAction("ComboBox", |
1074 |
mkComboBox(new String[] {"Stop", |
(new ComboBoxDemo("ComboBox Demo")).createContent(), |
|
"Software", |
|
|
"Hoarders", |
|
|
"Support", |
|
|
"GNU!"}), |
|
1075 |
panel); |
panel); |
1076 |
|
|
1077 |
new PopUpAction("Editor", |
new PopUpAction("Editor", |