Paket springlayout;
Import javax.swing.JButton;
Import javax.swing.JFrame;
Import javax.swing.JPanel;
Import javax.swing.SpringLayout;
allgemeine Kategorie SpringLayoutTest verlängert JPanel {
allgemeines SpringLayoutTest () {
SpringLayout mySpringLayout = neues SpringLayout ();
JPanel myPanel = neues JPanel (mySpringLayout);
JButton helloButton = neues JButton („hallo“);
myPanel.add (helloButton);
mySpringLayout.putConstraint (SpringLayout.WEST, helloButton, 10, SpringLayout.WEST, myPanel);
mySpringLayout.putConstraint (SpringLayout.NORTH, helloButton, 10, SpringLayout.NORTH, myPanel);
this.add (myPanel);
}
/**
*
* @param s
*
allgemeine Staticlückenhauptleitung (Schnur s []) {
JFrame Rahmen = neues JFrame („SpringLayoutTest“);
SpringLayoutTest springLayoutTest = neues SpringLayoutTest ();
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
frame.setContentPane (springLayoutTest);
frame.setSize (300, 300);
frame.setLocation (300.300);
frame.setVisible (zutreffend);
}
} |