java swing单选按钮点击事件_java Swing中点击不同单选按钮JPanel中部分区域进行改变,如何实现?。。急啊!...
展開全部
public class NewJFrame extends javax.swing.JFrame {
/** Creates new form NewJFrame */
public NewJFrame() {
initComponents();
}
/** 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")
//
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
buttonGroup1 = new javax.swing.ButtonGroup();
jPanel1 = new javax.swing.JPanel();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jPanel2 = new javax.swing.JPanel();
jPanel3 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jFormattedTextField1 = new javax.swing.JFormattedTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jFormattedTextField2 = new javax.swing.JFormattedTextField();
jLabel4 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox();
jLabel6 = new javax.swing.JLabel();
jPanel4 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new java.awt.GridBagLayout());
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(NewJFrame.class, "NewJFrame.jPanel1.border.title"))); // NOI18N
jPanel1.setLayout(new java.awt.GridBagLayout());
buttonGroup1.add(jRadioButton1);
jRadioButton1.setText(org.openide.util.NbBundle.getMessage(NewJFrame.class, "NewJFrame.jRadioButton1.text")); // NOI18N
jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton1ActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
jPanel1.add(jRadioButton1, gridBagConstraints);
buttonGroup1.add(jRadioButton2);
jRadioButton2.setText(org.openide.util.NbBundle.getMessage(NewJFrame.class, "NewJFrame.jRadioButton2.text")); // NOI18N
jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton2ActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
jPanel1.add(jRadioButton2, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
getContentPane().add(jPanel1, gridBagConstraints);
jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel2.setLayout(new java.awt.CardLayout());
jPanel3.setLayout(new java.awt.GridBagLayout());
jLabel1.setText(org.openide.util.NbBundle.getMessage(NewJFrame.class, "NewJFrame.jLabel1.text")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
jPanel3.add(jLabel1, gridBagConstraints);
jFormattedTextField1.setColumns(5);
jFormattedTextField1.setText(org.openide.util.NbBundle.getMessage(NewJFrame.class, "NewJFrame.jFormattedTextField1.text")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.ipadx = 30;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
jPanel3.add(jFormattedTextField1, gridBagConstraints);
jLabel2.setText(org.openide.util.NbBundle.getMessage(NewJFrame.class, "NewJFrame.jLabel2.text")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
jPanel3.add(jLabel2, gridBagConstraints);
jLabel3.setText(org.openide.util.NbBundle.getMessage(NewJFrame.class, "NewJFrame.jLabel3.text")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
jPanel3.add(jLabel3, gridBagConstraints);
jFormattedTextField2.setColumns(5);
jFormattedTextField2.setText(org.openide.util.NbBundle.getMessage(NewJFrame.class, "NewJFrame.jFormattedTextField2.text")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.ipadx = 30;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
jPanel3.add(jFormattedTextField2, gridBagConstraints);
jLabel4.setText(org.openide.util.NbBundle.getMessage(NewJFrame.class, "NewJFrame.jLabel4.text")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
jPanel3.add(jLabel4, gridBagConstraints);
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1成", "2成", "3成", "4成" }));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 1;
gridBagConstraints.ipadx = 5;
gridBagConstraints.ipady = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
jPanel3.add(jComboBox1, gridBagConstraints);
jLabel6.setText(org.openide.util.NbBundle.getMessage(NewJFrame.class, "NewJFrame.jLabel6.text")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 1;
jPanel3.add(jLabel6, gridBagConstraints);
jPanel2.add(jPanel3, "card2");
jPanel4.setLayout(new java.awt.GridBagLayout());
jLabel5.setText(org.openide.util.NbBundle.getMessage(NewJFrame.class, "NewJFrame.jLabel5.text")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel4.add(jLabel5, gridBagConstraints);
jTextField1.setColumns(8);
jTextField1.setText(org.openide.util.NbBundle.getMessage(NewJFrame.class, "NewJFrame.jTextField1.text")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.ipadx = 48;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel4.add(jTextField1, gridBagConstraints);
jPanel2.add(jPanel4, "card3");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
getContentPane().add(jPanel2, gridBagConstraints);
pack();
}//
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
((CardLayout) this.jPanel2.getLayout()).first(jPanel2);
}
private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
((CardLayout) this.jPanel2.getLayout()).next(jPanel2);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JFormattedTextField jFormattedTextField1;
private javax.swing.JFormattedTextField jFormattedTextField2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JTextField jTextField1;
// End of variables declaration
}
NewJFrame.jPanel1.border.title=計算方式
NewJFrame.jRadioButton1.text=jRadioButton1
NewJFrame.jRadioButton2.text=jRadioButton2
NewJFrame.jLabel1.text=單價
NewJFrame.jFormattedTextField1.text=
NewJFrame.jLabel2.text=元/平方
NewJFrame.jLabel3.text=面積
NewJFrame.jFormattedTextField2.text=
NewJFrame.jLabel4.text=平方
NewJFrame.jLabel5.text=總額
NewJFrame.jTextField1.text=
NewJFrame.jLabel6.text=按揭
netbeans生成的代碼你把編譯不過的地方用上面的62616964757a686964616fe78988e69d8331333264633465配置文件對應的字段替代。
已贊過
已踩過<
你對這個回答的評價是?
評論
收起
總結(jié)
以上是生活随笔為你收集整理的java swing单选按钮点击事件_java Swing中点击不同单选按钮JPanel中部分区域进行改变,如何实现?。。急啊!...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java jndi 例子_MEJB附录B
- 下一篇: java cindy_java枚举应用