I'm learning to program in java, I decided to create a form, created a JForm, added a button. When you run the project, the build is written successfully and everything, the form is not displayed. I looked at YouTube should be displayed normally, I can not understand what the problem is.

Code that is already present when creating a form.

public class NewJFrame extends javax.swing.JFrame { public NewJFrame() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jButton1.setText("jButton1"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(133, 133, 133) .addComponent(jButton1) .addContainerGap(194, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(210, Short.MAX_VALUE) .addComponent(jButton1) .addGap(67, 67, 67)) ); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new NewJFrame().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; // End of variables declaration } 
  • Build! = Launch - Sergey Gornostaev
  • And code sample is possible? - Bakhuss

1 answer 1

In NetBeans, select the "NewJFrame.java" file in the "Projects" pane. Press the right mouse button and select "Run File" from the context menu. You can also right-click anywhere in the open source and select "Run File".

Read the documentation for how to compile and execute the .java file. Look at the wiki: "Compiling and Running"

  • Thanks, now figured it out. - Alexey