GUI Frame(一)
2015-11-26 22:44
399 查看
package TestFrame;
import java.awt.*;
import java.awt.event.*;
public class TestFrame {
public static void main(String[] args) {
// TODO Auto-generated method stub
boolean flag = false;
if(flag == true) {
MyFrame f1 = new MyFrame(100,100,200,200,Color.BLUE);
MyFrame f2 = new MyFrame(300,100,200,200,Color.BLUE);
MyFrame f3 = new MyFrame(100,300,200,200,Color.BLUE);
MyFrame f4 = new MyFrame(300,300,200,200,Color.BLUE);
Frame f = new Frame("Java Frame with Panel");
Panel p = new Panel(null);
f.setLayout(null);
f.setBounds(300,300,500,500); //相对于屏幕坐标
f.setBackground(new Color(0,0,102));
p.setBounds(50,50,400,400);//相对于frame坐标
p.setBackground(new Color(204,204,255));
f.add(p);
f.setVisible(true);
}
new MyFrame2("MyFrameWithPanel",300,300,400,300);
}
}
class MyFrame extends Frame {
static int id = 0;
MyFrame(int x,int y,int w,int h,Color color) {
super("MyFrame" + (++id));
setBackground(color);
setLayout(null);
setBounds(x,y,w,h);
setVisible(true);
}
}
class MyFrame2 extends Frame {
private Panel p1,p2,p3,p4;
MyFrame2(String s,int x,int y,int w,int h) {
super(s);
setLayout(null);
p1 = new Panel(null);
p2 = new Panel(null);
p3 = new Panel(null);
p4 = new Panel(null);
p1.setBounds(0,0,w/2,h/2);
p2.setBounds(0,h/2,w/2,h/2);
p3.setBounds(w/2,0,w/2,h/2);
p4.setBounds(w/2,h/2,w/2,h/2);
p1.setBackground(Color.BLUE);
p2.setBackground(Color.GREEN);
p3.setBackground(Color.YELLOW);
p4.setBackground(Color.MAGENTA);
add(p1);
add(p2);
add(p3);
add(p4);
setBounds(x,y,w,h);
setVisible(true);
}
}
import java.awt.*;
import java.awt.event.*;
public class TestFrame {
public static void main(String[] args) {
// TODO Auto-generated method stub
boolean flag = false;
if(flag == true) {
MyFrame f1 = new MyFrame(100,100,200,200,Color.BLUE);
MyFrame f2 = new MyFrame(300,100,200,200,Color.BLUE);
MyFrame f3 = new MyFrame(100,300,200,200,Color.BLUE);
MyFrame f4 = new MyFrame(300,300,200,200,Color.BLUE);
Frame f = new Frame("Java Frame with Panel");
Panel p = new Panel(null);
f.setLayout(null);
f.setBounds(300,300,500,500); //相对于屏幕坐标
f.setBackground(new Color(0,0,102));
p.setBounds(50,50,400,400);//相对于frame坐标
p.setBackground(new Color(204,204,255));
f.add(p);
f.setVisible(true);
}
new MyFrame2("MyFrameWithPanel",300,300,400,300);
}
}
class MyFrame extends Frame {
static int id = 0;
MyFrame(int x,int y,int w,int h,Color color) {
super("MyFrame" + (++id));
setBackground(color);
setLayout(null);
setBounds(x,y,w,h);
setVisible(true);
}
}
class MyFrame2 extends Frame {
private Panel p1,p2,p3,p4;
MyFrame2(String s,int x,int y,int w,int h) {
super(s);
setLayout(null);
p1 = new Panel(null);
p2 = new Panel(null);
p3 = new Panel(null);
p4 = new Panel(null);
p1.setBounds(0,0,w/2,h/2);
p2.setBounds(0,h/2,w/2,h/2);
p3.setBounds(w/2,0,w/2,h/2);
p4.setBounds(w/2,h/2,w/2,h/2);
p1.setBackground(Color.BLUE);
p2.setBackground(Color.GREEN);
p3.setBackground(Color.YELLOW);
p4.setBackground(Color.MAGENTA);
add(p1);
add(p2);
add(p3);
add(p4);
setBounds(x,y,w,h);
setVisible(true);
}
}
相关文章推荐
- iPhone的UITextField-更改占位符文本颜色
- SPOJ LIS2 Another Longest Increasing Subsequence Problem 三维偏序最长链 CDQ分治
- mybatis:java.lang.IllegalArgumentException:Parameter Maps collection does notcontain value for ...
- 读书笔记--其他UI组件
- 108 Which two statements are true about the Automatic Diagnostic Repository (ADR)? (Choose two.) A.
- UIScrollView视差模糊效果
- Android官方文档翻译 五 1.3Building a Simple User Interface
- QUESTION 105 Examine the following RMAN script: RMAN> run { debug on; allocate channel c1 type disk;
- UI错误集
- 基于GUI的简易图像处理系统设计与实现
- UIView设置圆角、边框和阴影
- UITextFieldDelegate协议中各个方法调用情况
- 606第七周周赛 C - Wavio Sequence最长递增递减序列
- Auto Layout 使用心得(五)—— 根据文字、图片自动计算 UITableViewCell 高度
- 深入理解dispatch_queue
- UI-Target-action模式
- 浴室随想——RogueLike随想
- contentWindow,contentDocument, docuemnt ,window,self,top,parent,opener的关系
- crfsuite 安装文档
- leetcode_Range Sum Query 2D - Immutable