package com.kitri.test;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextArea;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JTextField;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JScrollPane;
import java.awt.Color;
import javax.swing.border.TitledBorder;
import javax.swing.border.SoftBevelBorder;
import javax.swing.border.BevelBorder;
public class BaseBall extends JFrame {
private JPanel contentPane;
private JTextField tf;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
BaseBall frame = new BaseBall();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public BaseBall() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 539, 501);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel l = new JLabel("\uC785\uB825");
l.setHorizontalAlignment(SwingConstants.CENTER);
l.setBounds(12, 405, 57, 29);
contentPane.add(l);
tf = new JTextField();
tf.setBounds(81, 405, 316, 29);
contentPane.add(tf);
tf.setColumns(10);
JPanel panel = new JPanel();
panel.setBounds(409, 10, 102, 424);
contentPane.add(panel);
panel.setLayout(new GridLayout(5,1,0,10));
JButton newGame = new JButton(" \uC0C8\uAC8C\uC784");
newGame.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, new Color(255, 0, 0), Color.RED, Color.RED));
newGame.setForeground(Color.PINK);
newGame.setBackground(Color.CYAN);
newGame.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
panel.add(newGame);
JButton clear = new JButton("\uC9C0\uC6B0\uAE30");
panel.add(clear);
JButton dap = new JButton("\uC815\uB2F5");
panel.add(dap);
JButton fontC = new JButton("\uAE00\uC790\uC0C9");
panel.add(fontC);
JButton exit = new JButton("\uC885\uB8CC");
panel.add(exit);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(12, 10, 385, 385);
contentPane.add(scrollPane);
JTextArea ta = new JTextArea();
scrollPane.setViewportView(ta);
}
}
- X 버튼 누르면 창 닫히는 code
-TextArea에 자동으로 스크롤바 생성X
-> ScrollPane 위에 TextArea 생성해야함.
[출처] 빡쏘끼룩
'IT > JAVA' 카테고리의 다른 글
[Java] JCF(Java Collection Framework) - Collection / Map (0) | 2020.10.16 |
---|---|
[Java] Swing - CardLayout (창 넘어가기) (0) | 2020.10.14 |
[Java] WindowBuilder 설치&사용 (0) | 2020.10.08 |
[Java] Window 창 닫는 code (0) | 2020.10.06 |
[Java] 계산기 Code (0) | 2020.10.05 |