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:
Printable View
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:
Here is a sample program to demonstrate the problem.
(Attached MDlg.java to zip)
Is this is a bug?
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: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.)
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();
}
});
}
}
Ahh, sorry. I see that you were talking about the JOptionPane not the initial window. It sometimes does act a little funny.
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?
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.
It seems that the attribute is carried from the parent. If you
MDlg.setResizable(false);
then neither have Maximize in their RC menus?
Looks like same one ... don't know why it marked closed.
http: // bugs<dot>sun<dot>com/view_bug<dot>do?bug_id=6601989