*/
package program_3;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
*
* @author Joe
*/
public class Program_3 extends JPanel {
JButton okButton;
GridBagConstraints c = new GridBagConstraints();
/**
*
*/
public Program_3 ()
{
setLayout(new GridBagLayout());
okButton = new JButton(" Ok ");
c.gridx = 0;
c.gridy = 0;
add(okButton,c);
}
public static void main(String[] args) {
JFrame Frame = new JFrame();
Program_3 Go = new Program_3();
Frame.setTitle("Program 3");
Frame.setSize(500,500);
Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Frame.setVisible(true);
Frame.add(Go);
}
}
Moving GUI Buttons
Page 1 of 11 Replies - 703 Views - Last Post: 18 September 2012 - 07:34 AM
#1
Moving GUI Buttons
Posted 17 September 2012 - 09:00 PM
I am trying to set up an intererface and want to movie this one ok button it really doesn't matter where to right now I just started learning. But i cannot seem to get it to move from the center of my frame no matter what. Any hints?
Replies To: Moving GUI Buttons
#2
Re: Moving GUI Buttons
Posted 18 September 2012 - 07:34 AM
Why use a GridBagLayout? If you don't care where it moves to, use FlowLayout (the default)
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|