Java Gui相关问题

来源:百度知道 编辑:UC知道 时间:2024/07/06 16:46:20
package Gui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class BmiGui3 implements ActionListener
{
public static void main(String[] args)
{
BmiGui3 gui=new BmiGui3();
}
private JFrame frame;
private JTextField heightField;
private JTextField weightField;
private JLabel bmiLabel;
private JButton button;

public BmiGui3()
{
heightField=new JTextField(5);
weightField=new JTextField(5);
bmiLabel=new JLabel("Type your height and weight");
button=new JButton("compute");

button.addActionListener(this);

JPanel north=new JPanel(new GridLayout(2,2));
north.add(new Label("Height"));
north.add(new JTextField());
north.add(new Label("Weight"));
north.add(new JTextField());

frame=new JFrame("BM

如果别人没有讲清楚问题,你都能够帮别人解决的话。。

那样才能算是一个比较合格的程序员。。。。

刚才看过了。。。也帮你改过了。。现在正确了。。你自己看下,。。。

错误的地方我已经注明了。。。

package Gui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class BmiGui3 implements ActionListener
{
public static void main(String[] args)
{
BmiGui3 gui=new BmiGui3();
}
private JFrame frame;
private JTextField heightField;
private JTextField weightField;
private JLabel bmiLabel;
private JButton button;

public BmiGui3()
{
heightField=new JTextField(5);
weightField=new JTextField(5);
bmiLabel=new JLabel("Type your height and weight");
button=new JButton("compute");

button.addActionListener(this);

JPanel north=new JPanel(new GridLayout(2,2));
north.add(new Label("Height"));
north.add(heightField)