How can I create a popup or popup window in a java app?

0

Good afternoon.

I'm doing a desktop app using the java swing library and I'm stuck with a popup problem.

In my app, there are some checkboxes that when you mark them you have to appear a popup with several options to choose from, spinners, textfields, labels, etc ...

The options that I found do not convince me, a jdialog is very limited for my needs (or I do not know how to customize it to max.). I have also tried with internal frame, but I can not find it when it appears, it appears with the necessary size (I have tested the .pack and all the options that I found on the internet), besides what I need is a little box that appears with what I need (As a tooltip but with more elements, not just text)

My last option and that seemed to work perfectly, was to make another JFrame with the position on the screen calculated by a function that believes, it seemed to be the perfect solution, but when you open the app in a main window and move it to another, the frame are still open in the previous window ....

You know some way you can do this more easily or at least some way that the JFrame appears on the same screen where the app is located

Thanks and best regards.

    
asked by Daniel F. L. González 05.12.2017 в 13:59
source

1 answer

0

You can create a JOptionPane that allows you to display the components you want, create a JPanel and add the components you are going to use:

 JPanel panel = new JPanel();
 panel.add(new JLabel("A:"));
 panel.add(new JTextField(12));
 panel.add(new JLabel("B:"));
 panel.add(new JTextField(12));
 JOptionPane.showConfirmDialog(forms, panel);

From here you can play with the options that you select in the JOption, you can put the listener to the components that you place within the panel or when you click on the options in the pop-up window to make decisions.

what you say about the checkbox is already at your discretion as you want to launch the pop-up window.

    
answered by 05.12.2017 / 15:27
source