import java.awt.*; |
import java.awt.event.WindowAdapter; |
import java.awt.event.WindowEvent; |
public class CalFrame extends Frame { |
//http://www.2cto.com/kf/201405/298165.html |
public void launchFrame() { |
this .setTitle( "test" ); |
this .setBounds( 20 , 20 , 300 , 450 ); |
this .setMaximumSize( null ); |
this .setVisible( true ); |
this .setResizable( false ); |
this .addWindowListener( new WindowAdapter() { |
@Override |
public void windowClosing(WindowEvent e) { |
System.exit( 0 ); |
} |
}); |
MenuBar menu = new MenuBar(); |
Menu file = new Menu( "File" ); |
Menu edit = new Menu( "Edit" ); |
Menu source = new Menu( "Source" ); |
Menu refa = new Menu( "Refactor" ); |
menu.add(file); |
menu.add(edit); |
menu.add(source); |
menu.add(refa); |
this .setMenuBar(menu); |
Panel p = new Panel(); |
p.setLayout( new BorderLayout( 5 , 5 )); |
p.setBackground(Color.LIGHT_GRAY); |
this .add(p); |
TextArea t = new TextArea( "0" , 2 , 1 , TextArea.SCROLLBARS_NONE); |
t.setBounds( new Rectangle( 280 , 40 )); |
t.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); |
t.setEditable( false ); |
System.out.println(t.getWidth() + "----" + t.getHeight()); |
p.add(t, BorderLayout.NORTH); |
Panel sub = new Panel(); |
sub.setBackground(Color.GRAY); |
sub.setBounds( new Rectangle( 280 , (p.getHeight() - t.getHeight()))); |
p.add(sub, BorderLayout.CENTER); |
sub.setLayout( new GridLayout( 6 , 5 , 5 , 5 )); |
|
for ( int i = 0 ; i < 5 ; i++) { |
for ( int j = 0 ; j < 6 ; j++) { |
Button b = new Button( "i" ); |
int width = sub.getWidth() / 5 ; |
int height = sub.getHeight() / 6 ; |
b.setSize(width, height); |
b.setBackground(Color.LIGHT_GRAY); |
sub.add(b); |
} |
} |
|
} |
public static void main(String[] args) { |
new CalFrame().launchFrame(); |
} |
} |