gpt4 book ai didi

java - netbeans 生成的代码中生成错误

转载 作者:行者123 更新时间:2023-12-01 11:26:14 26 4
gpt4 key购买 nike

到处寻找后,没有人遇到同样的问题。我需要编辑 netbeans 生成的代码,因为当我在设计 View 中删除一些 Swing 组件时,一个错误导致变量声明被删除,但在使用这些组件的 initComponents() 中,仍然存在抛出错误并且不允许我运行程序,代码如下:

    /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package controlpanel;

import java.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JTextArea;

/**
*
* @author Cam_2
*/
public class ControlPanel extends javax.swing.JFrame {

/**
* Creates new form ControlPanel
*/
public ControlPanel() {
initComponents();

}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
jButton1 = new javax.swing.JButton();
jInternalFrame1 = new javax.swing.JInternalFrame();
jLabel1 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(130, 0), new java.awt.Dimension(130, 0), new java.awt.Dimension(130, 32767));
jCheckBox1 = new javax.swing.JCheckBox();
jInternalFrame2 = new javax.swing.JInternalFrame();
redLight = new javax.swing.JCheckBox();
whiteLight = new javax.swing.JCheckBox();
blueLight = new javax.swing.JCheckBox();
greenLight = new javax.swing.JCheckBox();
yellowLight = new javax.swing.JCheckBox();
jInternalFrame3 = new javax.swing.JInternalFrame();
jButton3 = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jFormattedTextField1 = new javax.swing.JFormattedTextField();
jFormattedTextField2 = new javax.swing.JFormattedTextField();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox();
jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();

jList1.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane1.setViewportView(jList1);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setAlwaysOnTop(true);

jButton1.setText("Apply Changes");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jInternalFrame1.setTitle("Button Controller");
jInternalFrame1.setToolTipText("Controls the buttons that normally activate the lights.");
jInternalFrame1.setPreferredSize(new java.awt.Dimension(140, 160));
jInternalFrame1.setVisible(true);

jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Button Activation");
jLabel1.setToolTipText("Controls whether pressing a button will power the light or not");

jButton2.setText("Enable");
jButton2.setToolTipText("Controls whether pressing a button will power the light or not.");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel2.setText("Currently Disabled");
jLabel2.setToolTipText("Controls whether pressing a button will power the light or not");
jLabel2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

jCheckBox1.setText("Toggle Mode");
jCheckBox1.setToolTipText("Controls whether pressing a button will toggle the light on rather than only powering the light while the button is held down.");

javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
jInternalFrame1Layout.setHorizontalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 1, Short.MAX_VALUE))
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jCheckBox1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
jInternalFrame1Layout.setVerticalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jCheckBox1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

jInternalFrame2.setTitle("Light Controller");
jInternalFrame2.setToolTipText("Controls all the LED lights.");
jInternalFrame2.setPreferredSize(new java.awt.Dimension(140, 200));
jInternalFrame2.setVisible(true);

redLight.setText("Red Light");

whiteLight.setText("White Light");

blueLight.setText("Blue Light");

greenLight.setText("Green Light");

yellowLight.setText("Yellow Light");

javax.swing.GroupLayout jInternalFrame2Layout = new javax.swing.GroupLayout(jInternalFrame2.getContentPane());
jInternalFrame2.getContentPane().setLayout(jInternalFrame2Layout);
jInternalFrame2Layout.setHorizontalGroup(
jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(redLight)
.addComponent(yellowLight)
.addComponent(greenLight)
.addComponent(blueLight)
.addComponent(whiteLight))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jInternalFrame2Layout.setVerticalGroup(
jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(redLight)
.addGap(5, 5, 5)
.addComponent(yellowLight)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(greenLight)
.addGap(5, 5, 5)
.addComponent(blueLight)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(whiteLight)
.addContainerGap(12, Short.MAX_VALUE))
);

jInternalFrame3.setTitle("Screen Controller");
jInternalFrame3.setPreferredSize(new java.awt.Dimension(140, 313));
jInternalFrame3.setVisible(true);

jButton3.setText("Toggle On");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel3.setText("LED Char Screen");
jLabel3.setToolTipText("Control whether the LED matrix is on or off.");
jLabel3.setPreferredSize(new java.awt.Dimension(107, 16));

jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel4.setText("Currently Off");

jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel5.setText("Text To Display:");
jLabel5.setToolTipText("The text shown on the LED screen.");

jFormattedTextField1.setBackground(new java.awt.Color(204, 204, 255));
jFormattedTextField1.setToolTipText("Maximum characters is 20.");
jFormattedTextField1.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
jFormattedTextField1FocusLost(evt);
}
});

jFormattedTextField2.setBackground(new java.awt.Color(204, 204, 255));
jFormattedTextField2.setToolTipText("Maximum characters is 20.");
jFormattedTextField2.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
jFormattedTextField2FocusLost(evt);
}
});

jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel6.setText("Line 1:");

jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel7.setText("Line 2:");

jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

