[英]Create dialog with no buttons
How do I remove the OK button when I use createDialog() 使用createDialog()时如何删除“确定”按钮
(I need to use createDialog because I need to set the location) (我需要使用createDialog,因为我需要设置位置)
JPanel myPanel = new JPanel();
myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.Y_AXIS));//new BorderLayout());
myPanel.setPreferredSize(new Dimension(400,400));
JTextField tf= new JTextField(50);
tf.setText("<HTML>Here is<br>my text");
myPanel.add(tf);
JOptionPane optionPane = new JOptionPane(myPanel,1,JOptionPane.DEFAULT_OPTION);
optionPane.setOptions(new Object[]{});
JDialog dialog = optionPane.createDialog(null, "Quick Help");
dialog.setLocation(10,10);
dialog.setAlwaysOnTop(dialog.isAlwaysOnTopSupported());
dialog.setVisible(true);
JOptionPane.showOptionDialog(null, "Hello world","No button?", JOptionPane.DEFAULT_OPTION,JOptionPane.INFORMATION_MESSAGE, null, new Object[]{}, null);
我想这应该有所帮助
JOptionPane pane = new JOptionPane("message", JOptionPane.PLAIN_MESSAGE, JOptionPane.PLAIN_MESSAGE);
JDialog myDialog= pane.createDialog(null, "New Topic");
myDialog.setLocation(1000, 100);
myDialog.setVisible(true);
In your case would be something like this: 在您的情况下将是这样的:
JOptionPane optionPane = new JOptionPane(this,1,JOptionPane.PLAIN_MESSAGE);
optionPane.setOptions(new Object[]{});
JDialog dialog = optionPane.createDialog(null, "Quick Help");
dialog.setLocation(1000,10);
dialog.setAlwaysOnTop(dialog.isAlwaysOnTopSupported());
dialog.setVisible(true);
Tested and working. 经过测试和工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.