Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #697
| From | printdude1968@gmail.com.remove-dii-this |
|---|---|
| Subject | JPanel will not show ( a |
| Message-ID | <1168994757.563328.324640@11g2000cwr.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| Date | 2011-04-27 15:29 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
So you can see my program in contxt
public class MainPanel extends JPanel implements ActionListener {
JFrame parent;
// JFrame addPrinterFrame, deletePrinterFrame, changePrinterFrame;
JButton addButton, changeButton, delButton;
JTextArea jtarea;
JScrollPane scrollPane;
JPanel buttonPanel, scrollPanePanel;
// View
MainPanel(JFrame parent) throws IOException {
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int screenHeight = screenSize.height;
int screenWidth = screenSize.width;
setSize(screenWidth / 2, screenHeight / 2);
setLocation(screenWidth / 4, screenHeight / 4);
// snipping a bunch of stuff
// Here is my action
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command.equals("Add Printer")) {
JPanel addPanel = createAddPanel();
addPanel.setVisible(true);
addPanel.setEnabled(true);
} else if (command.equals("Change Printer")) {
// JPanel addPanel = createChangePanel();
} else if (command.equals("Delete Printer")) {
//JPanel addPanel = createDeletePanel();
}
}
// more snipped stuff
// Here is the method it calls
private JPanel createAddPanel()
{
JPanel box = new JPanel();
JButton testButton = new JButton("test");
box.setLayout(new BoxLayout(box, BoxLayout.PAGE_AXIS));
JPanel pane = new JPanel(new BorderLayout());
pane.add(box, BorderLayout.NORTH);
pane.add(testButton, BorderLayout.SOUTH);
// I see this line in my eclipse console so I know that the code is
getting here!!
System.out.println("returning pane");
return pane;
}
// snipped stuff at the end
}
How do I make my panel appear? Do I need to add it to the main JFrame,
or is there a way to use the JPanel and have it a distinct window that
can be moved around and resized independantly of the main window....
ideas where I can look to figure this out? Will I find the answer in
the sun java swing tutorial or is there somewhere else I should be
looking?
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Next in thread | Find similar | Unroll thread
JPanel will not show ( a printdude1968@gmail.com.remove-dii-this - 2011-04-27 15:29 +0000
Re: JPanel will not show "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
Re: JPanel will not show printdude1968@gmail.com.remove-dii-this - 2011-04-27 15:29 +0000
Re: JPanel will not show "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
Re: JPanel will not show "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
One final question before printdude1968@gmail.com.remove-dii-this - 2011-04-27 15:29 +0000
Re: One final question be "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
Re: One final question be printdude1968@gmail.com.remove-dii-this - 2011-04-27 15:29 +0000
Re: One final question be "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
Re: JPanel will not show "Ian Wilson" <ian.wilson@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
csiph-web