I created a GUI (called ParameterUI) with the NetBeans GUI Builder, and now I want to instantiate it and display it. However, using
ParameterUI gui = new ParameterUI();
gui.setVisible(true);
does not cause a window to appear ... Testing shows that after these commands gui.isVisible () returns true, but gui.isValid () returns false. The call to gui.revalidate () also has no effect.
In the ParameterUI class, the constructor method is generated by Netbeans and simply
public class ParameterUI extends javax.swing.JPanel {
public ParameterUI() {
initComponents();
}
}
initComponents is just a list of where all jPanel, etc. will be placed.
The strange thing is that when I made a practical GUI with a tutorial at http://netbeans.org/kb/docs/java/gui-functionality.html , the GUI was set as the main class despite the absence of the main method, and the GUI appeared itself by oneself.
Unfortunately, I'm a newbie with GUIs (I use the constructor because I don't have time to learn how to make the right manual GUI), but can anyone tell me how to make my GUI visible? If necessary, I can provide more code ...
EDIT: I tried
JFrame window = new JFrame();
ParameterUI gui = new ParameterUI();
window.setContentPane(gui);
window.pack();
window.setVisible(true);
after reading a short tutorial on JFrames, but it doesn’t change anything ...
source
share