📄 frame7_32.java
字号:
//the panel with three button
import java.awt.*;
import java.io.*;
class ThreeButtonsFrame extends Frame{
private String titlestr;
private int width = 0;
private int height = 0;
private Color mycolor;
public ThreeButtonsFrame(String s,int w,int h, Color c)
{
super(s);
titlestr=s;
width=w;
height=h;
mycolor=c;
}
public void go()
{
this.setSize(width,height);
this.setBackground(mycolor);
this.setLayout(new GridLayout(1,5));
Panel pan=new Panel();
pan.setSize(100,100);
pan.setBackground(Color.black);
Button b1=new Button("operation");
Button b2=new Button("button1");
Button b3=new Button("hello");
pan.add(b1);
pan.add(new Label());
pan.add(b2);
pan.add(new Label());
pan.add(b3);
this.add(pan);//if this lose it will not display panel
this.setVisible(true);
}
}
public class Frame7_32 {
/**
* Method main
*
*
* @param args
*
*/
public static void main(String[] args) {
// TODO: Add your code here
ThreeButtonsFrame tbf=new ThreeButtonsFrame("this is a Frame with button",200,300,Color.GREEN);
tbf.go();
BufferedReader intemp=new BufferedReader(new InputStreamReader(System.in));
//System.out.println("please return key to exit!!!");
try{
String s=intemp.readLine();
}
catch(IOException e)
{
System.out.println(e.toString());
System.exit(1);
}
System.exit(0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -