-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathColors.java
More file actions
203 lines (181 loc) · 8.77 KB
/
Colors.java
File metadata and controls
203 lines (181 loc) · 8.77 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package se;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
/**
*
* @author Nikhil Gupta
*/
public class Colors extends javax.swing.JFrame {
String user;
JFrame options;
public Colors(JFrame jf,String user) {
initComponents();
this.user=user;
this.options = jf;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jRadioButton3 = new javax.swing.JRadioButton();
jRadioButton4 = new javax.swing.JRadioButton();
jRadioButton5 = new javax.swing.JRadioButton();
jRadioButton6 = new javax.swing.JRadioButton();
jRadioButton7 = new javax.swing.JRadioButton();
jRadioButton8 = new javax.swing.JRadioButton();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Character Colour");
jLabel2.setText("Cave Colour");
buttonGroup1.add(jRadioButton1);
jRadioButton1.setMnemonic('1');
jRadioButton1.setText("Red");
jRadioButton1.setName("1"); // NOI18N
jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton1ActionPerformed(evt);
}
});
buttonGroup2.add(jRadioButton2);
jRadioButton2.setMnemonic('1');
jRadioButton2.setText("Red");
jRadioButton2.setName("1"); // NOI18N
buttonGroup2.add(jRadioButton3);
jRadioButton3.setMnemonic('2');
jRadioButton3.setText("Pink");
jRadioButton3.setName("2"); // NOI18N
buttonGroup2.add(jRadioButton4);
jRadioButton4.setMnemonic('3');
jRadioButton4.setText("Green");
jRadioButton4.setToolTipText("");
jRadioButton4.setName("3"); // NOI18N
buttonGroup2.add(jRadioButton5);
jRadioButton5.setMnemonic('4');
jRadioButton5.setSelected(true);
jRadioButton5.setText("Black");
jRadioButton5.setName("4"); // NOI18N
buttonGroup1.add(jRadioButton6);
jRadioButton6.setMnemonic('2');
jRadioButton6.setSelected(true);
jRadioButton6.setText("Pink");
jRadioButton6.setName("2"); // NOI18N
buttonGroup1.add(jRadioButton7);
jRadioButton7.setMnemonic('3');
jRadioButton7.setText("Green");
jRadioButton7.setName("3"); // NOI18N
buttonGroup1.add(jRadioButton8);
jRadioButton8.setMnemonic('4');
jRadioButton8.setText("Black");
jRadioButton8.setName("4"); // NOI18N
jButton1.setText("Save");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(73, 73, 73)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1)
.addComponent(jRadioButton1, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jRadioButton6, javax.swing.GroupLayout.Alignment.LEADING))
.addComponent(jRadioButton7)
.addComponent(jRadioButton8))
.addGap(70, 70, 70)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jRadioButton5)
.addComponent(jRadioButton4)
.addComponent(jRadioButton3)
.addComponent(jRadioButton2)
.addComponent(jLabel2)))
.addGroup(layout.createSequentialGroup()
.addGap(156, 156, 156)
.addComponent(jButton1)))
.addContainerGap(116, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(60, 60, 60)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jRadioButton1)
.addComponent(jRadioButton2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jRadioButton3)
.addComponent(jRadioButton6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jRadioButton4)
.addComponent(jRadioButton7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jRadioButton5)
.addComponent(jRadioButton8))
.addGap(18, 18, 18)
.addComponent(jButton1)
.addContainerGap(69, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jRadioButton1ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
DB db=new DB();
db.connDB();
//CHANGE IT
System.out.println(buttonGroup2.getSelection().getMnemonic() + " " +buttonGroup1.getSelection().getMnemonic());
if(buttonGroup2.getSelection().getMnemonic() == buttonGroup1.getSelection().getMnemonic())
JOptionPane.showMessageDialog(null, "Character Color and Cave Color cannot be same.");
else
{
db.updateColor(user, buttonGroup2.getSelection().getMnemonic()-48 , buttonGroup1.getSelection().getMnemonic()-48);
db.closeDB();
this.setVisible(false);
options.setVisible(true);
}
}//GEN-LAST:event_jButton1ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JRadioButton jRadioButton3;
private javax.swing.JRadioButton jRadioButton4;
private javax.swing.JRadioButton jRadioButton5;
private javax.swing.JRadioButton jRadioButton6;
private javax.swing.JRadioButton jRadioButton7;
private javax.swing.JRadioButton jRadioButton8;
// End of variables declaration//GEN-END:variables
}