Skip to content

Commit eadff70

Browse files
added new developer into ComboBox demo
1 parent 4b39617 commit eadff70

File tree

11 files changed

+145
-130
lines changed

11 files changed

+145
-130
lines changed

set_swing/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dependencies {
2929

3030
compile(name: 'iconloader', ext: 'jar')
3131
compile(name: 'material-ui-swing-0.9.9', ext: 'jar')
32+
//compile(name: 'material-ui-swing-0.9.3.3', ext: 'jar')
3233
compile(name: 'darcula', ext: 'jar')
3334
compile(name: 'AnimatedTransitions', ext: 'jar')
3435
compile(name: 'AppFramework', ext: 'jar')
4.19 MB
Binary file not shown.
-21.5 MB
Binary file not shown.

set_swing/src/main/java/ComboBoxDemo.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public Dimension getMaximumSize() {
189189
addFace("michael", getString("ComboBoxDemo.michael"));
190190
addFace("philip", getString("ComboBoxDemo.philip"));
191191
addFace("scott", getString("ComboBoxDemo.scott"));
192+
addFace("vincent", getString("ComboBoxDemo.vincent"));
192193

193194
// set the default face
194195
presetCB.setSelectedIndex(0);
@@ -275,6 +276,7 @@ void fillComboBox(JComboBox cb) {
275276
cb.addItem(getString("ComboBoxDemo.michael"));
276277
cb.addItem(getString("ComboBoxDemo.philip"));
277278
cb.addItem(getString("ComboBoxDemo.scott"));
279+
cb.addItem(getString("ComboBoxDemo.vincent"));
278280
}
279281

280282
public void actionPerformed(ActionEvent e) {
Lines changed: 137 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/*
22
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
3-
*
3+
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
66
* are met:
7-
*
7+
*
88
* -Redistributions of source code must retain the above copyright
99
* notice, this list of conditions and the following disclaimer.
10-
*
10+
*
1111
* -Redistribution in binary form must reproduct the above copyright
1212
* notice, this list of conditions and the following disclaimer in
1313
* the documentation and/or other materials provided with the distribution.
14-
*
14+
*
1515
* Neither the name of Sun Microsystems, Inc. or the names of contributors
1616
* may be used to endorse or promote products derived from this software
1717
* without specific prior written permission.
18-
*
18+
*
1919
* This software is provided "AS IS," without a warranty of any kind. ALL
2020
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
2121
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
@@ -27,7 +27,7 @@
2727
* INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
2828
* OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN
2929
* IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
30-
*
30+
*
3131
* You acknowledge that Software is not designed, licensed or intended for
3232
* use in the design, construction, operation or maintenance of any nuclear
3333
* facility.
@@ -46,113 +46,120 @@
4646
/**
4747
* JOptionPaneDemo
4848
*
49-
* @version 1.7 01/23/03
5049
* @author Jeff Dinkins
50+
* @version 1.7 01/23/03
5151
*/
5252
public class OptionPaneDemo extends DemoModule {
5353

5454
/**
5555
* main method allows us to run as a standalone demo.
5656
*/
5757
public static void main(String[] args) {
58-
OptionPaneDemo demo = new OptionPaneDemo(null);
59-
demo.mainImpl();
58+
OptionPaneDemo demo = new OptionPaneDemo(null);
59+
demo.mainImpl();
6060
}
6161

6262
/**
6363
* OptionPaneDemo Constructor
6464
*/
6565
public OptionPaneDemo(SwingSet2 swingset) {
66-
// Set the title for this demo, and an icon used to represent this
67-
// demo inside the SwingSet2 app.
68-
super(swingset, "OptionPaneDemo", "toolbar/JOptionPane.gif");
69-
70-
JPanel demo = getDemoPanel();
71-
72-
demo.setLayout(new BoxLayout(demo, BoxLayout.X_AXIS));
73-
74-
JPanel bp = new JPanel() {
75-
public Dimension getMaximumSize() {
76-
return new Dimension(getPreferredSize().width, super.getMaximumSize().height);
77-
}
78-
};
79-
bp.setLayout(new BoxLayout(bp, BoxLayout.Y_AXIS));
8066

81-
bp.add(Box.createRigidArea(VGAP30));
82-
bp.add(Box.createRigidArea(VGAP30));
83-
84-
bp.add(createInputDialogButton()); bp.add(Box.createRigidArea(VGAP15));
85-
bp.add(createWarningDialogButton()); bp.add(Box.createRigidArea(VGAP15));
86-
bp.add(createMessageDialogButton()); bp.add(Box.createRigidArea(VGAP15));
87-
bp.add(createComponentDialogButton()); bp.add(Box.createRigidArea(VGAP15));
88-
bp.add(createConfirmDialogButton()); bp.add(Box.createVerticalGlue());
89-
90-
demo.add(Box.createHorizontalGlue());
91-
demo.add(bp);
92-
demo.add(Box.createHorizontalGlue());
67+
// Set the title for this demo, and an icon used to represent this
68+
// demo inside the SwingSet2 app.
69+
super(swingset, "OptionPaneDemo", "toolbar/JOptionPane.gif");
70+
71+
JPanel demo = getDemoPanel();
72+
73+
demo.setLayout(new BoxLayout(demo, BoxLayout.X_AXIS));
74+
75+
JPanel bp = new JPanel() {
76+
public Dimension getMaximumSize() {
77+
return new Dimension(getPreferredSize().width, super.getMaximumSize().height);
78+
}
79+
};
80+
bp.setLayout(new BoxLayout(bp, BoxLayout.Y_AXIS));
81+
82+
bp.add(Box.createRigidArea(VGAP30));
83+
bp.add(Box.createRigidArea(VGAP30));
84+
85+
bp.add(createInputDialogButton());
86+
bp.add(Box.createRigidArea(VGAP15));
87+
bp.add(createWarningDialogButton());
88+
bp.add(Box.createRigidArea(VGAP15));
89+
bp.add(createMessageDialogButton());
90+
bp.add(Box.createRigidArea(VGAP15));
91+
bp.add(createComponentDialogButton());
92+
bp.add(Box.createRigidArea(VGAP15));
93+
bp.add(createConfirmDialogButton());
94+
bp.add(Box.createVerticalGlue());
95+
96+
demo.add(Box.createHorizontalGlue());
97+
demo.add(bp);
98+
demo.add(Box.createHorizontalGlue());
9399
}
94100

95101
public JButton createWarningDialogButton() {
96-
Action a = new AbstractAction(getString("OptionPaneDemo.warningbutton")) {
97-
public void actionPerformed(ActionEvent e) {
98-
JOptionPane.showMessageDialog(
99-
getDemoPanel(),
100-
getString("OptionPaneDemo.warningtext"),
101-
getString("OptionPaneDemo.warningtitle"),
102-
JOptionPane.WARNING_MESSAGE
103-
);
104-
}
105-
};
106-
return createButton(a);
102+
Action a = new AbstractAction(getString("OptionPaneDemo.warningbutton")) {
103+
public void actionPerformed(ActionEvent e) {
104+
JOptionPane.showMessageDialog(
105+
getDemoPanel(),
106+
getString("OptionPaneDemo.warningtext"),
107+
getString("OptionPaneDemo.warningtitle"),
108+
JOptionPane.WARNING_MESSAGE
109+
);
110+
}
111+
};
112+
return createButton(a);
107113
}
108114

109115
public JButton createMessageDialogButton() {
110-
Action a = new AbstractAction(getString("OptionPaneDemo.messagebutton")) {
111-
URL img = getClass().getResource("/resources/images/optionpane/bottle.gif");
112-
String imagesrc = "<img src=\"" + img + "\" width=\"284\" height=\"100\">";
113-
String message = getString("OptionPaneDemo.messagetext");
114-
public void actionPerformed(ActionEvent e) {
115-
JOptionPane.showMessageDialog(
116-
getDemoPanel(),
117-
"<html>" + imagesrc + "<br><center>" + message + "</center><br></html>"
118-
);
119-
}
120-
};
121-
return createButton(a);
116+
Action a = new AbstractAction(getString("OptionPaneDemo.messagebutton")) {
117+
URL img = getClass().getResource("/resources/images/optionpane/bottle.gif");
118+
String imagesrc = "<img src=\"" + img + "\" width=\"284\" height=\"100\">";
119+
String message = getString("OptionPaneDemo.messagetext");
120+
121+
public void actionPerformed(ActionEvent e) {
122+
JOptionPane.showMessageDialog(
123+
getDemoPanel(),
124+
"<html>" + imagesrc + "<br><center>" + message + "</center><br></html>"
125+
);
126+
}
127+
};
128+
return createButton(a);
122129
}
123130

124131
public JButton createConfirmDialogButton() {
125-
Action a = new AbstractAction(getString("OptionPaneDemo.confirmbutton")) {
126-
public void actionPerformed(ActionEvent e) {
132+
Action a = new AbstractAction(getString("OptionPaneDemo.confirmbutton")) {
133+
public void actionPerformed(ActionEvent e) {
127134
int result = JOptionPane.showConfirmDialog(getDemoPanel(), getString("OptionPaneDemo.confirmquestion"));
128-
if(result == JOptionPane.YES_OPTION) {
129-
JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.confirmyes"));
130-
} else if(result == JOptionPane.NO_OPTION) {
135+
if (result == JOptionPane.YES_OPTION) {
136+
JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.confirmyes"));
137+
} else if (result == JOptionPane.NO_OPTION) {
131138
JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.confirmno"));
132-
}
133-
}
134-
};
135-
return createButton(a);
139+
}
140+
}
141+
};
142+
return createButton(a);
136143
}
137144

138145
public JButton createInputDialogButton() {
139-
Action a = new AbstractAction(getString("OptionPaneDemo.inputbutton")) {
140-
public void actionPerformed(ActionEvent e) {
146+
Action a = new AbstractAction(getString("OptionPaneDemo.inputbutton")) {
147+
public void actionPerformed(ActionEvent e) {
141148
String result = JOptionPane.showInputDialog(getDemoPanel(), getString("OptionPaneDemo.inputquestion"));
142-
JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.inputresponse"));
143-
}
144-
};
145-
return createButton(a);
149+
JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.inputresponse"));
150+
}
151+
};
152+
return createButton(a);
146153
}
147154

148155
public JButton createComponentDialogButton() {
149-
Action a = new AbstractAction(getString("OptionPaneDemo.componentbutton")) {
150-
public void actionPerformed(ActionEvent e) {
151-
// In a ComponentDialog, you can show as many message components and
152-
// as many options as you want:
156+
Action a = new AbstractAction(getString("OptionPaneDemo.componentbutton")) {
157+
public void actionPerformed(ActionEvent e) {
158+
// In a ComponentDialog, you can show as many message components and
159+
// as many options as you want:
153160

154-
// Messages
155-
Object[] message = new Object[4];
161+
// Messages
162+
Object[] message = new Object[4];
156163
message[0] = getString("OptionPaneDemo.componentmessage");
157164
message[1] = new JTextField(getString("OptionPaneDemo.componenttextfield"));
158165

@@ -164,61 +171,61 @@ public void actionPerformed(ActionEvent e) {
164171

165172
message[3] = getString("OptionPaneDemo.componentmessage2");
166173

167-
// Options
174+
// Options
168175
String[] options = {
169-
getString("OptionPaneDemo.component_op1"),
170-
getString("OptionPaneDemo.component_op2"),
171-
getString("OptionPaneDemo.component_op3"),
172-
getString("OptionPaneDemo.component_op4"),
173-
getString("OptionPaneDemo.component_op5")
174-
};
176+
getString("OptionPaneDemo.component_op1"),
177+
getString("OptionPaneDemo.component_op2"),
178+
getString("OptionPaneDemo.component_op3"),
179+
getString("OptionPaneDemo.component_op4"),
180+
getString("OptionPaneDemo.component_op5")
181+
};
175182
int result = JOptionPane.showOptionDialog(
176-
getDemoPanel(), // the parent that the dialog blocks
177-
message, // the dialog message array
178-
getString("OptionPaneDemo.componenttitle"), // the title of the dialog window
179-
JOptionPane.DEFAULT_OPTION, // option type
180-
JOptionPane.INFORMATION_MESSAGE, // message type
181-
null, // optional icon, use null to use the default icon
182-
options, // options string array, will be made into buttons
183-
options[3] // option that should be made into a default button
184-
);
185-
switch(result) {
186-
case 0: // yes
187-
JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.component_r1"));
188-
break;
189-
case 1: // no
190-
JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.component_r2"));
191-
break;
192-
case 2: // maybe
193-
JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.component_r3"));
194-
break;
195-
case 3: // probably
196-
JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.component_r4"));
197-
break;
198-
default:
199-
break;
200-
}
201-
202-
}
203-
};
204-
return createButton(a);
183+
getDemoPanel(), // the parent that the dialog blocks
184+
message, // the dialog message array
185+
getString("OptionPaneDemo.componenttitle"), // the title of the dialog window
186+
JOptionPane.DEFAULT_OPTION, // option type
187+
JOptionPane.INFORMATION_MESSAGE, // message type
188+
null, // optional icon, use null to use the default icon
189+
options, // options string array, will be made into buttons
190+
options[3] // option that should be made into a default button
191+
);
192+
switch (result) {
193+
case 0: // yes
194+
JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.component_r1"));
195+
break;
196+
case 1: // no
197+
JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.component_r2"));
198+
break;
199+
case 2: // maybe
200+
JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.component_r3"));
201+
break;
202+
case 3: // probably
203+
JOptionPane.showMessageDialog(getDemoPanel(), getString("OptionPaneDemo.component_r4"));
204+
break;
205+
default:
206+
break;
207+
}
208+
209+
}
210+
};
211+
return createButton(a);
205212
}
206-
213+
207214
public JButton createButton(Action a) {
208-
JButton b = new JButton() {
209-
public Dimension getMaximumSize() {
210-
int width = Short.MAX_VALUE;
211-
int height = super.getMaximumSize().height;
212-
return new Dimension(width, height);
213-
}
214-
};
215-
// setting the following client property informs the button to show
216-
// the action text as it's name. The default is to not show the
217-
// action text.
218-
b.putClientProperty("displayActionText", Boolean.TRUE);
219-
b.setAction(a);
220-
// b.setAlignmentX(JButton.CENTER_ALIGNMENT);
221-
return b;
215+
JButton b = new JButton() {
216+
public Dimension getMaximumSize() {
217+
int width = Short.MAX_VALUE;
218+
int height = super.getMaximumSize().height;
219+
return new Dimension(width, height);
220+
}
221+
};
222+
// setting the following client property informs the button to show
223+
// the action text as it's name. The default is to not show the
224+
// action text.
225+
b.putClientProperty("displayActionText", Boolean.TRUE);
226+
b.setAction(a);
227+
// b.setAlignmentX(JButton.CENTER_ALIGNMENT);
228+
return b;
222229
}
223230

224231
}

set_swing/src/main/java/SwingSet2.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
* @(#)SwingSet2.java 1.35 03/01/23
3939
*/
4040

41+
import mdlaf.utils.MaterialColors;
42+
4143
import javax.swing.*;
4244
import javax.swing.border.EtchedBorder;
4345
import javax.swing.event.ChangeEvent;
@@ -1004,6 +1006,8 @@ public void setLookAndFeel(String laf) {
10041006
public void updateLookAndFeel() {
10051007
try {
10061008
UIManager.setLookAndFeel(currentLookAndFeel);
1009+
UIManager.put("Button[focus].color", MaterialColors.DARKLY_GRAY);
1010+
UIManager.put("Button.focusable", true);
10071011
for (Iterator itr = swingSets.iterator(); itr.hasNext(); ) {
10081012
SwingSet2 ss = (SwingSet2) itr.next();
10091013
SwingUtilities.updateComponentTreeUI(ss);
7.32 KB
Loading
29.1 KB
Loading
12.4 KB
Loading
12.2 KB
Loading

0 commit comments

Comments
 (0)