
February 27th, 2013, 02:08 PM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 7
Time spent in forums: 50 m 47 sec
Reputation Power: 0
|
|
Here is my source code:
Code:
public class PhoneListGUI implements ActionListener{
JFrame guiFrame;
JPanel buttonPanel;
JButton button;
JList list;
public PhoneListGUI() {
guiFrame = new JFrame();
//make sure the program exits when the frame closes
guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
guiFrame.setTitle("Phone List");
guiFrame.setSize(300,300);
//This will center the JFrame in the middle of the screen
guiFrame.setLocationRelativeTo(null);
Container contentPane = guiFrame.getContentPane();
contentPane.setLayout(new BorderLayout());
JPanel buttonPanel = new JPanel();
JButton newButton = new JButton("New Number");
buttonPanel.add(newButton);
JButton delButton = new JButton("Delete Number");
buttonPanel.add(delButton);
JButton exitButton = new JButton("Exit");
buttonPanel.add(exitButton);
list = new JList<>();
contentPane.add(buttonPanel, BorderLayout.WEST);
contentPane.add(list, BorderLayout.EAST);
guiFrame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}
It seems the JList is not really displayed... I have a main where I create an instance of PhoneListGUI.
|