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);
}
}
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);
}
}
解决方案 »
- JDBC ACCESS 操作错误求解!
- 奇怪的金字塔--光棍节打击
- 一个奇怪的多线程问题,求解!
- JSP最好的教学开发平台是什么?哪个软件能查出具体那行出错,并最好能提示呀!
- 如何清空一个文件中所有的内容,如何修改相对路径?
- 为什么这样报错?Exception in thread "main" java.lang.NoSuchMethodError: main
- 求具体代码:怎么判断一个字符串在另一个字符串中出现的次数?
- 如何使用java包?
- 产生异常的原因?
- 问个问题
- 使用Java读取sql server 2000中的数据与直接读取磁盘上.txt文件中的数据,这两者哪一个更快一些?
- 帮看一下这句英文题怎么译?谢谢
估計是gif的格式問題 ·~ 你試試吧 api上也 沒有講為什么~