码迷,mamicode.com
首页 > 编程语言 > 详细

学习java窗口基本操作时无聊写的

时间:2017-06-20 20:14:53      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:pac   tooltip   设置   void   hello   log   setborder   oca   swing   

学习java窗口基本操作时无聊写的

就当记录

代码如下:

package day08;

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

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

public class Testketianglianxin extends JFrame {
public Testketianglianxin() {

Font font1 = new Font("Serif", Font.BOLD + Font.ITALIC, 20);
Font jbutton1 = new Font("Dialog", Font.PLAIN + Font.BOLD, 20);
Font count1 = new Font("楷体", Font.BOLD + Font.PLAIN, 20);

TitledBorder help = new TitledBorder("hello world");
TitledBorder titledBorder = new TitledBorder("三个按钮");

LineBorder lb1 = new LineBorder(Color.RED,4);
LineBorder lb2 = new LineBorder(Color.ORANGE,4);




JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
JButton btn1 = new JButton("Left");
btn1.setForeground(new Color(FRAMEBITS));
btn1.setToolTipText("00000000");
btn1.setFont(font1);

JButton jbutton = new JButton("center");
jbutton.setForeground(new Color(120, 25, 30));
jbutton.setFont(jbutton1);

JButton jbutton2 = new JButton("Right");
jbutton2.setFont(count1);

p1.add(jbutton);
p1.add(btn1);
p1.add(jbutton2);
JPanel p2 = new JPanel(new GridLayout(1,2));
JLabel label1 = new JLabel("Red");
JLabel label2 = new JLabel("Orange");
p2.add(label1);
p2.add(label2);

label1.setBorder(lb1);
label2.setBorder(lb2);

// Font help1 = new Font("楷体", Font.BOLD + Font.PLAIN, 20);
// 创建边框
// 给p1设置边框
p1.setBorder(titledBorder);
p2.setBorder(help);
setLayout(new GridLayout(2, 1, 5, 5));
add(p1);
add(p2);
}

public static void main(String[] args) {
Testketianglianxin fr = new Testketianglianxin();
fr.setSize(500, 300);
fr.setLocationRelativeTo(null);
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fr.setVisible(true);
}
}

学习java窗口基本操作时无聊写的

标签:pac   tooltip   设置   void   hello   log   setborder   oca   swing   

原文地址:http://www.cnblogs.com/F001li/p/7055977.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!