Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-07-2008, 01:16 AM
Member
 
Join Date: Aug 2008
Posts: 58
Rep Power: 0
playwin2 is on a distinguished road
Red face Not-resizable (J)dialog showing Maximize Menu !!!
Hello,

Why not-resizable JOptionPane/JDialog's [setResizable(false)] shows "Maximize" in the System Menu?
(i.e. the menu you get when you right click on the title bar of the dialog.)

How should I stop this?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 09-07-2008, 03:58 AM
Member
 
Join Date: Aug 2008
Posts: 58
Rep Power: 0
playwin2 is on a distinguished road
Default
Here is a sample program to demonstrate the problem.
(Attached MDlg.java to zip)

Is this is a bug?
Attached Files:
File Type: zip MDlg.zip (743 Bytes, 4 views)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 09-07-2008, 04:07 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,391
Rep Power: 8
Fubarable is on a distinguished road
Default
Quote:
Why not-resizable JOptionPane/JDialog's [setResizable(false)] shows "Maximize" in the System Menu?
(i.e. the menu you get when you right click on the title bar of the dialog.)
You're not showing a JDialog but rather a JFrame. If you want your window to act like a dialog, then make it a dialog:
Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class MDlg
{
  private JPanel mainPanel = new JPanel();
  private JButton btnPop = new JButton("MsgBox");

  public MDlg()
  {
    mainPanel.setLayout(new FlowLayout());

    String txt = "<html>(1) First Right Click on my TitleBar.<br><br>"
        + "(2) Choose Maximize Menu.<br><br>"
        + "(3) Click on the Restore button on my TitleBar.<br><br>"
        + "(4) NOW - Click on the \"MsgBox\" Button.<br><br>"
        + "(5) Right Click on the TitleBar of the MessageBox.<br><br>"
        + "(6) Did you see the \"Maximize\" menu? Click on it!</html>";
    mainPanel.add(new JLabel(txt));
    mainPanel.add(btnPop);

    btnPop.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        JOptionPane.showMessageDialog(mainPanel, "Hello World!",
            "Right Click on HERE", JOptionPane.INFORMATION_MESSAGE);
      }
    });

    mainPanel.setPreferredSize(new Dimension(400, 300));
  }
  
  public JPanel getMainPanel()
  {
    return mainPanel;
  }

  public static void main(String args[])
  {
    EventQueue.invokeLater(new Runnable()
    {
      public void run()
      {
        //new MDlg().setVisible(true);
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        
        JDialog dialog = new JDialog(frame, "Test -- Right Click on HERE", true);
        dialog.getContentPane().add(new MDlg().getMainPanel());
        dialog.pack();
        dialog.setLocationRelativeTo(null);
        dialog.setVisible(true);
        
        frame.dispose();
      }
    });
  }
}
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 09-07-2008, 04:13 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,391
Rep Power: 8
Fubarable is on a distinguished road
Default
Ahh, sorry. I see that you were talking about the JOptionPane not the initial window. It sometimes does act a little funny.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 09-07-2008, 04:14 AM
Member
 
Join Date: Aug 2008
Posts: 58
Rep Power: 0
playwin2 is on a distinguished road
Default
Hello,

I don't get it, I'm talking about the JOptionPane's behavior in the above example, same thing happens in case of Dialog
For ex if I do : class myClass extends JDialog...etc.

btw: sorry for the main(frame) class name MDlg, are you reffering to it?

Edit: oops!

btw so you do thing it's a kind of a bug? no?

Last edited by playwin2; 09-07-2008 at 04:17 AM.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 09-07-2008, 04:25 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,391
Rep Power: 8
Fubarable is on a distinguished road
Default
It's sure smelling like a Java bug, but I for one am very reluctant to call it as I just don't feel qualified to make that call or even accusation. I just searched the Java bug database and found what looks to be a related bug, but on closer examination it's not quite the same as it's for a much earlier version of Java and discusses a different problem:
Bug ID: 4219710 JOptionPane resizability

Perhaps the best thing to do is to submit a possible bug report to this database and see what falls out.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 09-07-2008, 03:07 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
It seems that the attribute is carried from the parent. If you
MDlg.setResizable(false);
then neither have Maximize in their RC menus?
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 09-08-2008, 01:51 AM
Member
 
Join Date: Aug 2008
Posts: 58
Rep Power: 0
playwin2 is on a distinguished road
Default
Looks like same one ... don't know why it marked closed.

http: // bugs<dot>sun<dot>com/view_bug<dot>do?bug_id=6601989
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill a menu dynamically when menu is shown Java Tip SWT 0 07-07-2008 05:47 PM
How to use SWT menu and menu event Java Tip SWT 0 07-07-2008 05:46 PM
React to menu action and checkbox menu Java Tip javax.swing 0 06-27-2008 08:50 PM
how to create Popup Menu with Sub Menu while right-clicking the JTree Node?? Kabiraa AWT / Swing 7 05-09-2008 08:54 AM
File Save not showing FileSAVE dialog box , getting displayed in browser deepdba Java Servlet 0 12-06-2007 07:10 PM


All times are GMT +2. The time now is 06:38 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org