Repository navigation
Expand file tree
/
Copy pathguiPrefs.java
More file actions
89 lines (77 loc) · 2.55 KB
/
Copy pathguiPrefs.java
File metadata and controls
89 lines (77 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import javax.swing.*; // Swing objects
//import java.awt.event.*; // Action listener stuff
import java.awt.*;
import java.util.*; // For
import java.awt.event.*; // For the listeners
import java.util.prefs.Preferences; // Preferences
import java.util.logging.*;
/**
* Implements the functions necessary for the user preference windows
*
* @author Christer Vaskinn
*
*/
public class guiPrefs extends JFrame{
/**
* Constructor for preference window
*/
Logger logger = Logger.getLogger("MyLog");
public guiPrefs(){
super(prosjekt1.getMessages().getString("winPreferencesTitle"));
try{
GridBagLayout thisLayout = new GridBagLayout(); // Sets the window to gridbag
GridBagConstraints wplCons = new GridBagConstraints(); // Constraints for new file
this.setLayout(thisLayout);
wplCons.insets = new Insets(5,5,5,5); // Sets internal padding
wplCons.fill = GridBagConstraints.HORIZONTAL;
wplCons.gridx = 0;
wplCons.gridy = 0;
wplCons.gridwidth = 1;
wplCons.weightx = 3;
wplCons.anchor = GridBagConstraints.EAST;
this.add(new JLabel(prosjekt1.getMessages().getString("winPreferenceIceCreamQuestion")),wplCons);
wplCons.gridx = 2;
wplCons.gridy = 0;
wplCons.gridwidth = GridBagConstraints.REMAINDER;
this.add(genJCombo(),wplCons);
wplCons.gridx = 0;
wplCons.gridy = 5;
wplCons.weightx = 1;
wplCons.gridwidth = 2;
JButton btnCancel = new JButton(prosjekt1.getMessages().getString("stdDialogCancel"));
this.add(btnCancel,wplCons);
wplCons.gridx = 2;
wplCons.gridwidth = 2;
wplCons.gridy = 5;
wplCons.weightx = 1;
JButton btnOK = new JButton(prosjekt1.getMessages().getString("stdDialogOK"));
this.add(btnOK,wplCons);
pack();
btnCancel.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
guiPrefs.this.setVisible(false);
}
});
this.setSize((int)this.getSize().getWidth() + 20, (int)this.getSize().getHeight() + 10);
this.setVisible(true);
}
catch(Exception pEx){
logger.log(Level.WARNING, pEx.getMessage());
}
}
private JComboBox genJCombo(){
try{
String[] test = {"Vanilla", "Strawberry","Chocolate"};
//String[] test = prosjekt1.getMessages().getStringArray("winPreferenceIceCreamFlavors.String[]");
System.out.println(test);
JComboBox loveIceCream = new JComboBox(test);
loveIceCream.setEditable(true);
loveIceCream.setMaximumRowCount(3);
return (loveIceCream);
}
catch(Exception e){
logger.log(Level.WARNING,e.getMessage());
return(new JComboBox(new String[] {"Error!"}));
}
}
}