?? frame1.java
字號(hào):
package ex06_04;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Frame1 extends JFrame { JPanel contentPane; JButton jButton1 = new JButton(); /**Construct the frame*/ public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); jButton1.setText("jButton1"); jButton1.setBounds(new Rectangle(24, 18, 79, 29)); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); contentPane.setLayout(null); this.setSize(new Dimension(400, 300)); this.setTitle("Frame Title"); contentPane.add(jButton1, null); } /**Overridden so we can exit when window is closed*/ protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void jButton1_actionPerformed(ActionEvent e) {int[][] dd = new int[3][4];for (int I=0 ; I<3 ; I++){ int ordersum=0; for (int J=0 ; J<4 ; J++) { dd[I][J]=Integer.parseInt(JOptionPane.showInputDialog(this,"請(qǐng)輸入第" + (I+1) + "位候選人,第" + (J+1) + "區(qū)票數(shù)")); ordersum+=dd[I][J]; } System.out.println("第" + (I+1) + "位候選人得" + ordersum + "票");} }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -