package task1;
import java.awt.*;
import javax.swing.*;
public class task2
{
public static void main(String[] args)
{
JFrame fr=new JFrame("A simple GUi");//设置一个窗口
JPanel fy=new JPanel();//添加一个面板
JLabel ft=new JLabel("Which one is your choice?");//加入一个标签
JButton yes=new JButton("Yes");//加入一个按钮
TextField fu=new TextField(30);
TextField jt=new TextField("输入");
jt.setEnabled(false);
FlowLayout flow=new FlowLayout();//创建流式布局
fr.add(fy);//将面板添加到JFrame中
fy.add(jt);//添加提示文本框
fy.add(fu);//文本信息放置在面板上
fy.setLayout(flow);
fy.add(ft);//标签
fy.add(yes);//按钮
ft.setFont(new Font("黑体",Font.BOLD|Font.ITALIC,30));//标贴的字体
ft.setForeground(Color.green);//标贴的颜色
yes.setFont(new Font("黑体",Font.BOLD|Font.ITALIC,40));//标贴的字体
yes.setForeground(Color.pink);//按钮的字颜色
yes.setBackground(Color.black);//按钮的背景色
jt.setFont(new Font("黑体",Font.BOLD|Font.ITALIC,20));//提示文本框字体(斜体)。
fu.setFont(new Font("谐体",Font.BOLD,30));//设置字体。
fu.setBackground(Color.red);//背景色
fu.setForeground(Color.black);//字体颜色2
fr.setBounds(400, 400, 500, 300);//窗口边界
fr.setVisible(true);//是否窗口可见
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}