View Single Post
  #1 (permalink)  
Old 04-07-2008, 11:00 AM
Eranga's Avatar
Eranga Eranga is online now
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,054
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
[SOLVED] Not dispose my JPanel
Hi all,

I've write some code to rendering some HTML code in a GUI. Here it is,

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); }
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.

You guys have any idea why is that happened?

Thanks
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote
Sponsored Links