Results 1 to 4 of 4
Thread: [SOLVED] Not dispose my JPanel
- 04-07-2008, 10:00 AM #1
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
[SOLVED] Not dispose my JPanel
Hi all,
I've write some code to rendering some HTML code in a GUI. Here it is,
My question is that, on the click event mainPanel is not dispose. Only I want to dispose, not exist the system. I can exit from the system, not the dispose which I want to do.Java Code:private JEditorPane editor = new JEditorPane(); private JPanel mainPanel = new JPanel(); private JButton exitButton = new JButton(); private JDialog mainDialog = new JDialog(); private HTMLRendering(String htmlText){ editor.setEditorKit(new HTMLEditorKit()); editor.setContentType("text/html"); editor.setBorder(new BevelBorder(BevelBorder.LOWERED)); editor.setEditable(false); editor.setText(htmlText); // HTML code should be added here editor.addHyperlinkListener(this); // Exit button exitButton.setText("Exit"); exitButton.setSize(new Dimension(65, 25)); exitButton.setLocation(185, 215); exitButton.setBorder(new BevelBorder(BevelBorder.RAISED)); editor.add(exitButton); exitButton.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { if("Exit".equals(e.getActionCommand())){ // Newly added code segment System.out.println("Exit clicked"); mainDialog.dispose(); } } }); // Main panel mainPanel.setLayout(new BorderLayout()); mainPanel.setPreferredSize(new Dimension(260, 250)); mainPanel.add(editor); } private JPanel GetMainPanel(){ return mainPanel; } public void CreateAndShowGUI(String htmlText){ mainDialog.getContentPane().add(new HTMLRendering(htmlText).GetMainPanel()); mainDialog.setResizable(false); //mainDialog.setUndecorated(false); // Changed in future mainDialog.pack(); setWindowLocation(); mainDialog.setVisible(true); }
You guys have any idea why is that happened?
Thanks
- 04-07-2008, 02:20 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Oops, I refer the wrong object here. I've solved it well. Thanks for spending your time to read this post.
- 11-14-2010, 02:53 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 1
- Rep Power
- 0
dispoje JPanel....
Hi..
I am Also Interested to know how you disojed JPanel object without using System.exit(0);
I am using application and in that i am using jdatechooser program using JPanel
Once the date gets selected by user i want to dispoje the JPanel without exiting whole application....
PLEASE REPLAY:confused::confused::confused::confused:
- 11-14-2010, 03:02 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
This is a very old thread. So why don't you start a new thread, in the relevant sub-forum with a better explanation about your requirements. Please don't post non-related questions in a forum.
Similar Threads
-
refresh JPanel
By olesja in forum AWT / SwingReplies: 1Last Post: 04-16-2008, 03:58 PM -
Genarate JPanel
By Bill in forum AWT / SwingReplies: 6Last Post: 03-24-2008, 07:38 PM -
Problem with JPanel
By ibanez270dx in forum New To JavaReplies: 2Last Post: 11-09-2007, 05:04 PM -
JPanel Problems
By Riftwalker in forum AWT / SwingReplies: 6Last Post: 10-15-2007, 11:16 PM -
Draw on JPanel, Help
By carl in forum Java 2DReplies: 1Last Post: 07-31-2007, 06:56 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks