@Carey Brown: Here is the code that I used and comes up with the centered components on the JPanel. Thanks for looking at it.
import javax.swing.*;
import java.awt.*;
public class FutureValueFrame extends JFrame {
public FutureValueFrame(){
initComponents();
}
private void initComponents(){
setTitle("future Value Calculator");
setSize(400, 400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationByPlatform(true);
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e){
System.out.println(e);
}
JPanel pane = new JPanel();
pane.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
add(pane);
JButton button = new JButton("Button1");
c.gridx = 0;
c.gridy = 0;
c.ipadx=0;
c.ipady = 0;
pane.add(button,c);
JButton button1 = new JButton("Button2");
c.gridx = 1;
c.gridy = 0;
c.ipadx=0;
c.ipady = 0;
pane.add(button1,c);
JButton button2 = new JButton("Button3");
c.gridx = 0;
c.gridy = 1;
c.ipadx = 0;
c.ipady = 0;
pane.add(button2,c);
setVisible(true);
}
public static void main(
String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run(){
JFrame frame = new FutureValueFrame();
}
});
}
}