简介
AWT
介绍
组件和容器
Frame
import java. awt. * ;
public class TestFrame {
public static void main ( String [ ] args) {
Frame frame = new Frame ( "我的第一个图形界面窗口" ) ;
frame. setVisible ( true ) ;
frame. setSize ( 300 , 100 ) ;
frame. setBackground ( new Color ( 11 , 199 , 239 , 255 ) ) ;
frame. setLocation ( 100 , 100 ) ;
frame. setResizable ( false ) ;
}
}
import java. awt. * ;
public class TestFrame2 {
public static void main ( String [ ] args) {
new myFrame ( 100 , 100 , 200 , 200 , Color . BLUE) ;
new myFrame ( 500 , 500 , 100 , 100 , Color . GREEN) ;
}
}
class myFrame extends Frame {
static int id= 0 ;
public myFrame ( int x, int y, int w, int h, Color color) {
super ( "myFrame" + ( ++ id) ) ;
setBounds ( x, y, w, h) ;
setBackground ( color) ;
setVisible ( true ) ;
}
}
布局管理器
流布局
import java. awt. * ;
import java. awt. event. WindowAdapter ;
import java. awt. event. WindowEvent ;
public class TestFlowLayout {
public static void main ( String [ ] args) {
Frame frame = new Frame ( "FlowLayout" ) ;
frame. setBounds ( 200 , 200 , 500 , 500 ) ;
frame. setVisible ( true ) ;
frame. setLayout ( new FlowLayout ( ) ) ;
Button button1 = new Button ( "button1" ) ;
Button button2 = new Button ( "button2" ) ;
Button button3 = new Button ( "button3" ) ;
frame. add ( button1) ;
frame. add ( button2) ;
frame. add ( button3) ;
frame. addWindowListener ( new WindowAdapter ( ) {
@Override
public void windowClosing ( WindowEvent e) {
System . exit ( 0 ) ;
}
} ) ;
}
}
边界布局
import java. awt. * ;
import java. awt. event. WindowAdapter ;
import java. awt. event. WindowEvent ;
public class TestBorderLayout {
public static void main ( String [ ] args) {
Frame frame = new Frame ( "TestBorderLayout" ) ;
frame. setSize ( 300 , 300 ) ;
frame. setVisible ( true ) ;
Button east = new Button ( "east" ) ;
Button west = new Button ( "west" ) ;
Button north = new Button ( "north" ) ;
Button south = new Button ( "south" ) ;
Button center = new Button ( "center" ) ;
frame. add ( east, BorderLayout . EAST) ;
frame. add ( west, BorderLayout . WEST) ;
frame. add ( north, BorderLayout . NORTH) ;
frame. add ( south, BorderLayout . SOUTH) ;
frame. add ( center, BorderLayout . CENTER) ;
frame. addWindowListener ( new WindowAdapter ( ) {
@Override
public void windowClosing ( WindowEvent e) {
System . exit ( 0 ) ;
}
} ) ;
}
}
表格布局
import java. awt. * ;
import java. awt. event. WindowAdapter ;
import java. awt. event. WindowEvent ;
public class TestGridLayout {
public static void main ( String [ ] args) {
Frame frame = new Frame ( "testGridLayout" ) ;
frame. setBounds ( 300 , 300 , 300 , 300 ) ;
frame. setVisible ( true ) ;
Button btn1 = new Button ( "btn1" ) ;
Button btn2 = new Button ( "btn2" ) ;
Button btn3 = new Button ( "btn3" ) ;
Button btn4 = new Button ( "btn4" ) ;
Button btn5 = new Button ( "btn5" ) ;
Button btn6 = new Button ( "btn6" ) ;
frame. setLayout ( new GridLayout ( 5 , 5 ) ) ;
frame. add ( btn1) ;
frame. add ( btn2) ;
frame. add ( btn3) ;
frame. add ( btn4) ;
frame. add ( btn5) ;
frame. add ( btn6) ;
frame. pack ( ) ;
frame. addWindowListener ( new WindowAdapter ( ) {
@Override
public void windowClosing ( WindowEvent e) {
System . exit ( 0 ) ;
}
} ) ;
}
}
练习
import java. awt. * ;
import java. awt. event. WindowAdapter ;
import java. awt. event. WindowEvent ;
public class PracticeDemo {
public static void main ( String [ ] args) {
Frame frame = new Frame ( "practiceDemo" ) ;
frame. setBounds ( 300 , 300 , 500 , 500 ) ;
frame. setVisible ( true ) ;
frame. setLayout ( new GridLayout ( 2 , 1 ) ) ;
frame. setBackground ( Color . GREEN) ;
Panel p1 = new Panel ( new BorderLayout ( ) ) ;
Panel p2 = new Panel ( new GridLayout ( 2 , 1 ) ) ;
Panel p3 = new Panel ( new BorderLayout ( ) ) ;
Panel p4 = new Panel ( new GridLayout ( 2 , 2 ) ) ;
p1. add ( new Button ( "West-1" ) , BorderLayout . WEST) ;
p1. add ( new Button ( "East-1" ) , BorderLayout . EAST) ;
p2. add ( new Button ( "p2-btn-1" ) ) ;
p2. add ( new Button ( "p2-btn-2" ) ) ;
p1. add ( p2) ;
frame. add ( p1) ;
p3. add ( new Button ( "West-2" ) , BorderLayout . WEST) ;
p3. add ( new Button ( "East-2" ) , BorderLayout . EAST) ;
p4. add ( new Button ( "p4-btn-1" ) ) ;
p4. add ( new Button ( "p4-btn-2" ) ) ;
p4. add ( new Button ( "p4-btn-3" ) ) ;
p4. add ( new Button ( "p4-btn-4" ) ) ;
p3. add ( p4) ;
frame. add ( p3) ;
frame. addWindowListener ( new WindowAdapter ( ) {
@Override
public void windowClosing ( WindowEvent e) {
System . exit ( 0 ) ;
}
} ) ;
}
}
事件监听
import java. awt. * ;
import java. awt. event. ActionEvent ;
import java. awt. event. ActionListener ;
import java. awt. event. WindowAdapter ;
import java. awt. event. WindowEvent ;
public class TestActionEvent {
public static void main ( String [ ] args) {
Frame frame = new Frame ( ) ;
Button button = new Button ( ) ;
MyActionListener myActionListener = new MyActionListener ( ) ;
button. addActionListener ( myActionListener) ;
frame. setBounds ( 300 , 300 , 300 , 300 ) ;
frame. setVisible ( true ) ;
frame. add ( button, BorderLayout . CENTER) ;
frame. pack ( ) ;
frame. addWindowListener ( new WindowAdapter ( ) {
@Override
public void windowClosing ( WindowEvent e) {
System . exit ( 0 ) ;
}
} ) ;
}
}
class MyActionListener implements ActionListener {
@Override
public void actionPerformed ( ActionEvent e) {
System . out. println ( "aaa" ) ;
}
}
import java. awt. * ;
import java. awt. event. ActionEvent ;
import java. awt. event. ActionListener ;
import java. awt. event. WindowAdapter ;
import java. awt. event. WindowEvent ;
public class TestActionEvent2 {
public static void main ( String [ ] args) {
Frame frame = new Frame ( ) ;
Button button1 = new Button ( "start" ) ;
Button button2 = new Button ( "stop" ) ;
button1. setActionCommand ( "button1-start" ) ;
button2. setActionCommand ( "button2-stop" ) ;
MyMonitor myMonitor = new MyMonitor ( ) ;
button1. addActionListener ( myMonitor) ;
button2. addActionListener ( myMonitor) ;
frame. setLayout ( new FlowLayout ( ) ) ;
frame. add ( button1) ;
frame. add ( button2) ;
frame. setBounds ( 300 , 300 , 300 , 300 ) ;
frame. setVisible ( true ) ;
frame. pack ( ) ;
frame. addWindowListener ( new WindowAdapter ( ) {
@Override
public void windowClosing ( WindowEvent e) {
System . exit ( 0 ) ;
}
} ) ;
}
}
class MyMonitor implements ActionListener {
@Override
public void actionPerformed ( ActionEvent e) {
System . out. println ( "按钮被点击了,msg:" + e. getActionCommand ( ) ) ;
}
}
输入框TextField监听
import java. awt. * ;
import java. awt. event. * ;
public class TestTextField {
public static void main ( String [ ] args) {
new MyFrame2 ( ) ;
}
}
class MyFrame2 extends Frame {
public MyFrame2 ( ) throws HeadlessException {
setBounds ( 300 , 300 , 500 , 500 ) ;
setVisible ( true ) ;
TextField textField = new TextField ( ) ;
add ( textField) ;
textField. setEchoChar ( '*' ) ;
MyActionListener2 myActionListener2 = new MyActionListener2 ( ) ;
textField. addActionListener ( myActionListener2) ;
addWindowListener ( new WindowAdapter ( ) {
@Override
public void windowClosing ( WindowEvent e) {
System . exit ( 0 ) ;
}
} ) ;
}
}
class MyActionListener2 implements ActionListener {
@Override
public void actionPerformed ( ActionEvent e) {
TextField textField = ( TextField ) e. getSource ( ) ;
System . out. println ( textField. getText ( ) ) ;
textField. setText ( "" ) ;
}
}
简易计算器
import java. awt. * ;
import java. awt. event. ActionEvent ;
import java. awt. event. ActionListener ;
import java. awt. event. WindowAdapter ;
import java. awt. event. WindowEvent ;
public class TestCalc {
public static void main ( String [ ] args) {
new Calculator ( ) ;
}
}
class Calculator extends Frame {
TextField num1;
TextField num2;
TextField num3;
Button button;
Label label;
public Calculator ( ) {
load ( ) ;
}
public void load ( ) {
num1 = new TextField ( 20 ) ;
num2 = new TextField ( 20 ) ;
num3 = new TextField ( 20 ) ;
button = new Button ( "=" ) ;
button. addActionListener ( new MyCalculatorListener ( this ) ) ;
label = new Label ( "+" ) ;
setLayout ( new FlowLayout ( ) ) ;
add ( num1) ;
add ( label) ;
add ( num2) ;
add ( button) ;
add ( num3) ;
pack ( ) ;
setVisible ( true ) ;
addWindowListener ( new WindowClose ( ) ) ;
}
}
class MyCalculatorListener implements ActionListener {
private Calculator calculator;
public MyCalculatorListener ( Calculator calculator) {
this . calculator = calculator;
}
@Override
public void actionPerformed ( ActionEvent e) {
int a = Integer . parseInt ( calculator. num1. getText ( ) ) ;
int b = Integer . parseInt ( calculator. num2. getText ( ) ) ;
calculator. num3. setText ( "" + ( a+ b) ) ;
}
}
class WindowClose extends WindowAdapter {
@Override
public void windowClosing ( WindowEvent e) {
System . exit ( 0 ) ;
}
}
画笔
import java. awt. * ;
public class TestPaint {
public static void main ( String [ ] args) {
new MyPaint ( ) . loadFrame ( ) ;
}
}
class MyPaint extends Frame {
public void loadFrame ( ) {
setBounds ( 300 , 300 , 800 , 500 ) ;
setVisible ( true ) ;
}
@Override
public void paint ( Graphics g) {
g. setColor ( Color . ORANGE) ;
g. drawOval ( 100 , 100 , 200 , 200 ) ;
g. fillOval ( 300 , 300 , 100 , 100 ) ;
g. setColor ( Color . red) ;
g. fill3DRect ( 400 , 10 , 100 , 100 , false ) ;
}
}
鼠标监听
import java. awt. * ;
import java. awt. event. MouseAdapter ;
import java. awt. event. MouseEvent ;
import java. awt. event. WindowAdapter ;
import java. awt. event. WindowEvent ;
import java. util. ArrayList ;
import java. util. Iterator ;
public class TestMouseListener {
public static void main ( String [ ] args) {
new MyFrame ( "mouseListener" ) ;
}
}
class MyFrame extends Frame {
private ArrayList points;
public MyFrame ( String title) {
super ( title) ;
setBounds ( 300 , 300 , 500 , 500 ) ;
setVisible ( true ) ;
addWindowListener ( new WindowAdapter ( ) {
@Override
public void windowClosing ( WindowEvent e) {
System . exit ( 0 ) ;
}
} ) ;
addMouseListener ( new MyMouseListener ( ) ) ;
points = new ArrayList < > ( ) ;
}
@Override
public void paint ( Graphics g) {
Iterator iterator = points. iterator ( ) ;
while ( iterator. hasNext ( ) ) {
Point point = ( Point ) iterator. next ( ) ;
g. setColor ( Color . BLUE) ;
g. fillOval ( point. x, point. y, 10 , 10 ) ;
}
}
public void addPaint ( Point point) {
points. add ( point) ;
}
private class MyMouseListener extends MouseAdapter {
@Override
public void mousePressed ( MouseEvent e) {
MyFrame myFrame = ( MyFrame ) e. getSource ( ) ;
myFrame. addPaint ( new Point ( e. getX ( ) , e. getY ( ) ) ) ;
myFrame. repaint ( ) ;
}
}
}
窗口监听
import java. awt. * ;
import java. awt. event. WindowAdapter ;
import java. awt. event. WindowEvent ;
public class TestWindowListener {
public static void main ( String [ ] args) {
new WindowFrame ( ) ;
}
}
class WindowFrame extends Frame {
public WindowFrame ( ) {
setBounds ( 200 , 200 , 300 , 300 ) ;
setBackground ( Color . red) ;
setVisible ( true ) ;
addWindowListener ( new WindowAdapter ( ) {
@Override
public void windowClosing ( WindowEvent e) {
System . exit ( 0 ) ;
}
} ) ;
}
}
键盘监听
import java. awt. * ;
import java. awt. event. KeyAdapter ;
import java. awt. event. KeyEvent ;
import java. awt. event. WindowAdapter ;
import java. awt. event. WindowEvent ;
public class TestKeyListener {
public static void main ( String [ ] args) {
new KeyFrame ( ) ;
}
}
class KeyFrame extends Frame {
public KeyFrame ( ) {
setBounds ( 200 , 200 , 300 , 300 ) ;
setVisible ( true ) ;
addKeyListener ( new KeyAdapter ( ) {
@Override
public void keyPressed ( KeyEvent e) {
int keyCode = e. getKeyCode ( ) ;
if ( keyCode== KeyEvent . VK_UP) {
System . out. println ( "你按下了上键" ) ;
}
}
} ) ;
addWindowListener ( new WindowAdapter ( ) {
@Override
public void windowClosing ( WindowEvent e) {
System . exit ( 0 ) ;
}
} ) ;
}
}
Swing
窗口、面板
import javax. swing. * ;
import java. awt. * ;
public class TestJFrame {
public void init ( ) {
JFrame frame = new JFrame ( "这是一个JFrame窗口" ) ;
frame. setBounds ( 300 , 300 , 300 , 300 ) ;
frame. setVisible ( true ) ;
JLabel label = new JLabel ( "Hello world" ) ;
label. setHorizontalAlignment ( SwingConstants . CENTER) ;
frame. add ( label) ;
Container container = frame. getContentPane ( ) ;
container. setBackground ( Color . red) ;
frame. setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE) ;
}
public static void main ( String [ ] args) {
new TestJFrame ( ) . init ( ) ;
}
}
import javax. swing. * ;
import java. awt. * ;
public class TestJPanel extends JFrame {
public TestJPanel ( ) {
Container container = getContentPane ( ) ;
container. setLayout ( new GridLayout ( 2 , 1 , 10 , 10 ) ) ;
JPanel panel1 = new JPanel ( new GridLayout ( 1 , 3 ) ) ;
panel1. add ( new JButton ( "1" ) ) ;
panel1. add ( new JButton ( "2" ) ) ;
panel1. add ( new JButton ( "3" ) ) ;
container. add ( panel1) ;
this . setVisible ( true ) ;
this . setSize ( 200 , 200 ) ;
setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE) ;
}
public static void main ( String [ ] args) {
new TestJPanel ( ) ;
}
}
弹窗
import javax. swing. * ;
import java. awt. * ;
import java. awt. event. ActionEvent ;
import java. awt. event. ActionListener ;
public class DialogDemo extends JFrame {
public DialogDemo ( ) {
setVisible ( true ) ;
setBounds ( 300 , 300 , 300 , 300 ) ;
setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE) ;
Container container = getContentPane ( ) ;
container. setLayout ( null ) ;
JButton button = new JButton ( "弹窗" ) ;
button. setBounds ( 100 , 100 , 100 , 100 ) ;
button. addActionListener ( new ActionListener ( ) {
@Override
public void actionPerformed ( ActionEvent e) {
new MyDialog ( ) ;
}
} ) ;
container. add ( button) ;
}
public static void main ( String [ ] args) {
new DialogDemo ( ) ;
}
}
class MyDialog extends JDialog {
public MyDialog ( ) {
setVisible ( true ) ;
this . setBounds ( 100 , 100 , 100 , 100 ) ;
Container container = getContentPane ( ) ;
container. setLayout ( null ) ;
container. add ( new JLabel ( "Hello world" ) ) ;
}
}
Icon标签
import javax. swing. * ;
import java. awt. * ;
public class TestICON extends JFrame implements Icon {
public static void main ( String [ ] args) {
new TestICON ( ) . init ( ) ;
}
private int width;
private int heigth;
public TestICON ( ) { }
public TestICON ( int width, int heigth) {
this . width = width;
this . heigth = heigth;
}
@Override
public void paintIcon ( Component c, Graphics g, int x, int y) {
g. fillOval ( x, y, width, heigth) ;
}
@Override
public int getIconWidth ( ) {
return 0 ;
}
@Override
public int getIconHeight ( ) {
return 0 ;
}
public void init ( ) {
TestICON icon = new TestICON ( 15 , 15 ) ;
JLabel label = new JLabel ( "testICON" , icon, SwingConstants . CENTER) ;
Container container = getContentPane ( ) ;
container. add ( label) ;
setBounds ( 200 , 200 , 300 , 300 ) ;
setVisible ( true ) ;
setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE) ;
}
}
ImageIcon标签
import javax. swing. * ;
import java. awt. * ;
import java. net. URL;
public class TestImageIcon extends JFrame {
public TestImageIcon ( ) {
JLabel label = new JLabel ( "ImageIcon" ) ;
URL url = TestImageIcon . class . getResource ( "check-circle.png" ) ;
ImageIcon icon = new ImageIcon ( url) ;
label. setIcon ( icon) ;
label. setSize ( 100 , 100 ) ;
label. setHorizontalAlignment ( SwingConstants . CENTER) ;
Container container = getContentPane ( ) ;
container. add ( label) ;
setVisible ( true ) ;
setBounds ( 300 , 300 , 1000 , 1000 ) ;
setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE) ;
}
public static void main ( String [ ] args) {
new TestImageIcon ( ) ;
}
}
文本域JScroll面板
import javax. swing. * ;
import java. awt. * ;
public class TestJScroll extends JFrame {
public TestJScroll ( ) {
Container container = getContentPane ( ) ;
JTextArea textArea = new JTextArea ( 40 , 50 ) ;
textArea. setText ( "Hello world" ) ;
JScrollPane scrollPane = new JScrollPane ( textArea) ;
container. add ( scrollPane) ;
this . setVisible ( true ) ;
this . setSize ( 300 , 300 ) ;
this . setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE) ;
}
public static void main ( String [ ] args) {
new TestJScroll ( ) ;
}
}
按钮
普通按钮
import javax. swing. * ;
import java. awt. * ;
import java. net. URL;
public class TestJButton extends JFrame {
public static void main ( String [ ] args) {
new TestJButton ( ) ;
}
public TestJButton ( ) {
Container container = getContentPane ( ) ;
URL url = TestJButton . class . getResource ( "check-circle.png" ) ;
ImageIcon icon = new ImageIcon ( url) ;
JButton button = new JButton ( ) ;
button. setIcon ( icon) ;
button. setBounds ( 50 , 50 , 50 , 50 ) ;
button. setToolTipText ( "图标按钮" ) ;
this . setVisible ( true ) ;
this . setSize ( 1000 , 1000 ) ;
this . setLayout ( new GridLayout ( 2 , 2 ) ) ;
this . setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE) ;
container. add ( button) ;
}
}
单选框
import javax. swing. * ;
import java. awt. * ;
public class TestRadioButton extends JFrame {
public static void main ( String [ ] args) {
new TestRadioButton ( ) ;
}
public TestRadioButton ( ) {
Container container = getContentPane ( ) ;
JRadioButton radioButton1 = new JRadioButton ( "JRadioButton1" ) ;
JRadioButton radioButton2 = new JRadioButton ( "JRadioButton2" ) ;
JRadioButton radioButton3 = new JRadioButton ( "JRadioButton3" ) ;
ButtonGroup group1 = new ButtonGroup ( ) ;
group1. add ( radioButton1) ;
group1. add ( radioButton2) ;
ButtonGroup group2 = new ButtonGroup ( ) ;
group2. add ( radioButton3) ;
this . setVisible ( true ) ;
this . setSize ( 1000 , 1000 ) ;
this . setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE) ;
container. add ( radioButton1, BorderLayout . NORTH) ;
container. add ( radioButton2, BorderLayout . CENTER) ;
container. add ( radioButton3, BorderLayout . SOUTH) ;
}
}
复选框
import javax. swing. * ;
import java. awt. * ;
public class TestJCheckBox extends JFrame {
public static void main ( String [ ] args) {
new TestJCheckBox ( ) ;
}
public TestJCheckBox ( ) {
Container container = getContentPane ( ) ;
JCheckBox checkbox01 = new JCheckBox ( "checkbox01" ) ;
JCheckBox checkbox02 = new JCheckBox ( "checkbox02" ) ;
container. add ( checkbox01) ;
container. add ( checkbox02) ;
this . setVisible ( true ) ;
this . setSize ( 1000 , 1000 ) ;
this . setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE) ;
this . setLayout ( new FlowLayout ( FlowLayout . LEFT) ) ;
}
}
列表
下拉框
public class TestJComboBox extends JFrame {
public static void main ( String [ ] args) {
new TestJComboBox ( ) ;
}
public TestJComboBox ( ) {
Container container = getContentPane ( ) ;
JPanel panel = new JPanel ( ) ;
container. add ( panel) ;
JComboBox jComboBox = new JComboBox ( ) ;
jComboBox. addItem ( null ) ;
jComboBox. addItem ( "正在热映" ) ;
jComboBox. addItem ( "已下架" ) ;
jComboBox. addItem ( "即将上映" ) ;
panel. add ( jComboBox) ;
this . setVisible ( true ) ;
this . setSize ( 300 , 300 ) ;
this . setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE) ;
}
}
列表框
import javax. swing. * ;
import java. awt. * ;
public class TestJList extends JFrame {
public static void main ( String [ ] args) {
new TestJList ( ) ;
}
public TestJList ( ) {
Container container = getContentPane ( ) ;
String [ ] contents = { "aaa" , "男" , "20" } ;
JList jList = new JList ( contents) ;
container. add ( jList) ;
this . setVisible ( true ) ;
this . setSize ( 300 , 300 ) ;
this . setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE) ;
}
}
文本框
文本框
import javax. swing. * ;
import java. awt. * ;
public class TestJTextField extends JFrame {
public static void main ( String [ ] args) {
new TestJTextField ( ) ;
}
public TestJTextField ( ) {
this . setVisible ( true ) ;
this . setSize ( 300 , 300 ) ;
this . setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE) ;
Container container = this . getContentPane ( ) ;
JTextField textField1 = new JTextField ( "Hello world" ) ;
JTextField textField2 = new JTextField ( "你好,世界!" , 30 ) ;
container. add ( textField1) ;
container. add ( textField2) ;
container. setLayout ( new GridLayout ( 2 , 1 ) ) ;
}
}
密码框
import javax. swing. * ;
import java. awt. * ;
public class TestPasswordField extends JFrame {
public static void main ( String [ ] args) {
new TestPasswordField ( ) ;
}
public TestPasswordField ( ) {
this . setVisible ( true ) ;
this . setSize ( 300 , 300 ) ;
this . setDefaultCloseOperation ( WindowConstants . EXIT_ON_CLOSE) ;
Container container = this . getContentPane ( ) ;
JPasswordField passwordField = new JPasswordField ( ) ;
container. add ( passwordField) ;
}
}