Java界面应用程序

package text12;
import java.awt.*;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class text1 extends JFrame {
//  private JButton jbt1,jbt2,jbt3,jbt4,jbt5,jbt6;
    public text1(){
        JPanel p1=new JPanel();
        p1.setLayout(new FlowLayout());
        p1.add(new JButton("Button 1"));
        p1.add(new JButton("Button 2"));
        p1.add(new JButton("Button 3"));
        JPanel p2=new JPanel();
        p2.setLayout(new FlowLayout());
        p2.add(new JButton("Button 4"));
        p2.add(new JButton("Button 5"));
        p2.add(new JButton("Button 6"));
        setLayout(new FlowLayout());
        add(p1);
        add(p2);        
    }
    public static void main(String[] args){
        JFrame frame=new text1();
        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("Exercise 12_1");
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

}

package text12;

import java.awt.FlowLayout;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class text2 extends JPanel {
    public text2(){
        add(new JButton("Button 1"));
        add(new JButton("Button 2"));
        add(new JButton("Button 3"));
        setLayout(new FlowLayout());        
    }
    public static void main(String[] args){
        JFrame frame=new JFrame();
        JPanel p=new JPanel(new GridLayout(2, 1,5,5));
        text2 p1=new text2();
        text2 p2=new text2();
        p.add(p1);
        p.add(p2);      
        frame.add(p);       
        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);     
    }
}


``package text12;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

public class text3 extends JPanel{
    public text3(){
        setLayout(new GridLayout(4,1));     
        JLabel l1=new JLabel("Department of Computer Science");
        l1.setBorder(new LineBorder(Color.blue,1));
        JLabel l2=new JLabel("School of Computing");
        l2.setBorder(new LineBorder(Color.GRAY,1));
        JLabel l3=new JLabel("Armstong Atlanfic");
        l3.setBorder(new LineBorder(Color.RED,1));
        JLabel l4=new JLabel("Tel(912)921-6440");
        l4.setBorder(new LineBorder(Color.black,1));        
        add(l1);
        add(l2);
        add(l3);
        add(l4);            
    }
    public static void main(String[] args){
        JFrame frame=new JFrame();
        text3 p=new text3();
        frame.add(p);
        frame.setTitle("Exercise12_5");
        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

package text12;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.LineBorder;
public class text4 extends JPanel{
private ImageIcon usIcon=new ImageIcon(“D:\tu\b.jpg”);
private ImageIcon myIcon=new ImageIcon(“D:\tu\c.jpg”);
private ImageIcon frIcon=new ImageIcon(“D:\tu\d.jpg”);
private ImageIcon ukIcon=new ImageIcon(“D:\tu\e.jpg”);
public text4(){
setLayout(new GridLayout(2,2,1,1));
JLabel l1=new JLabel(usIcon);
JLabel l2=new JLabel(myIcon);
JLabel l3=new JLabel(frIcon);
JLabel l4=new JLabel(ukIcon);
l1.setBorder(new LineBorder(Color.BLUE,1));
l2.setBorder(new LineBorder(Color.BLUE,1));
l3.setBorder(new LineBorder(Color.BLUE,1));
l4.setBorder(new LineBorder(Color.BLUE,1));
add(l1);
add(l2);
add(l3);
add(l4);
}
public static void main(String[] args){
JFrame frame=new JFrame();
text4 p=new text4();
frame.add(p);
frame.pack();
frame.setSize(200,200);
frame.setTitle(“Exercise12_6”);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}

package text12;

import java.awt.*;
import javax.swing.*;
public class text5 extends JFrame{

    public text5(){


        //ImageIcon icon = new ImageIcon("d:\\tu\\c.jpg");
        JButton button = new JButton("beauty");
        button.setIcon(new ImageIcon("d:\\tu\\c.jpg"));
        add(button);
        setLayout(new FlowLayout());

    }
    public static void main(String[] args){

       text5 frame= new text5();
       frame.pack();
       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
       frame.setLocationRelativeTo(null);
       frame.setVisible(true);
    }

}
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值