swing列表、文本框

时间:2021-08-23 20:20:34   收藏:0   阅读:22

3.6列表

package com.zishi.lesson06;
?
import javax.swing.*;
import java.awt.*;
?
public class TestComboboxDemo01 extends JFrame {
?
   public TestComboboxDemo01(){
?
       Container container = this.getContentPane();
?
       JComboBox status = new JComboBox();
?
       status.addItem(null);
       status.addItem("正在热映");
       status.addItem("已下架");
       status.addItem("即将上映");
       
       container.add(status);
?
       this.setVisible(true);
       this.setSize(200,400);
       this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  }
?
   public static void main(String[] args) {
       new TestComboboxDemo01();
  }
}

 

3.7 文本框

package com.zishi.lesson06;
?
import javax.swing.*;
import java.awt.*;
?
public class TestTextDemo01 extends JFrame {
?
   public TestTextDemo01(){
?
       Container container = this.getContentPane();
?
       JTextField textField = new JTextField("textField",20);
       JTextField textField02 = new JTextField("textField2",20);
?
       container.add(textField,BorderLayout.NORTH);
       container.add(textField02,BorderLayout.SOUTH);
?
       this.setVisible(true);
       this.setSize(300,400);
       this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  }
?
   public static void main(String[] args) {
       new TestTextDemo01();
  }
}

 

package com.zishi.lesson06;
?
import javax.swing.*;
import java.awt.*;
?
public class TestTextDemo03 extends JFrame {
?
   public TestTextDemo03(){
?
       Container container = this.getContentPane();
?
       JTextArea textArea = new JTextArea();
       textArea.setText("一起学JAVA" +
               "skaljdlajks" +
               "ksjmalkdjkla" +
               "asdbagskjaghkjd");
?
       //Scroll滚动面板
?
       JScrollPane scrollPane = new JScrollPane(textArea);
?
       container.add(scrollPane);
?
       this.setVisible(true);
       this.setSize(300,400);
       this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  }
?
   public static void main(String[] args) {
       new TestTextDemo03();
  }
}

 

package com.zishi.lesson06;
?
import javax.swing.*;
import java.awt.*;
?
public class TestTextDemo02 extends JFrame {
?
   public TestTextDemo02(){
?
       Container container = this.getContentPane();
?
       JPasswordField passwordField = new JPasswordField(20);//........默认
       passwordField.setEchoChar(‘*‘);//********
       container.add(passwordField);
       this.setVisible(true);
       this.setSize(300,400);
       this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  }
?
   public static void main(String[] args) {
       new TestTextDemo02();
  }
}

 

原文:https://www.cnblogs.com/yizhifei/p/15177277.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!