我不太确定我在这里做错了什么。 该程序显示在线餐厅订购菜单。 我还没有写出事件处理程序,但我希望能够看到是什么即时通讯 正在为该计划工作。 我把add组件放在一个名为initComponents()的方法中 但是我似乎无法在主方法中调用它。
以下是其完整的代码:
import javax.swing.*;
import javax.swing.JFrame;
import java.awt.*;
public class JameSimpsonP7 extends javax.swing.JPanel {
public static void main(String[] args){
//Declare Food Objects
//Appitizers
Food artDuo = new Food("Artichoke Duo", 11.00, "A duo of fried artichoke hearts and cream cheese artichoke dip. Served with Ciabatta crisps. ");
Food shrimpCocktail = new Food("Jumbo Shrimp Cocktail", 12.00, "Large ice cold shrimp served in a martini glass served with our house marinara sauce ");
Food sliders = new Food("Kobe Sliders", 11.00, "Three bite sized kobe beef hamburgers served with french fries and house dill aioli.");
Food crabStack = new Food("Mango Crab Stack", 13.00, "A tower of mango, cream cheese, and freash crab served with ciabatta crisps.");
Food bisque = new Food("Tomato Bisque", 6.00, "A bowl of our famous house tomato bisque served with house made croutons.");
//Entree's
Food ribeye = new Food("Ribeye", 38.00, "Our succulent ribeye cut cooked to order. Served with a loaded baked potato and lobster mac and cheese.");
Food surfTurf = new Food("Surf and Turf", 42.00, "A combination of our house prime rib cut and lobster cooked to order. Served with yorkshire pudding.");
Food filet = new Food("Filet Mignon", 34.00, "Our house cut of filet mignon served with au jous and bacon and asperigus creamed corn.");
Food nyStrip = new Food("New York Strip", 35.00, "A 12 oz. New York Cut steak strip cooked to your specification. Served with yorkshire pudding.");
Food primeRib = new Food("Prime Rib", 29.00, "A 14 oz. cut of our prime rib. Cooked to your specification. Served with house potatoes.");
Food charShirmp = new Food("Charbroiled Shrimp", 28.00, "Five of our large house shrimp grilled and served with a sweet corn polenta and asperagus.");
Food halibut = new Food("Pan Seared Halibut", 34.00, "Freash caught halibut grilled and served with house vegetables and yorkshire pudding.");
Food scallops = new Food("Ancho Peanut Dusted Scallops", 34.00, "Scallops seasoned with ancho peanut dust, grilled, and served with bacon and asperagus creamed corn.");
Food romanChick = new Food("Roman Chicken", 24.00, "A grilled airline chicken breast served with a melange of house vegetables and sweet corn polenta.");
Food salmon = new Food("Cedar Plank Salmon", 30.00, "Salmon smoked with our Cedar wood and lemon zest, served with a light pasta with a lemon caper buerre blanc sauce.");
//Sides
Food lobMacChz = new Food("Lobster Mac and Cheese", 8.00, "House made macoroni and cheese served with 4 oz. of pure lobster meat.");
Food yorkPud = new Food("Yorkshire Pudding", 5.00, "A smoky pudding made with our house french bread and a smokey caper and pepper sauce.");
Food crmCorn = new Food("Bacon and Asperegus Creamed Corn", 6.00, "A melange of bacon and asperegus with our house made creamed corn.");
Food potatoes = new Food("Parmesean House Chive Potatoes", 5.00, "Our house mashed potatoes made with chives and parmesean cheese.");
//Desserts
Food chocCake = new Food("Chocolate Cake", 7.00, "An individual dark chocolate cake served with chocolate shavings and a chocolate fudge sauce.");
Food carrotCake = new Food("Carrot Cake", 7.00, "Carrot cake with a cream cheese frosting and a sugar carrot on top.");
Food strawShrtCak = new Food("Strawberry Short Cake", 7.00, "An American Classic! Shortbread soaked with strawberry sauce, topped with whipped cream, and stuffed with strawberries.");
Food tiramisu = new Food("Tiramisu", 6.00, "A classic espresso and kahlua soaked lady finger cake served with chocolate shavings.");
Food applePie = new Food("Stuffed Apple Pie", 5.00, "Our applle pie dumpling served with cinnamon dust and whipped cream.");
Food bananaCrm = new Food("Banana Cream Pie", 6.00, "An individual pie crust stuffed with banana slices, vanilla pudding, and topped with a mirangue cream.");
JameSimpsonP7 frame = new JameSimpsonP7();
frame.initComponents();
}
public JameSimpsonP7() {
initComponents();
}
@SuppressWarnings("unchecked")
private void initComponents() {
northPanel = new javax.swing.JPanel();
titleLabel = new javax.swing.JLabel();
phoneNumLabel = new javax.swing.JLabel();
westPanel = new javax.swing.JPanel();
appitizerLabel = new javax.swing.JLabel();
appitizerPane = new javax.swing.JScrollPane();
appList = new javax.swing.JList();
entreeLabel = new javax.swing.JLabel();
entreePane = new javax.swing.JScrollPane();
entreeList = new javax.swing.JList();
dessertLabel = new javax.swing.JLabel();
dessertPane = new javax.swing.JScrollPane();
dessertList = new javax.swing.JList();
southPanel = new javax.swing.JPanel();
addToOrderButton = new javax.swing.JButton();
eastPanel = new javax.swing.JPanel();
yourOrderLabel = new javax.swing.JLabel();
orderTextArea = new java.awt.TextArea();
totalPanel = new javax.swing.JPanel();
delivaryCheckBox = new javax.swing.JCheckBox();
carryoutCheckBox = new javax.swing.JCheckBox();
subTotalLabel = new javax.swing.JLabel();
taxRateLabel = new javax.swing.JLabel();
totalPriceLabel = new javax.swing.JLabel();
calcButton = new javax.swing.JButton();
centerPanel = new javax.swing.JPanel();
detailPanel = new javax.swing.JPanel();
detailLabel = new javax.swing.JLabel();
detailTextArea = new java.awt.TextArea();
specificationPanel = new javax.swing.JPanel();
pricePanel = new javax.swing.JPanel();
priceLabel = new javax.swing.JLabel();
specificationLabel = new javax.swing.JLabel();
specificationField = new java.awt.TextField();
sidesPanel = new javax.swing.JPanel();
sideLabel = new javax.swing.JLabel();
buttonPanel = new javax.swing.JPanel();
lobMacChzRadioButton = new javax.swing.JRadioButton();
yorkPudRadioButton = new javax.swing.JRadioButton();
baconAspRadioButton = new javax.swing.JRadioButton();
parmPotRadioButton = new javax.swing.JRadioButton();
setMaximumSize(new java.awt.Dimension(800, 600));
setMinimumSize(new java.awt.Dimension(800, 600));
setLayout(new java.awt.BorderLayout());
northPanel.setBackground(new java.awt.Color(250, 0, 50));
northPanel.setLayout(new java.awt.BorderLayout());
titleLabel.setFont(new java.awt.Font("Trajan Pro", 1, 24)); // NOI18N
titleLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
titleLabel.setText("James American Bistro");
northPanel.add(titleLabel, java.awt.BorderLayout.CENTER);
phoneNumLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
phoneNumLabel.setText("(405) 555-3213");
northPanel.add(phoneNumLabel, java.awt.BorderLayout.PAGE_END);
add(northPanel, java.awt.BorderLayout.PAGE_START);
westPanel.setBackground(new java.awt.Color(255, 0, 50));
westPanel.setMaximumSize(new java.awt.Dimension(260, 520));
westPanel.setMinimumSize(new java.awt.Dimension(260, 520));
westPanel.setPreferredSize(new java.awt.Dimension(260, 520));
westPanel.setLayout(new java.awt.GridLayout(6, 1, 1, 1));
appitizerLabel.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 1, 14));
appitizerLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
appitizerLabel.setText("Appitizers");
westPanel.add(appitizerLabel);
appitizerPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
appList.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Artichoke Duo", "Kobe Sliders", "Jumbo Shrimp Cocktail", "Mango Crab Stack", "Tomato Bisque", "" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
appList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
appList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
appListValueChanged(evt);
}
});
appitizerPane.setViewportView(appList);
westPanel.add(appitizerPane);
entreeLabel.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 1, 14));
entreeLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
entreeLabel.setText("Entrees");
westPanel.add(entreeLabel);
entreePane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
entreeList.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Ribeye", "Surf and Turf", "Filet Mignon", "New York Strip", "Prime Rib", "Charbroiled Shrimp", "Pan Seared Halibut", "Ancho Peanut Dusted Scallops", "Roman Chicken", "Cedar Plank Salmon", " ", " " };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
entreeList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
entreeList.setToolTipText("");
entreeList.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
entreeList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
entreeListValueChanged(evt);
}
});
entreePane.setViewportView(entreeList);
westPanel.add(entreePane);
dessertLabel.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 1, 14));
dessertLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
dessertLabel.setText("Deserts");
westPanel.add(dessertLabel);
dessertPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
dessertList.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Chocolate Cake", "Carrot Cake", "Strawberry Shortcake", "Tiramisu", "Stuffed Apple Pie", "Banana Cream Pie", " " };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
dessertList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
dessertList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
dessertListValueChanged(evt);
}
});
dessertPane.setViewportView(dessertList);
westPanel.add(dessertPane);
add(westPanel, java.awt.BorderLayout.LINE_START);
southPanel.setBackground(new java.awt.Color(255, 0, 55));
southPanel.setLayout(new java.awt.BorderLayout());
addToOrderButton.setText("Add to Order");
addToOrderButton.setToolTipText("");
addToOrderButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
addToOrderButton.setDoubleBuffered(true);
addToOrderButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
addToOrderButton.setMaximumSize(new java.awt.Dimension(10, 25));
addToOrderButton.setMinimumSize(new java.awt.Dimension(10, 25));
addToOrderButton.setPreferredSize(new java.awt.Dimension(10, 25));
addToOrderButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addToOrderButtonActionPerformed(evt);
}
});
southPanel.add(addToOrderButton, java.awt.BorderLayout.CENTER);
add(southPanel, java.awt.BorderLayout.PAGE_END);
eastPanel.setBackground(new java.awt.Color(255, 0, 50));
eastPanel.setMaximumSize(new java.awt.Dimension(260, 520));
eastPanel.setPreferredSize(new java.awt.Dimension(260, 520));
eastPanel.setLayout(new javax.swing.BoxLayout(eastPanel, javax.swing.BoxLayout.Y_AXIS));
yourOrderLabel.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 1, 14)); // NOI18N
yourOrderLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
yourOrderLabel.setLabelFor(orderTextArea);
yourOrderLabel.setText("Your Order");
eastPanel.add(yourOrderLabel);
orderTextArea.setEditable(false);
eastPanel.add(orderTextArea);
totalPanel.setBackground(new java.awt.Color(255, 0, 50));
totalPanel.setLayout(new java.awt.GridLayout(6, 1));
delivaryCheckBox.setBackground(new java.awt.Color(255, 0, 55));
delivaryCheckBox.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 1, 11));
delivaryCheckBox.setText("Delivary - $4.00");
delivaryCheckBox.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
delivaryCheckBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
delivaryCheckBoxActionPerformed(evt);
}
});
totalPanel.add(delivaryCheckBox);
carryoutCheckBox.setBackground(new java.awt.Color(240, 0, 55));
carryoutCheckBox.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 1, 11)); // NOI18N
carryoutCheckBox.setText("Carryout - Free!");
totalPanel.add(carryoutCheckBox);
subTotalLabel.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 0, 11));
subTotalLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
subTotalLabel.setText("Sub Total :");
totalPanel.add(subTotalLabel);
taxRateLabel.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 0, 11));
taxRateLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
taxRateLabel.setText("Tax Rate : ");
totalPanel.add(taxRateLabel);
totalPriceLabel.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 0, 11));
totalPriceLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
totalPriceLabel.setText("Total Price :");
totalPanel.add(totalPriceLabel);
calcButton.setBackground(new java.awt.Color(255, 0, 55));
calcButton.setText("Calculate");
calcButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
calcButtonActionPerformed(evt);
}
});
totalPanel.add(calcButton);
eastPanel.add(totalPanel);
add(eastPanel, java.awt.BorderLayout.LINE_END);
centerPanel.setBackground(new java.awt.Color(255, 255, 255));
centerPanel.setMaximumSize(new java.awt.Dimension(370, 520));
centerPanel.setPreferredSize(new java.awt.Dimension(370, 520));
centerPanel.setLayout(new java.awt.GridLayout(3, 1));
detailPanel.setBackground(new java.awt.Color(250, 250, 250));
detailPanel.setLayout(new java.awt.BorderLayout());
detailLabel.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 1, 11));
detailLabel.setText("Details");
detailPanel.add(detailLabel, java.awt.BorderLayout.LINE_START);
detailTextArea.setEditable(false);
detailPanel.add(detailTextArea, java.awt.BorderLayout.CENTER);
centerPanel.add(detailPanel);
specificationPanel.setBackground(new java.awt.Color(250, 250, 250));
specificationPanel.setLayout(new java.awt.GridLayout(4, 1));
pricePanel.setBackground(new java.awt.Color(250, 250, 250));
pricePanel.setLayout(new java.awt.BorderLayout());
priceLabel.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 1, 11));
priceLabel.setText("Price:");
pricePanel.add(priceLabel, java.awt.BorderLayout.LINE_START);
specificationPanel.add(pricePanel);
specificationLabel.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 1, 14));
specificationLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
specificationLabel.setText("Specifications");
specificationPanel.add(specificationLabel);
specificationField.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
specificationField.addTextListener(new java.awt.event.TextListener() {
public void textValueChanged(java.awt.event.TextEvent evt) {
specificationFieldTextValueChanged(evt);
}
});
specificationField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
specificationFieldActionPerformed(evt);
}
});
specificationPanel.add(specificationField);
specificationField.getAccessibleContext().setAccessibleDescription("");
centerPanel.add(specificationPanel);
sidesPanel.setBackground(new java.awt.Color(250, 250, 250));
sidesPanel.setLayout(new java.awt.BorderLayout());
sideLabel.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 1, 11));
sideLabel.setText("Add Sides");
sidesPanel.add(sideLabel, java.awt.BorderLayout.LINE_START);
buttonPanel.setBackground(new java.awt.Color(250, 250, 250));
lobMacChzRadioButton.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 0, 11));
lobMacChzRadioButton.setText("Lobster Mac and Cheese - $8.00");
lobMacChzRadioButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
lobMacChzRadioButtonActionPerformed(evt);
}
});
buttonPanel.add(lobMacChzRadioButton);
yorkPudRadioButton.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 0, 11));
yorkPudRadioButton.setText("Yorkshire Pudding - $5.00");
yorkPudRadioButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
yorkPudRadioButtonActionPerformed(evt);
}
});
buttonPanel.add(yorkPudRadioButton);
baconAspRadioButton.setFont(new java.awt.Font(
"Tw Cen MT Condensed Extra Bold", 0, 11));
baconAspRadioButton.setText(
"Bacon and Asparagus Cream Corn - $6.00");
baconAspRadioButton.addActionListener(
new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
baconAspRadioButtonActionPerformed(evt);
}
});
buttonPanel.add(baconAspRadioButton);
parmPotRadioButton.setFont(new java.awt.Font(
"Tw Cen MT Condensed Extra Bold", 0, 11));
parmPotRadioButton.setText("Parmesean House Chive Potatoes - $5.00");
parmPotRadioButton.addActionListener(
new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
parmPotRadioButtonActionPerformed(evt);
}
});
buttonPanel.add(parmPotRadioButton);
sidesPanel.add(buttonPanel, java.awt.BorderLayout.CENTER);
centerPanel.add(sidesPanel);
add(centerPanel, java.awt.BorderLayout.CENTER);
}
//declare variables used in handlers
final double TAX_RATE = 2.9;
public double orderTotal;
public double [] yourOrderPrices = new double [10];
public String [] yourOrderName = new String [10];
public String details;
public double price;
//Handler Functions
private void calcButtonActionPerformed(java.awt.event.ActionEvent evt) {
}
private void delivaryCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
orderTotal += 4.00;
}
private void lobMacChzRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
}
private void specificationFieldActionPerformed(java.awt.event.ActionEvent evt) {
}
private void yorkPudRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
}
private void appListValueChanged(javax.swing.event.ListSelectionEvent evt) {
detailTextArea.setText("TEST");
}
private void dessertListValueChanged(javax.swing.event.ListSelectionEvent evt) {
detailTextArea.setText("TEST");
}
private void specificationFieldTextValueChanged(java.awt.event.TextEvent evt) {
}
private void addToOrderButtonActionPerformed(java.awt.event.ActionEvent evt) {
}
private void baconAspRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
}
private void parmPotRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
}
private void entreeListValueChanged(javax.swing.event.ListSelectionEvent evt) {
}
// GUI Componenet Declaration
private javax.swing.JButton addToOrderButton;
private javax.swing.JList appList;
private javax.swing.JLabel appitizerLabel;
private javax.swing.JScrollPane appitizerPane;
private javax.swing.JRadioButton baconAspRadioButton;
private javax.swing.JPanel buttonPanel;
private javax.swing.JButton calcButton;
private javax.swing.JCheckBox carryoutCheckBox;
private javax.swing.JPanel centerPanel;
private javax.swing.JCheckBox delivaryCheckBox;
private javax.swing.JLabel dessertLabel;
private javax.swing.JList dessertList;
private javax.swing.JScrollPane dessertPane;
private javax.swing.JLabel detailLabel;
private javax.swing.JPanel detailPanel;
private java.awt.TextArea detailTextArea;
private javax.swing.JPanel eastPanel;
private javax.swing.JLabel entreeLabel;
private javax.swing.JList entreeList;
private javax.swing.JScrollPane entreePane;
private javax.swing.JRadioButton lobMacChzRadioButton;
private javax.swing.JPanel northPanel;
private java.awt.TextArea orderTextArea;
private javax.swing.JRadioButton parmPotRadioButton;
private javax.swing.JLabel phoneNumLabel;
private javax.swing.JLabel priceLabel;
private javax.swing.JPanel pricePanel;
private javax.swing.JLabel sideLabel;
private javax.swing.JPanel sidesPanel;
private javax.swing.JPanel southPanel;
private java.awt.TextField specificationField;
private javax.swing.JLabel specificationLabel;
private javax.swing.JPanel specificationPanel;
private javax.swing.JLabel subTotalLabel;
private javax.swing.JLabel taxRateLabel;
private javax.swing.JLabel titleLabel;
private javax.swing.JPanel totalPanel;
private javax.swing.JLabel totalPriceLabel;
private javax.swing.JPanel westPanel;
private javax.swing.JRadioButton yorkPudRadioButton;
private javax.swing.JLabel yourOrderLabel;
//Food class handles food objects
private static class Food {
private String name;
private double price;
private String details;
public Food(String name, double price, String details) {
this.setName(name);
this.setPrice(price);
this.setDetails(details);
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public double getPrice(){
return price;
}
public void setPrice(double price){
this.price = price;
}
public String getDetails(){
return details;
}
public void setDetails(String details){
this.details = details;
}
}
}
答案 0 :(得分:3)
您尚未创建任何可显示的窗口,例如JFrame
,其中可以显示派生的JPanel
JameSimpsonP7
。同时调用JameSimpsonP7
变量frame
可能会引起您的混淆。
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JameSimpsonP7 panel = new JameSimpsonP7();
JFrame frame = new JFrame();
frame.add(panel);
frame.pack();
frame.setVisible(true);
}
});
答案 1 :(得分:0)
您编写此代码的方式,调用frame.initComponents()
将是多余的。这是因为,在构造JameSimpsonP7
对象时,已经调用了initComponents方法,正如您在构造函数方法中看到的那样
public JameSimpsonP7() {
initComponents();
}
因为我不确定你得到了什么错误(问题中没有说明),这是我注意到的唯一修复。