Swing Problem. Panel not showing up
I am adding a JPanel to the content pane of my app, but its not showing up when i run the application. Its just a grey blank box with a title bar. I dont understand why, i think ive done it like this before and its worked. :mad:
import swing and awt...
declare public class called PokerGUI {...
declare JButtons and such....
// constructor
void PokerGUI() {
infoPanel = new JPanel();
infoPanel.setLayout( new BoxLayout(infoPanel, BoxLayout.Y_AXIS) );
// add the account name information
acntNameLabel = new JLabel("Account Name");
accountNameTF = new JTextField("Jon Anthony");
infoPanel.add( acntNameLabel );
infoPanel.add( accountNameTF );
// add the email address information
emailLabel = new JLabel("Email");
emailTF = new JTextField("MillionDollorMan@microsoft.net");
infoPanel.add( emailLabel );
infoPanel.add( emailTF );
// add the street address information
addressLabel = new JLabel("Address");
addressTF = new JTextField("142 Wood St, Sunburn CT, 09432");
infoPanel.add( addressLabel );
infoPanel.add( addressTF );
// add to contentPane
Container contentPane = getContentPane();
contentPane.setLayout( new FlowLayout() );
contentPane.add(infoPanel);
}
// main method
public static void main(String[] args) {
PokerGUI pk = new PokerGUI();
pk.setVisible(true);
pk.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
someone please tell me what i forgot lol, im coming back to java from a long C++ project, and i guess i forgot how to use swing. :/
[1720 byte] By [
ZeroFear] at [2007-11-11 7:55:06]

# 4 Re: Swing Problem. Panel not showing up
See wether this is want u want to do.
import javax.swing.*;
import java.awt.*;
public class Poker
{
public Component compo()
{
JPanel infoPanel = new JPanel();
infoPanel.setLayout( new BoxLayout(infoPanel, BoxLayout.Y_AXIS) );
// add the account name information
JLabel acntNameLabel = new JLabel("Account Name");
JTextField accountNameTF = new JTextField("Jon Anthony");
infoPanel.add( acntNameLabel );
infoPanel.add( accountNameTF );
// add the email address information
JLabel emailLabel = new JLabel("Email");
JTextField emailTF = new JTextField("MillionDollorMan@microsoft.net");
infoPanel.add( emailLabel );
infoPanel.add( emailTF );
// add the street address information
JLabel addressLabel = new JLabel("Address");
JTextField addressTF = new JTextField("142 Wood St, Sunburn CT, 09432");
infoPanel.add( addressLabel );
infoPanel.add( addressTF );
return infoPanel;
}
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame f = new JFrame("");
Poker pk = new Poker();
Component pg = pk.compo();
f.getContentPane().add(pg);
f.setSize(800,600);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}