티스토리 뷰
package gui;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class Testing extends JFrame{
//get 현재상태값
//is boolean return
//한줄 텍스트필드, 여러줄 텍스트에어리어
JFrame internalframe;
JLayeredPane mainPane;
JButton btLogin = new JButton("LOGIN");
JTextField txID = new JTextField();
JPasswordField txPass = new JPasswordField();
JLabel lbID = new JLabel("ID");
JLabel lbPass = new JLabel("Password");
JLabel lbMe = new JLabel("j0n9m1n1.com");
JButton btOK = new JButton("OK");
JButton btCancel = new JButton("Cancel");
JLabel lbLog = new JLabel("Message Log");
JTextArea taLog = new JTextArea("");
MyActionListener myBTListener = new MyActionListener();
public Testing() {
super("Main Frame");
setSize(600, 500);
Container c = getContentPane();
mainPane = new JLayeredPane();
c.setLayout(new BorderLayout());
mainPane.setLayout(new BorderLayout());;
c.add(btLogin, BorderLayout.SOUTH);
c.add(mainPane, BorderLayout.CENTER);
mainPane.add(lbLog, BorderLayout.NORTH);
mainPane.add(taLog, BorderLayout.CENTER);
taLog.setEditable(false);
internalframe = new JFrame("Login Frame");
Container ic = internalframe.getContentPane();
ic.setLayout(new GridLayout(4,2));
ic.add(lbID);
ic.add(txID);
ic.add(lbPass);
ic.add(txPass);
ic.add(btOK);
ic.add(btCancel);
ic.add(lbMe);
btLogin.addActionListener(myBTListener);
btOK.addActionListener(myBTListener);
btCancel.addActionListener(myBTListener);
setVisible(true);
taLog.append("> System is initiated. \n");
}
public static void main(String[] args) {
Testing a = new Testing();
}
class MyActionListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
JButton b = (JButton)e.getSource();
if(b.getText().equals("LOGIN")) {
if(internalframe.isVisible()==false) {
internalframe.setBounds(150,100, 250,140);
internalframe.setVisible(true);;
}
}
else if (b.getText().equals("OK")) {
internalframe.setVisible(false);
btLogin.setText("EXIT");
String enteredID = txID.getText();
taLog.append("> " + enteredID + " is entered this room. \n");
taLog.setEditable(true);
}
else if (b.getText().equals("Cancel")) {
internalframe.setVisible(false);
}
else if (b.getText().equals("EXIT")) {
System.exit(0);
}
}
}
}
'Java > for Class, Project' 카테고리의 다른 글
Java TCP 네트워킹 (tcp networking) 노트 (이것이 자바다2) (0) | 2017.11.01 |
---|---|
JAVA 자바 채팅 인터페이스, 로그인(Chat interface, login only, JFrame, WindowBuilder) (0) | 2017.10.28 |
Java Swing Frame Example 스윙 프레임 예제 (0) | 2017.10.11 |
자바 스레드 동기화 예제 Java Thread synchronize example (0) | 2017.09.29 |
JAVA java9 eclipse(이클립스) NoclassdefFoundError 관련 실행불가 문제 해결 (0) | 2017.09.25 |
티스토리 방명록
- Total
- Today
- Yesterday
Contact: j0n9m1n1@gmail.com