Home > Back-end >  java
java

Time:11-20

I will actionlistener to write in a class, then wants to achieve in another class of bn array monitoring, how should I new the class, a great god consult,
The HTML code is as follows, the purpose is to achieve the bn monitoring





Public class ApiHomework extends JFrame {

Public String JBN []={" MC ", "MR", "MS", "M +", "M -", "please", "CE", "C", "+", "quality", "7", "eight" and "9", "/", "%", "4", "5", "6", "*", "1/x", "1", "2", "3", "-", "=", "0", ""," + "};
JButton [] bn=new JButton [JBN length];
String STR="";
Public JTextArea jt.

Public ApiHomework () {
Super (" computer ");
Enclosing setBounds (100, 100, 390, 450);
Enclosing setDefaultCloseOperation (EXIT_ON_CLOSE);

JMenuBar menubar=new JMenuBar ();
Enclosing setJMenuBar (menubar);
JMenu menu=new JMenu (" check (V) ");
JMenu menu1=new JMenu (" edit (E) ");
JMenu menu2=new JMenu (" help (H) ");
Menubar. Add (menu);
Menubar. Add (menu1);
Menubar. Add (menu2);
JTextArea jt=new JTextArea (" ");
Jt. SetBounds (30, 5, 305, 50);
Jt. SetEditable (false);


JPanel jp=new JPanel ();
Jp. SetLayout (null);



for(int i=0; i{
Bn [I]=new JButton (JBN [I]);
//bn=new MyActionListener (bn, jt);

}
New MyActionListener (bn, jt);



Bn [0]. SetBounds (5, 70, 60, 40).
Bn [1]. The setBounds (80, 70, 60, 40).
Bn [2]. SetBounds (155, 70, 60, 40).
Bn [3]. SetBounds (230, 70, 60, 40).
Bn [4]. SetBounds (305, 70, 60, 40).
Bn [5]. SetBounds (5, 125, 60, 40).
Bn [6]. SetBounds (80, 125, 60, 40).
Bn [7]. SetBounds (155, 125, 60, 40).
Bn [8]. SetBounds (230, 125, 60, 40).
Bn [9]. SetBounds (305, 125, 60, 40).
Bn [10]. SetBounds (5, 180, 60, 40).
Bn [11]. SetBounds (80, 180, 60, 40).
Bn [12]. SetBounds (155, 180, 60, 40).
Bn [13]. SetBounds (230, 180, 60, 40).
Bn. [14] setBounds (305, 180, 60, 40).
Bn [15]. SetBounds (5, 235, 60, 40).
Bn. [16] setBounds (80, 235, 60, 40).
Bn. [17] setBounds (155, 235, 60, 40).
Bn [18]. SetBounds (230, 235, 60, 40).
Bn. [19] setBounds (305, 235, 60, 40).
Bn [20]. SetBounds (5, 290, 60, 40).
Bn [21]. SetBounds (80, 290, 60, 40).
Bn [22]. SetBounds (155, 290, 60, 40).
Bn [23]. SetBounds (230, 290, 60, 40).
Bn. [24] setBounds (305, 290, 60, 95);
Bn [25]. SetBounds (5, 345, 135, 40).
Bn [26]. SetBounds (155, 345, 60, 40).
Bn [27]. SetBounds (230, 345, 60, 40).

For (int i1=0; I1 & lt; Bn. Length; I1 + +)
{
Jp. Add (bn (i1));

}

Jp. Add (jt);
This. The add (jp);
Enclosing setResizable (false);
this.setVisible(true);

}

}

















Public class MyActionListener implements ActionListener {
JButton BTN.
JButton [] bnte;
JTextArea jte;
Public MyActionListener (JButton BTN, JTextArea jte) {
Enclosing BTN=BTN;
Enclosing jte=jte;
}

Public MyActionListener (JButton [] bn, JTextArea jt) {
//TODO Auto - generated constructor stub
}

@ Override
Public void actionPerformed (an ActionEvent e) {
for(int i=0; i<27. I++)
If (um participant etSource ()==BTN) {
String STR=BTN. GetText ();
Jte. Append (STR);
}
}

}