Skip to content

Instantly share code, notes, and snippets.

@xyzshantaram
Created August 26, 2018 02:43
Show Gist options
  • Save xyzshantaram/820bbfd8eb6da331fe6c5e9253de4db9 to your computer and use it in GitHub Desktop.
Save xyzshantaram/820bbfd8eb6da331fe6c5e9253de4db9 to your computer and use it in GitHub Desktop.
q
w
e
r
t
y
u
i
o
p
/*
* 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 siddharth;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
/**
*
* @author sid
*/
public class NewJFrame extends javax.swing.JFrame {
/**
* Creates new form NewJFrame
*/
public NewJFrame() {
initComponents();
houseChangeVisible(false);
voteVoidVisible(false);
try {
BufferedReader in;
in = new BufferedReader(new FileReader("helloworld.txt"));
int lines = 0;
while (in.readLine() != null) lines++;
System.out.println(lines);
String[] read = new String[lines];
for (int i = 0; i < lines; i++) {
read[i] = in.readLine();
System.out.println("file output: " + read[i]);
in.close();
}
}
catch (IOException e) {
System.out.println("There was a problem:" + e);
}
}
/**
* 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">
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
jLayeredPane1 = new javax.swing.JLayeredPane();
PositionsPane = new javax.swing.JTabbedPane();
HeadPosnPane = new javax.swing.JPanel();
HBLabel = new javax.swing.JLabel();
HeadBoyBox = new javax.swing.JComboBox<>();
HGLabel = new javax.swing.JLabel();
HeadGirlBox = new javax.swing.JComboBox<>();
CulPane = new javax.swing.JPanel();
CulLabel = new javax.swing.JLabel();
ACulLabel = new javax.swing.JLabel();
CulBox = new javax.swing.JComboBox<>();
ACulBox = new javax.swing.JComboBox<>();
HousePane = new javax.swing.JPanel();
CapLabel = new javax.swing.JLabel();
ACapLabel = new javax.swing.JLabel();
CapBox = new javax.swing.JComboBox<>();
ACapBox = new javax.swing.JComboBox<>();
HouseIndicatorLabel = new javax.swing.JLabel();
HouseIndicatorBox = new javax.swing.JTextField();
redRadBtn = new javax.swing.JRadioButton();
greenRadBtn = new javax.swing.JRadioButton();
blueRadBtn = new javax.swing.JRadioButton();
yellowRadBtn = new javax.swing.JRadioButton();
passwdField = new javax.swing.JPasswordField();
houseChangeBtn = new javax.swing.JButton();
passwdLabel = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
SportsPane = new javax.swing.JPanel();
SCLabel = new javax.swing.JLabel();
ASCBox = new javax.swing.JComboBox<>();
ASCLabel = new javax.swing.JLabel();
SportsCapBox = new javax.swing.JComboBox<>();
ConfigPane = new javax.swing.JPanel();
configPasswdField = new javax.swing.JPasswordField();
voteVoidField = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
unlockButton = new javax.swing.JButton();
voidConfirmBtn = new javax.swing.JButton();
voidLabel = new javax.swing.JLabel();
hideButton = new javax.swing.JButton();
submitButton = new javax.swing.JButton();
rollNumBox1 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
rollNumBox2 = new javax.swing.JTextField();
rollNumBox3 = new javax.swing.JTextField();
rollNumBox4 = new javax.swing.JTextField();
rollNumBox5 = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Student Council Elections - APS Chennai");
HBLabel.setText("Head Boy:");
HeadBoyBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "<select>", "item1" }));
HGLabel.setText("Head Girl:");
HeadGirlBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "<select>", "item1" }));
javax.swing.GroupLayout HeadPosnPaneLayout = new javax.swing.GroupLayout(HeadPosnPane);
HeadPosnPane.setLayout(HeadPosnPaneLayout);
HeadPosnPaneLayout.setHorizontalGroup(
HeadPosnPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(HeadPosnPaneLayout.createSequentialGroup()
.addContainerGap(74, Short.MAX_VALUE)
.addGroup(HeadPosnPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(HBLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(HGLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(4, 4, 4)
.addGroup(HeadPosnPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(HeadGirlBox, 0, 200, Short.MAX_VALUE)
.addComponent(HeadBoyBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(91, Short.MAX_VALUE))
);
HeadPosnPaneLayout.setVerticalGroup(
HeadPosnPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(HeadPosnPaneLayout.createSequentialGroup()
.addGap(62, 62, 62)
.addGroup(HeadPosnPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(HBLabel)
.addComponent(HeadBoyBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(HeadPosnPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(HGLabel)
.addComponent(HeadGirlBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(118, Short.MAX_VALUE))
);
PositionsPane.addTab("Heads", HeadPosnPane);
CulLabel.setText("Cultural Secretary");
ACulLabel.setText("Assistant Cultural Secretary");
CulBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "<select>", "item1" }));
CulBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CulBoxActionPerformed(evt);
}
});
ACulBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "<select>", "item1" }));
javax.swing.GroupLayout CulPaneLayout = new javax.swing.GroupLayout(CulPane);
CulPane.setLayout(CulPaneLayout);
CulPaneLayout.setHorizontalGroup(
CulPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(CulPaneLayout.createSequentialGroup()
.addGap(47, 47, 47)
.addGroup(CulPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(ACulLabel)
.addComponent(CulLabel))
.addGap(18, 18, 18)
.addGroup(CulPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(CulBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(ACulBox, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(58, Short.MAX_VALUE))
);
CulPaneLayout.setVerticalGroup(
CulPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(CulPaneLayout.createSequentialGroup()
.addGap(54, 54, 54)
.addGroup(CulPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(CulLabel)
.addComponent(CulBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(CulPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(ACulLabel)
.addComponent(ACulBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(126, Short.MAX_VALUE))
);
PositionsPane.addTab("Cultural Secretaries", CulPane);
CapLabel.setText("Captain");
ACapLabel.setText("Assistant Captain");
CapBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "<select>", "item1" }));
CapBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CapBoxActionPerformed(evt);
}
});
ACapBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "<select>", "item1" }));
ACapBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ACapBoxActionPerformed(evt);
}
});
HouseIndicatorLabel.setText("House:");
HouseIndicatorBox.setEditable(false);
HouseIndicatorBox.setText(" ");
buttonGroup1.add(redRadBtn);
redRadBtn.setText("Red");
buttonGroup1.add(greenRadBtn);
greenRadBtn.setText("Green");
buttonGroup1.add(blueRadBtn);
blueRadBtn.setText("Blue");
buttonGroup1.add(yellowRadBtn);
yellowRadBtn.setText("Yellow");
houseChangeBtn.setText("Change");
houseChangeBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
houseChangeBtnActionPerformed(evt);
}
});
passwdLabel.setText("Password");
jButton1.setText("...");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout HousePaneLayout = new javax.swing.GroupLayout(HousePane);
HousePane.setLayout(HousePaneLayout);
HousePaneLayout.setHorizontalGroup(
HousePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(HousePaneLayout.createSequentialGroup()
.addGroup(HousePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(HousePaneLayout.createSequentialGroup()
.addGap(77, 77, 77)
.addComponent(passwdLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(passwdField, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(53, 53, 53)
.addComponent(houseChangeBtn)
.addGap(33, 33, 33))
.addGroup(HousePaneLayout.createSequentialGroup()
.addGroup(HousePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(HousePaneLayout.createSequentialGroup()
.addGap(79, 79, 79)
.addGroup(HousePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(ACapLabel)
.addComponent(CapLabel))
.addGap(18, 18, 18)
.addGroup(HousePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(CapBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(ACapBox, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(HousePaneLayout.createSequentialGroup()
.addGap(156, 156, 156)
.addComponent(HouseIndicatorLabel)
.addGap(18, 18, 18)
.addComponent(HouseIndicatorBox, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE)))
.addGap(44, 44, 44))
.addGroup(HousePaneLayout.createSequentialGroup()
.addGap(109, 109, 109)
.addComponent(redRadBtn)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(greenRadBtn)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(blueRadBtn)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(yellowRadBtn)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
HousePaneLayout.setVerticalGroup(
HousePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(HousePaneLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(HousePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(HouseIndicatorLabel)
.addComponent(HouseIndicatorBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addGap(18, 18, 18)
.addGroup(HousePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(CapLabel)
.addComponent(CapBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(HousePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(ACapLabel)
.addComponent(ACapBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(49, 49, 49)
.addGroup(HousePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(redRadBtn)
.addComponent(greenRadBtn)
.addComponent(blueRadBtn)
.addComponent(yellowRadBtn))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(HousePaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(passwdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(houseChangeBtn)
.addComponent(passwdLabel)))
);
PositionsPane.addTab("House Captains", HousePane);
SCLabel.setText("Sports Captain: ");
ASCBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "<select>", "item1" }));
ASCLabel.setText("Assistant Sports Captain:");
SportsCapBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "<select>", "item1" }));
SportsCapBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
SportsCapBoxActionPerformed(evt);
}
});
javax.swing.GroupLayout SportsPaneLayout = new javax.swing.GroupLayout(SportsPane);
SportsPane.setLayout(SportsPaneLayout);
SportsPaneLayout.setHorizontalGroup(
SportsPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(SportsPaneLayout.createSequentialGroup()
.addGap(55, 55, 55)
.addGroup(SportsPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(ASCLabel)
.addComponent(SCLabel))
.addGap(18, 18, 18)
.addGroup(SportsPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(ASCBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(SportsCapBox, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(67, Short.MAX_VALUE))
);
SportsPaneLayout.setVerticalGroup(
SportsPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(SportsPaneLayout.createSequentialGroup()
.addGap(49, 49, 49)
.addGroup(SportsPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(SCLabel)
.addComponent(SportsCapBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(SportsPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(ASCLabel)
.addComponent(ASCBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(131, Short.MAX_VALUE))
);
PositionsPane.addTab("Sports Captains", SportsPane);
jLabel2.setText("Config password:");
unlockButton.setText("Unlock");
unlockButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
unlockButtonActionPerformed(evt);
}
});
voidConfirmBtn.setText("Confirm");
voidConfirmBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
voidConfirmBtnActionPerformed(evt);
}
});
voidLabel.setText("Void previous vote");
hideButton.setText("Hide");
hideButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
hideButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout ConfigPaneLayout = new javax.swing.GroupLayout(ConfigPane);
ConfigPane.setLayout(ConfigPaneLayout);
ConfigPaneLayout.setHorizontalGroup(
ConfigPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(ConfigPaneLayout.createSequentialGroup()
.addGap(114, 114, 114)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(configPasswdField, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(unlockButton)
.addGap(0, 114, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ConfigPaneLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(hideButton, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(voidConfirmBtn)
.addGap(187, 187, 187))
.addGroup(ConfigPaneLayout.createSequentialGroup()
.addGap(125, 125, 125)
.addComponent(voidLabel)
.addGap(47, 47, 47)
.addComponent(voteVoidField, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
ConfigPaneLayout.setVerticalGroup(
ConfigPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(ConfigPaneLayout.createSequentialGroup()
.addGap(30, 30, 30)
.addGroup(ConfigPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(configPasswdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(unlockButton, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(36, 36, 36)
.addGroup(ConfigPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(voteVoidField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(voidLabel))
.addGap(34, 34, 34)
.addGroup(ConfigPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(voidConfirmBtn)
.addComponent(hideButton))
.addContainerGap(65, Short.MAX_VALUE))
);
PositionsPane.addTab("Config...", ConfigPane);
submitButton.setText("Submit");
submitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
submitButtonActionPerformed(evt);
}
});
jLabel1.setText("Roll number:");
jLayeredPane1.setLayer(PositionsPane, javax.swing.JLayeredPane.DRAG_LAYER);
jLayeredPane1.setLayer(submitButton, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(rollNumBox1, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(rollNumBox2, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(rollNumBox3, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(rollNumBox4, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLayeredPane1.setLayer(rollNumBox5, javax.swing.JLayeredPane.DEFAULT_LAYER);
javax.swing.GroupLayout jLayeredPane1Layout = new javax.swing.GroupLayout(jLayeredPane1);
jLayeredPane1.setLayout(jLayeredPane1Layout);
jLayeredPane1Layout.setHorizontalGroup(
jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jLayeredPane1Layout.createSequentialGroup()
.addComponent(PositionsPane, javax.swing.GroupLayout.PREFERRED_SIZE, 522, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 56, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jLayeredPane1Layout.createSequentialGroup()
.addGap(84, 84, 84)
.addComponent(jLabel1)
.addGap(28, 28, 28)
.addComponent(rollNumBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(rollNumBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(rollNumBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(rollNumBox4, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(5, 5, 5)
.addComponent(rollNumBox5, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(41, 41, 41)
.addComponent(submitButton)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jLayeredPane1Layout.setVerticalGroup(
jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jLayeredPane1Layout.createSequentialGroup()
.addGap(31, 31, 31)
.addComponent(PositionsPane, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(submitButton)
.addComponent(rollNumBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1)
.addComponent(rollNumBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(rollNumBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(rollNumBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(rollNumBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLayeredPane1)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
void message(String message) {
JOptionPane.showMessageDialog(this, message);
}
void resetAll() {
HeadBoyBox.setSelectedIndex(0);
HeadGirlBox.setSelectedIndex(0);
CulBox.setSelectedIndex(0);
ACulBox.setSelectedIndex(0);
CapBox.setSelectedIndex(0);
ACapBox.setSelectedIndex(0);
SportsCapBox.setSelectedIndex(0);
ASCBox.setSelectedIndex(0);
rollNumBox1.setText("");
rollNumBox2.setText("");
rollNumBox3.setText("");
rollNumBox4.setText("");
rollNumBox5.setText("");
}
boolean rollNoCheck() {
boolean voteAllowed;
String classString = rollNumBox1.getText() + rollNumBox2.getText();
int enteredClass;
enteredClass = Integer.parseInt(classString);
if (enteredClass < 8 || enteredClass > 12) {
message("Illegal roll number, class too great or small.");
voteAllowed = false;
return voteAllowed;
} else {
if (Integer.parseInt(rollNumBox4.getText() + rollNumBox5.getText()) == 0) {
voteAllowed = false;
message("Roll number cannot be zero.");
return voteAllowed;
} else {
voteAllowed = true;
return voteAllowed;
}
}
}
private void CulBoxActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
boolean houseChangeButtonPressed = false;
String House = "";
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (houseChangeButtonPressed == false) {
houseChangeButtonPressed = true;
houseChangeVisible(true);
} else {
houseChangeButtonPressed = false;
houseChangeVisible(false);
}
}
String password = "APSElection";
String successMessage = "House changed successfully.";
boolean canVote;
private void houseChangeBtnActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (redRadBtn.isSelected() && String.valueOf(passwdField.getPassword()).equals(password)) {
House = "Red";
message(successMessage);
} else if (blueRadBtn.isSelected() && String.valueOf(passwdField.getPassword()).equals(password)) {
House = "Blue";
message(successMessage);
} else if (yellowRadBtn.isSelected() && String.valueOf(passwdField.getPassword()).equals(password)) {
House = "Yellow";
message(successMessage);
} else if (greenRadBtn.isSelected() && String.valueOf(passwdField.getPassword()).equals(password)) {
House = "Green";
message(successMessage);
} else {
message("ERROR: Select house or verify password.");
}
HouseIndicatorBox.setText(House);
passwdField.setText("");
houseChangeVisible(false);
}
private void CapBoxActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void ACapBoxActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void SportsCapBoxActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (ACapBox.getSelectedItem().equals("<select>")
|| CapBox.getSelectedItem().equals("<select>")
|| HeadBoyBox.getSelectedItem().equals("<select>")
|| HeadGirlBox.getSelectedItem().equals("<select>")
|| SportsCapBox.getSelectedItem().equals("<select>")
|| ASCBox.getSelectedItem().equals("<select>")
|| CulBox.getSelectedItem().equals("<select>")
|| ACulBox.getSelectedItem().equals("<select>")) {
message("You cannot leave any of the values at default.");
canVote = false;
} else {
canVote = true;
}
if (canVote == true) {
if ("".equals(House)) {
canVote = false;
} else {
canVote = true;
}
} else {
}
if (rollNoCheck() != true || canVote != true) {
submitVote(false);
} else {
submitVote(true);
}
}
private void unlockButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (String.valueOf(configPasswdField.getPassword()).equals(password)) {
voteVoidVisible(true);
configPasswdField.setText("");
} else {
message("Illegal action: password incorrect");
configPasswdField.setText("");
}
}
private void hideButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
voteVoidVisible(false);
}
private void voidConfirmBtnActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (voteVoidField.getText().equals("")) {
message("Enter admission number before attempting void");
}
message("TODO: IMPLEMENT THE VOTE VOIDING");
}
/**
* @param args the command line arguments
*/
final void houseChangeVisible(boolean yes) {
redRadBtn.setVisible(yes);
greenRadBtn.setVisible(yes);
yellowRadBtn.setVisible(yes);
blueRadBtn.setVisible(yes);
passwdField.setVisible(yes);
passwdLabel.setVisible(yes);
houseChangeBtn.setVisible(yes);
}
final void voteVoidVisible(boolean state) {
voteVoidField.setVisible(state);
voidLabel.setVisible(state);
voidConfirmBtn.setVisible(state);
hideButton.setVisible(state);
}
void submitVote(boolean shouldSubmit) {
if (shouldSubmit == true) {
if ((JOptionPane.showConfirmDialog(this, "You have selected: \n"
+ HeadBoyBox.getSelectedItem() + " as Head Boy,\n"
+ HeadGirlBox.getSelectedItem() + " as Head Girl,\n"
+ SportsCapBox.getSelectedItem() + " as Sports Captain,\n"
+ ASCBox.getSelectedItem() + " as Head Boy,\n"
+ CulBox.getSelectedItem() + " as Cultural Secretary,\n"
+ ACulBox.getSelectedItem() + " as Assistant Cultural Secretary,\n"
+ CapBox.getSelectedItem() + " as " + House + " House's Captain,\n and "
+ CapBox.getSelectedItem() + " as " + House + " House's Assistant Captain,\n"
+ "Are you sure you want to register your votes for these candidates?", "Confirm",
JOptionPane.OK_CANCEL_OPTION)) == 0) {
message("TODO: Implement voting");
message("Thank you for voting, you can leave now.");
resetAll();
} else {
message("OK, change your options and try again!");
}
} else {
message("Illegal vote, will not be considered.");
resetAll();
}
}
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JComboBox<String> ACapBox;
private javax.swing.JLabel ACapLabel;
private javax.swing.JComboBox<String> ACulBox;
private javax.swing.JLabel ACulLabel;
private javax.swing.JComboBox<String> ASCBox;
private javax.swing.JLabel ASCLabel;
private javax.swing.JComboBox<String> CapBox;
private javax.swing.JLabel CapLabel;
private javax.swing.JPanel ConfigPane;
private javax.swing.JComboBox<String> CulBox;
private javax.swing.JLabel CulLabel;
private javax.swing.JPanel CulPane;
private javax.swing.JLabel HBLabel;
private javax.swing.JLabel HGLabel;
private javax.swing.JComboBox<String> HeadBoyBox;
private javax.swing.JComboBox<String> HeadGirlBox;
private javax.swing.JPanel HeadPosnPane;
private javax.swing.JTextField HouseIndicatorBox;
private javax.swing.JLabel HouseIndicatorLabel;
private javax.swing.JPanel HousePane;
private javax.swing.JTabbedPane PositionsPane;
private javax.swing.JLabel SCLabel;
private javax.swing.JComboBox<String> SportsCapBox;
private javax.swing.JPanel SportsPane;
private javax.swing.JRadioButton blueRadBtn;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JPasswordField configPasswdField;
private javax.swing.JRadioButton greenRadBtn;
private javax.swing.JButton hideButton;
private javax.swing.JButton houseChangeBtn;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLayeredPane jLayeredPane1;
private javax.swing.JPasswordField passwdField;
private javax.swing.JLabel passwdLabel;
private javax.swing.JRadioButton redRadBtn;
private javax.swing.JTextField rollNumBox1;
private javax.swing.JTextField rollNumBox2;
private javax.swing.JTextField rollNumBox3;
private javax.swing.JTextField rollNumBox4;
private javax.swing.JTextField rollNumBox5;
private javax.swing.JButton submitButton;
private javax.swing.JButton unlockButton;
private javax.swing.JButton voidConfirmBtn;
private javax.swing.JLabel voidLabel;
private javax.swing.JTextField voteVoidField;
private javax.swing.JRadioButton yellowRadBtn;
// End of variables declaration
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment