import javax.swing.*;
import java.awt.*;
public class UseDimension1 extends JPanel{
JButton b1,b2;
JTextField text;
public UseDimension1(){
setLayout(new FlowLayout());
b1=new JButton("OK");
b2=new JButton("Cancel");
text=new JTextField(10);
add(text);
add(b1);
add(b2);
}
public static void main(String[]args){
JFrame f=new JFrame();
Toolkit tk=f.getToolkit();
Dimension screen=tk.getScreenSize();
Dimension FrameSize=new Dimension(300,100);
f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
f.setSize(FrameSize);
Container c=f.getContentPane();
c.add(new UseDimension1());
int x=(screen.width-FrameSize.width)/2;
int y=(screen.height-FrameSize.height)/2;
f.setLocation(x,y);
f.show();
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น