?? pushcounter.java
字號:
import javax.swing.JFrame;
public class PushCounter
{
public static void main (String[] args)
{ JFrame frame=new JFrame("push counter");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new PushCounterPanel());
frame.pack();
frame.setVisible(true);
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class PushCounterPanel extends JPanel
{private int count;
private JButton push;
private JLabel label;
public PushCounterpanel()
{count=0;
push=new JButton ("push me!");
label=new JLabel("pushes:" +count);
add(push);
add(label);
setPreferredSize(new Dimension(300,400));
setBackground(Color.cyan);
}
private class ButtonListener implements ActionListener
{
{public void actionPerformed(ActionEvent event)
count++;
label.setText("Pushes:"+count);
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -