Swing
JFrame窗口
package gui.lesson01.lesson03;
import javax.swing.*;
import java.awt.*;
public class TextJFrame{
public static void main(String[] args) {
new JFrame01().init();
}
}
class JFrame01 extends JFrame {
public void init(){
this.setBounds(100,100,300,300);
this.setVisible(true);
JLabel jlabel = new JLabel("欢迎来到JFrame窗口");
this.add(jlabel);
JDialog弹窗
JDialog用来被弹出窗体,默认有关闭事件。
package gui.lesson01.lesson03;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Image标签
package gui.lesson01.lesson03;
import javax.swing.*;
import java.awt.*;
import java.net.URL;
public class TextImage extends JFrame {
public TextImage() {
JLabel jLabel = new JLabel();
icon标签
package gui.lesson01.lesson03;
import javax.swing.*;
import java.awt.*;
public class TextIcon extends JFrame implements Icon {
private int width,height;
面板布局JPanel
package gui.lesson01.lesson03;
import javax.swing.*;
import java.awt.*;
public class TextJscroll extends JFrame {
public TextJscroll() {
TextArea textArea = new TextArea();
JScroll面板(含滚动条)
package gui.lesson01.lesson03;
import javax.swing.*;
import java.awt.*;
public class ScrollDemo extends JFrame{
public ScrollDemo() {
JTextArea jTextArea = new JTextArea(20,50);
引入图片,图片按钮,图片标签
package gui.lesson01.lesson03;
import javax.swing.*;
import java.awt.*;
import java.net.URL;
public class TextPicture extends JFrame {
public TextPicture() {
Container container = this.getContentPane();
URL resource = TextPicture.class.getResource("10.PNG");
package gui.lesson01.lesson03;
import javax.swing.*;
import java.awt.*;
import java.net.URL;
public class TextPic extends JFrame {
public TextPic() {
Container container = this.getContentPane();
URL resource = TextPicture.class.getResource("10.PNG");
package gui.lesson01.lesson03;
import javax.swing.*;
import java.awt.*;
import java.net.URL;
public class TextPic01 extends JFrame {
public TextPic01() {
Container container = this.getContentPane();
URL resource = TextPicture.class.getResource("10.PNG");
package gui.lesson01.lesson04;
import javax.swing.*;
import java.awt.*;
public class TextCombox extends JFrame {
public TextCombox() {
Container container = this.getContentPane();
JComboBox status = new JComboBox();
package gui.lesson01.lesson04;
import javax.swing.*;
import java.awt.*;
import java.util.Vector;
public class TextCombobox01 extends JFrame {
public TextCombobox01() {
Container container = this.getContentPane();
应用场景:1、选择地区,关联性,中国,后面出现中国的城市,下拉框。
2、列表用来展示信息,一般是动态扩容,类似聊天室建房。