62,614
社区成员
发帖
与我相关
我的任务
分享
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class lcd extends JFrame{
JPanel p = new JPanel();
private JButton b1 = new JButton("Setup");
private JButton b2 = new JButton("Hide");
private Image icon;
public lcd(){
icon=Toolkit.getDefaultToolkit().getImage("1.gif");
Container con = this.getContentPane();
con.setLayout(null);
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
b1_button(e);
}
});
b2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
b2_button(e);
}
});
p.setBackground(Color.BLACK);
p.setBounds(0, 85, 400, 50);
b1.setBounds(340, 0, 60, 40);
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
b1.setBorder(null);
b2.setBounds(280, 0, 60, 40);
b2.setBackground(Color.BLACK);
b2.setForeground(Color.WHITE);
b2.setBorder(null);
p.add(b2);
p.setLayout(null);
p.add(b1);
con.add(p);
con.setBackground(Color.WHITE);
// this.setIconImage(icon)
}
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.RED);
g.drawString("hello java", 0,40);
}
public void b1_button(ActionEvent e){
}
public void b2_button(ActionEvent e){
this.setState(1);
}
public static void main(String args[]){
lcd lc= new lcd();
lc.setSize(400,150);
lc.setVisible(true);
}
}