次のようなGUIインターフェースがある場合のように
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class login1 extends JFrame implements ActionListener{
JTextField username = new JTextField(15);
JTextField password = new JTextField(15);
JButton login1 = new JButton("login1");
JLabel status = new JLabel("Status:Not logged in");
public login1(){
super("login1:");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500,500);
GridBagLayout g = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
setLayout(g);
c.gridx = 0;
c.gridy = 0;
add(username,c);
c.gridx = 0;
c.gridy = 1;
add(password,c);
c.gridx = 0;
c.gridy = 2;
add(login1,c);
c.gridx = 0;
c.gridy = 3;
add(status,c);
login1.addActionListener(this);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == login1){
String user = username.getText();
String pass = password.getText();
}
}
public static void main(String[] args){
login1 l = new login1();
}
}
詳細を入力してボタンを使用して送信した後、パネルが 500,500 のフレームにあったように、jtextarea を使用してパネルの同じスペースにボタンで入力を送信できますか? jscrolllpane