davidc2
10-02-2006, 09:14 AM
I need to make this:
http://www.wtfhost.com//files/34/this2.jpg
look like this:
http://www.wtfhost.com//files/34/this.jpg
But I don't know how to...
Here's the code, can you give me a hand?
import java.awt.GridLayout;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JButton;
public class Align extends JFrame
{
private JTextField textField; // text field
private JTextField textField2;
private JCheckBox snapToGrid;
private JCheckBox showGrid;
private JLabel label1;
private JLabel label2;
private JButton button1;
private JButton button2;
private JButton button3;
private GridLayout gridLayout1;
private Container container;
private GridLayout gridLayout2;
private Container container2;
// CheckBoxFrame constructor adds JCheckBoxes to JFrame
public Align()
{
super( "Align" );
gridLayout1 = new GridLayout( 3, 3, 5, 5 );
container = getContentPane();
setLayout( gridLayout1 ); // set frame layout
snapToGrid = new JCheckBox( "Snap to Grid" );
showGrid = new JCheckBox( "Show Grid" );
add( snapToGrid );
label1 = new JLabel( "X:" );
add ( label1 );
// set up JTextField and set its font
textField = new JTextField( " ", 3 );
textField.setFont( new Font( "Serif", Font.PLAIN, 14 ) );
add( textField ); // add textField to JFrame
add( showGrid );
label2 = new JLabel( "Y:" );
add ( label2 );
// set up JTextField and set its font
textField2 = new JTextField( " ", 3 );
textField2.setFont( new Font( "Serif", Font.PLAIN, 14 ) );
add( textField2 ); // add textField to JFrame
button1 = new JButton( "OK" );
add (button1);
button2 = new JButton( "Cancel" );
add (button2);
button3 = new JButton( "Help" );
add (button3);
} // end constructor
} // end class
and
import javax.swing.JFrame;
public class Align_Test
{
public static void main( String args[] )
{
Align align = new Align();
align.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
align.setSize( 275, 140 ); // set frame size
align.setVisible( true ); // display frame
} // end main
} // end class
http://www.wtfhost.com//files/34/this2.jpg
look like this:
http://www.wtfhost.com//files/34/this.jpg
But I don't know how to...
Here's the code, can you give me a hand?
import java.awt.GridLayout;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JButton;
public class Align extends JFrame
{
private JTextField textField; // text field
private JTextField textField2;
private JCheckBox snapToGrid;
private JCheckBox showGrid;
private JLabel label1;
private JLabel label2;
private JButton button1;
private JButton button2;
private JButton button3;
private GridLayout gridLayout1;
private Container container;
private GridLayout gridLayout2;
private Container container2;
// CheckBoxFrame constructor adds JCheckBoxes to JFrame
public Align()
{
super( "Align" );
gridLayout1 = new GridLayout( 3, 3, 5, 5 );
container = getContentPane();
setLayout( gridLayout1 ); // set frame layout
snapToGrid = new JCheckBox( "Snap to Grid" );
showGrid = new JCheckBox( "Show Grid" );
add( snapToGrid );
label1 = new JLabel( "X:" );
add ( label1 );
// set up JTextField and set its font
textField = new JTextField( " ", 3 );
textField.setFont( new Font( "Serif", Font.PLAIN, 14 ) );
add( textField ); // add textField to JFrame
add( showGrid );
label2 = new JLabel( "Y:" );
add ( label2 );
// set up JTextField and set its font
textField2 = new JTextField( " ", 3 );
textField2.setFont( new Font( "Serif", Font.PLAIN, 14 ) );
add( textField2 ); // add textField to JFrame
button1 = new JButton( "OK" );
add (button1);
button2 = new JButton( "Cancel" );
add (button2);
button3 = new JButton( "Help" );
add (button3);
} // end constructor
} // end class
and
import javax.swing.JFrame;
public class Align_Test
{
public static void main( String args[] )
{
Align align = new Align();
align.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
align.setSize( 275, 140 ); // set frame size
align.setVisible( true ); // display frame
} // end main
} // end class