package javaPracticeCode;
public class JFrameComboBox extends javax.swing.JFrame {
/** Creates new form JFrameComboBox */
public JFrameComboBox() {
initComponents();
TimerScript stain = new TimerScript();
stain.run();
}
/** 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() {
TestComboBox = new javax.swing.JComboBox();
jTextField1 = new javax.swing.JTextField();
jComboBox2 = new javax.swing.JComboBox();
jTextField2 = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
TestComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "(none selected)", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }));
TestComboBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TestComboBoxActionPerformed(evt);
}
});
jTextField1.setText("jTextField1");
jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jTextField2.setText("jTextField2");
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(TestComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextField2, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE))
.addContainerGap(90, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(TestComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(212, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void TestComboBoxActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// JComboBox cb = (JComboBox)e.getSource();
String month = (String)TestComboBox.getSelectedItem();
String monthInt = month;
if(month == "1")
jTextField1.setText("January");
else if(month == "2")
jTextField1.setText("February");
else if(month =="3")
jTextField1.setText("March");
else
jTextField1.setText("Every month is a PARTY!");
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JFrameComboBox().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JComboBox TestComboBox;
private javax.swing.JComboBox jComboBox2;
public javax.swing.JTextField jTextField1;
public static javax.swing.JTextField jTextField2;
// End of variables declaration
}