-1

I have created one checkbox this way:

JCheckbox field = new JCheckBox("EDEX:", true);.

I was add this to Jpanel and layout is FormLayout using CellConstraints xy positions.

but it is not displayed EDEX text after checkbox.

this is code:

panel.add(field , cc.xy(5, 3));

please help me

Thank You

Heisenbug
  • 38,762
  • 28
  • 132
  • 190
java2world
  • 219
  • 1
  • 2
  • 4

1 Answers1

2

This works fine:

enter image description here

import java.awt.EventQueue;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;

import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Example {

    public Example() {
        FormLayout layout =
            new FormLayout( "left:pref, 15px, center:pref, 15px, right:pref, 15px, fill:pref, 15px, pref",
                            "pref, 12px, pref, 4px, pref, 4px, pref, 4px, pref, 4px, pref" );

        JPanel panel = new JPanel( layout );
        CellConstraints cc = new CellConstraints();

        JCheckBox field = new JCheckBox( "EDEX:", true );
        panel.add( field, cc.xy( 5, 3 ) );

        JFrame f = new JFrame();
        f.setBounds( 10, 10, 100, 100 );
        f.setDefaultCloseOperation( 3 );
        f.getContentPane().add( panel );
        f.setVisible( true );
    }

    public static void main( String[] args ) {
        EventQueue.invokeLater( new Runnable() {
            @Override
            public void run() {
                new Example();
            }
        } );
    }

}
oliholz
  • 7,447
  • 2
  • 43
  • 82
  • Nice screenshot, but to make a *great* screenshot, check out the tips on [How do I create screenshots?](http://meta.stackexchange.com/questions/99734/how-do-i-create-a-screenshot-to-illustrate-a-post). – Andrew Thompson Sep 02 '11 at 15:39