home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-12-14 | 1.4 KB | 65 lines |
-
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
-
- public class NoLayout1 extends JPanel
- {
- public NoLayout1()
- {
- JButton btnOne;
- JButton btnTwo;
- JButton btnThree;
- JButton btnFour;
-
- this.setLayout(null);
-
- btnOne = new JButton("One");
- btnOne.setBounds(0,0,100,100);
- add(btnOne);
-
- btnTwo = new JButton("Two");
- btnTwo.setBounds(100,0,100,50);
- add(btnTwo);
-
- btnThree = new JButton("Three");
- btnThree.setBounds(0,100,75,100);
- add(btnThree);
-
- btnFour = new JButton("Four");
- btnFour.setBounds(115,115,100,100);
- add(btnFour);
-
- }//constructor
-
-
-
- public static void main(String s[])
- {
- JFrame f = new JFrame("No Layout");
- NoLayout1 panel = new NoLayout1();
-
- f.setForeground(Color.black);
- f.setBackground(Color.lightGray);
- f.getContentPane().add(panel, "Center");
-
- f.setSize(250,250);
- f.setVisible(true);
- f.addWindowListener(new WindowCloser());
-
-
- }//main
- }//class
-
-
- class WindowCloser extends WindowAdapter
- {
- public void windowClosing(WindowEvent e)
- {
- Window win = e.getWindow();
- win.setVisible(false);
- win.dispose();
- System.exit(0);
- }//windowClosing
- }//class WindowCloser
-