javax.swing.GroupLayout jInternalFrame3Layout = new javax.swing.GroupLayout(jInternalFrame3.getContentPane());
jInternalFrame3.getContentPane().setLayout(jInternalFrame3Layout);
jInternalFrame3Layout.setHorizontalGroup(
jInternalFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jInternalFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jInternalFrame3Layout.createSequentialGroup()
.addGroup(jInternalFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jInternalFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jFormattedTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE)
.addComponent(jFormattedTextField2)))
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jInternalFrame3Layout.setVerticalGroup(
jInternalFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jInternalFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jInternalFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jFormattedTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(489, 489, 489))
);

jList1.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane1.setViewportView(jList1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jInternalFrame3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE)
.addComponent(jInternalFrame2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE)
.addComponent(jInternalFrame1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 992, Short.MAX_VALUE)
.addComponent(jButton1)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGap(182, 182, 182)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jInternalFrame2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jInternalFrame3, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(86, 86, 86)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 287, Short.MAX_VALUE))))
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addContainerGap())
);

pack();
}// </editor-fold>

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
javax.swing.JButton src = (javax.swing.JButton) evt.getSource();
if(src.getText().equalsIgnoreCase("Enable")) {
jLabel2.setText("Currently Enabled");
src.setText("Disable");
} else {
jLabel2.setText("Currently Disabled");
src.setText("Enable");
}
}

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
javax.swing.JButton src = (javax.swing.JButton) evt.getSource();
if(src.getText().equalsIgnoreCase("Toggle On")) {
jLabel4.setText("Currently On");
src.setText("Toggle Off");
} else {
jLabel4.setText("Currently Off");
src.setText("Toggle On");
}
}

private void jFormattedTextField1FocusLost(java.awt.event.FocusEvent evt) {
JFormattedTextField src = jFormattedTextField1;
String prevText = src.getText();
if(prevText.length() > 20) {
src.setText(prevText.substring(0, 19));
final JDialog notice = new JDialog(cp, "Notice");
notice.setSize(new Dimension(400, 300));
notice.setLocationRelativeTo(null);
notice.setModal(true);
notice.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
JTextArea noticeLabel = new JTextArea("What you entered into Line 1 of the LED Screen exceeded the maximum 20 characters. The message has been shortened from \"" + prevText + "\" to \""+ src.getText() +".\"");
noticeLabel.setLineWrap(true);
noticeLabel.setWrapStyleWord(true);
noticeLabel.setEditable(false);
JButton okButton = new JButton("Okay");
okButton.setSize(new Dimension(300, 120));
noticeLabel.setSize(new Dimension(350, 60));
noticeLabel.setFont(new java.awt.Font("Times New Roman", java.awt.Font.BOLD, 18));
okButton.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
notice.setVisible(false);
}
});
notice.setLayout(new FlowLayout());
notice.add(noticeLabel);
notice.add(okButton);
notice.setVisible(true);
}
}

private void jFormattedTextField2FocusLost(java.awt.event.FocusEvent evt) {
JFormattedTextField src = jFormattedTextField2;
String prevText = src.getText();
if(prevText.length() > 20) {
src.setText(prevText.substring(0, 19));
final JDialog notice = new JDialog(cp, "Notice");
notice.setSize(new Dimension(400, 300));
notice.setLocationRelativeTo(null);
notice.setModal(true);
notice.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
JTextArea noticeLabel = new JTextArea("What you entered into Line 2 of the LED Screen exceeded the maximum 20 characters. The message has been shortened from \"" + prevText + "\" to \""+ src.getText() +".\"");
noticeLabel.setLineWrap(true);
noticeLabel.setWrapStyleWord(true);
noticeLabel.setEditable(false);
JButton okButton = new JButton("Okay");
okButton.setSize(new Dimension(300, 120));
noticeLabel.setSize(new Dimension(350, 60));
noticeLabel.setFont(new java.awt.Font("Times New Roman", java.awt.Font.BOLD, 18));
okButton.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
notice.setVisible(false);
}
});
notice.setLayout(new FlowLayout());
notice.add(noticeLabel);
notice.add(okButton);
notice.setVisible(true);
}
}


// Variables declaration - do not modify
private javax.swing.JCheckBox blueLight;
private javax.swing.Box.Filler filler1;
private javax.swing.JCheckBox greenLight;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JFormattedTextField jFormattedTextField1;
private javax.swing.JFormattedTextField jFormattedTextField2;
private javax.swing.JInternalFrame jInternalFrame1;
private javax.swing.JInternalFrame jInternalFrame2;
private javax.swing.JInternalFrame jInternalFrame3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JCheckBox redLight;
private javax.swing.JCheckBox whiteLight;
private javax.swing.JCheckBox yellowLight;
// End of variables declaration

private static ControlPanel cp;

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Metal".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ControlPanel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ControlPanel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ControlPanel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ControlPanel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
cp = new ControlPanel();
cp.setVisible(true);
cp.setLocationRelativeTo(null);
}
});
}



}

我如何编辑生成的代码?

最佳答案

如果问题仍然存在,您必须在任何文本编辑器中打开 JFrame 类:记事本、Notepad++、写字板等,然后删除错误。然后返回 netbeans 并重新加载您的项目。

要删除表单项,请使用导航器窗口 (Ctl+7) 并安全地删除它们。

关于java - netbeans 生成的代码中生成错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30787091/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com