1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
import javax.swing.JLabel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Group;
import javax.swing.GroupLayout.SequentialGroup;
public class MyFrame extends javax.swing.JFrame {
GroupLayout layout;
Group layoutHorizontal, layoutVertical;
SequentialGroup layoutHorizontalSequential, layoutVerticalSequential;
/** Creates new form MyFrame */
public MyFrame()
{
initComponents();
JLabel l = new JLabel("Salut");
l.setVisible(true);
layoutHorizontalSequential.addComponent(l);
layoutVerticalSequential.addComponent(l);
validate();
repaint();
pack();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Frame");
layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layoutHorizontalSequential = layout.createSequentialGroup()
.addGap(116, 116, 116)
.addComponent(jLabel1)
.addContainerGap(254, Short.MAX_VALUE);
layoutHorizontal = layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layoutHorizontalSequential);
layoutVerticalSequential = layout.createSequentialGroup()
.addContainerGap(146, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(140, 140, 140);
layoutVertical = layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.TRAILING, layoutVerticalSequential
);
layout.setHorizontalGroup(layoutHorizontal);
layout.setVerticalGroup(layoutVertical);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new MyFrame().setVisible(true);
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
// End of variables declaration
} |
Partager