Why is my transformation only one of an ELSE statement is useful?

zhaozj2021-02-16  120

Why do you have a buffama?

Only ELSE is really doing I don't understand, I will help me debug, tell me there.

Import javax.swing. *;

Import java.awt. *;

Import java.awt.event. *;

Public Class Tfhlayout Extends Jframe Implements ActionListener {

Public JButton Button1, Button2, Button3, Button4

Jtextarea area = new Jtextarea (14, 28);

Public void tfhlayout () {

Jframe frame;

JPANel P1, P2;

P1 = new jpanel ();

P2 = new jpanel ();

Frame = New Jframe ("TFH Document");

P1.setLayout (New BoxLayout (P1, BoxLayout.y_AXIS);

Container con = frame.getContentPane ();

Con.SetLayout (New BorderLayout (1, 1));

JButton Button1 = New JButton ("Tanfang said");

JButton Button2 = New JButton ("Long Minjie");

JButton Button3 = New JButton ("Wu Mingki");

JButton Button4 = New JButton ("Tan Wenjuan said");

Button1.addactionListener (this);

Button2.addactionListener (this);

Button3.addactionListener (this);

Button4.addactionListener (this);

P1.Add (Button1);

P1.Add (Button2);

P1.Add (Button3);

P1.Add (Button4);

C. ADD ("West", P1);

P2.Add (Area);

C. ADD (P2);

Frame.setsize (400, 300);

Frame.show ();

frame.addwindowlistener (new windowadapter () {

Public void windowClosing (WindowEvent E) {

System.exit (0);}});

}

Public Void ActionPerformed (ActionEvent E) {

IF (E.getsource () == Button4)

{JOPANE.SHOWMESSAGEDIALOG (NULL, "Hello", "Hello", JOPTIONPANE.INFORMATION_MESSAGE);

Area.setText ("Button1");

}

Else if (E.getsource () == Button2)

Area.setText ("Button2");

Else if (E.Getsource () == Button3)

Area.setText ("Button3");

Else IF (E.GetSource () == Button4)

{JOPANE.SHOWMESSAGEDIALOG (NULL, "Button4", "Hello", JOPANE.INFORMATION_MESSAGE

Area.Settext ("Button4");

Else Area.Settext ("null");}

Public static void main (String [] args) {

TFHLAYOUT APP = New TFHLAYOUT ();

app.tfhlayout ();

}

}

转载请注明原文地址:https://www.9cbs.com/read-9001.html

New Post(0)