Я построил программу в автономном JFormDesigner, сохранил ее, и при запуске ничего не показывает.Что мне нужно отредактировать или напечатать, чтобы оно показывалось?Спасибо.
public class Something extends JFrame {
public Something() {
initComponents();
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// Generated using JFormDesigner Evaluation license - Vanja Banic
label1 = new JLabel();
button1 = new JButton();
button2 = new JButton();
//======== this ========
Container contentPane = getContentPane();
contentPane.setLayout(null);
//---- label1 ----
label1.setText("Something");
contentPane.add(label1);
label1.setBounds(0, 0, 585, 39);
//---- button1 ----
button1.setText("text");
contentPane.add(button1);
button1.setBounds(new Rectangle(new Point(95, 160), button1.getPreferredSize()));
//---- button2 ----
button2.setText("text");
contentPane.add(button2);
button2.setBounds(new Rectangle(new Point(285, 160), button2.getPreferredSize()));
{ // compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < contentPane.getComponentCount(); i++) {
Rectangle bounds = contentPane.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = contentPane.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
contentPane.setMinimumSize(preferredSize);
contentPane.setPreferredSize(preferredSize);
}
pack();
setLocationRelativeTo(getOwner());
}
// Generated using JFormDesigner Evaluation license - Vanja Banic
private JLabel label1;
private JButton button1;
private JButton button2;
// JFormDesigner - End of variables declaration //GEN-END:variables
}
Я знаю, что теперь ему не хватает main (), и я не уверен, что писать в нем, чтобы показать программу.Это пример, который будет показывать 1 метку и 2 кнопки.