jdialog

JDialog not showing minimize/close button

折月煮酒 提交于 2019-12-22 17:49:04
问题 When researching the problem, it seems most people are wanting to do the opposite (i.e remove the minimize/close button). I've had no success using the reoccurrent setUndecorated and setDefaultCloseOperation Here is my code: private class TestDialog extends JDialog { public static final String title_ = "Test Dialog"; public TestDialog(JFrame parent) { super(parent,title_,true); setMinimumSize(new Dimension(500,500)); setLocationRelativeTo(null); setUndecorated(false); setDefaultCloseOperation

JFileChooser vs JDialog vs FileDialog

我与影子孤独终老i 提交于 2019-12-22 10:59:50
问题 I need to know which of the 3 is best for me. My requirements are as follows in order of importance: Save and load files with ease. File type filter during file selection (not afterwards). Look and feel is exactly the same as the native OS L&F. If there is a dialog that I've not mentioned that would be more ideal, please let me know. 回答1: What is the rest of your application written in? If you used AWT you should use FileDialog. If you used Swing you should use JFileChooser. Both classes meet

Java return from a ShowOptionDialog from an inner JPanel

白昼怎懂夜的黑 提交于 2019-12-22 10:48:54
问题 I used JOptionPane.showOptionDialog(null, new MyPanel(), "Import", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[]{}, null); because I don't want the default buttons provided by the OptionDialog and I created my buttons inside the MyPanel extends JPanel So my problem is now how can I close that OptionDialog from inside the MyPanel fired by an ActionEvent ? I don't care the return value, as long as that dialog disappears. And I realize this might not be the best

Custom Cursor in a Swing JDialog

丶灬走出姿态 提交于 2019-12-22 08:26:31
问题 I have a Java Swing application, developed on Mac OS X 10.5 using Java 1.5. I'm trying to make a custom cursor appear when the user moves the mouse over some text in a dialog. The cursor never changes, though. When I don't use a JFrame instead of a JDialog, the cursor does change. But then I'll have to write all the dialog code myself. How can I get the cursor to appear? Here's the simplest code I could create to demonstrate the problem: import javax.swing.*; import java.awt.*; public class

Retrieve input entered in a JDialog

和自甴很熟 提交于 2019-12-22 06:36:01
问题 I extended JDialog to create a custom dialog where the user must fill some fields : How should I retrieve the data entered ? I came up with a solution that works. It mimics JOptionPane but the way I do it looks ugly to me because of the static fields involved... Here is roughly my code : public class FObjectDialog extends JDialog implements ActionListener { private static String name; private static String text; private JTextField fName; private JTextArea fText; private JButton bAdd; private

JDialog: How to disable the ESC key of my Modal dialog?

房东的猫 提交于 2019-12-21 22:34:18
问题 So there's a frame (main app). From here, I open a Modal JDialog and start a background thread working whilst displaying progress (log entries) in a table. This process is critical and should not be stoppable/hideable/closeable, thus why the dialog's close button is de-activated until everything's finished. However, the user can at any time tap the ESC key and my onCanceled() is called, thus calling this.dispose(). EDIT: I inherited this project and oversaw how deep the rabbit hole of

Stop newly created dialog from taking focus

假装没事ソ 提交于 2019-12-21 20:45:54
问题 I'm trying to have Java Swing dialog be created but I don't want to have the dialog to take focus away from whatever is currently focused. So for example, if you're editing a word doc and a different application creates a dialog, you should see the dialog but the word doc should remain in focus so that you can keep editing. I've tested the following code on Mac OSX and on Ubuntu 12.04. On Mac, the code creates dialogs that do not take the focus like I want. On Ubuntu, the dialogs take the

Java, how can I popup a dialog box as only an image?

强颜欢笑 提交于 2019-12-21 17:50:41
问题 I'm trying to find a way to replace all the contents of a JDialog to simply an image. It's for the about page of a project I'm working on and I want when the user clicks on the About section, an image to popup in the style of a JDialog(and to disappear when focus is lost). Example: http://www.tecmint.com/wp-content/uploads/2012/08/About-Skype.jpg There Skype displays only an image they've created as their "About" page. How can I make an "image dialog" in Java(swing)? 回答1: How can I make an

How to set a 3D border for a JDialog with rounded corners?

淺唱寂寞╮ 提交于 2019-12-21 17:41:01
问题 I could add a rounded corner border to my JDialog as in How to create a rounded title border in Java Swing. But it is still one color. I want to make the border looks like 3D. Here is how I tried. Graphics2D g2d = (Graphics2D) g; Color c1 = getBackground(); Color c2 = color1.darker(); int w = getWidth(); int h = getHeight(); GradientPaint gp = new GradientPaint( 0, 0, c1, 0, h, c2); g2d.setPaint(gp); g2d.fill3DRect(0,0, w, h,true); Then, no 3D look, but the border has been widen more with its

java expandable JDialog

会有一股神秘感。 提交于 2019-12-21 06:18:59
问题 For my application I have a JDialog which contains a JPanel with some basic JTextFields and JButtons . The idea is to have a button which expands the JDialog to reveal a second JPanel which contains some "advance" settings. I have achieved this with calling setPreferredSize() and pack() , but this isn't very elegant. An "elegant" solution would be to set the second Panel to be somehow null and therefore to get ignored by pack() when the toggle state is in "retracted". Sorry that I can't