Results 1 to 8 of 8
  1. #1
    playwin2 is offline Member
    Join Date
    Aug 2008
    Posts
    58
    Rep Power
    0

    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? :confused:

  2. #2
    playwin2 is offline Member
    Join Date
    Aug 2008
    Posts
    58
    Rep Power
    0

    Default

    Here is a sample program to demonstrate the problem.
    (Attached MDlg.java to zip)

    Is this is a bug?
    Attached Files Attached Files

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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:
    Java 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();
          }
        });
      }
    }

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Ahh, sorry. I see that you were talking about the JOptionPane not the initial window. It sometimes does act a little funny.

  5. #5
    playwin2 is offline Member
    Join Date
    Aug 2008
    Posts
    58
    Rep Power
    0

    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 03:17 AM.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    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.

  7. #7
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,560
    Rep Power
    25

    Default

    It seems that the attribute is carried from the parent. If you
    MDlg.setResizable(false);
    then neither have Maximize in their RC menus?

  8. #8
    playwin2 is offline Member
    Join Date
    Aug 2008
    Posts
    58
    Rep Power
    0

    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

Similar Threads

  1. Fill a menu dynamically when menu is shown
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-07-2008, 04:47 PM
  2. How to use SWT menu and menu event
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-07-2008, 04:46 PM
  3. React to menu action and checkbox menu
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 07:50 PM
  4. Replies: 7
    Last Post: 05-09-2008, 07:54 AM
  5. Replies: 0
    Last Post: 12-06-2007, 06:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •