假期第一个练习就是仿造XP的计算器界面,虽然有很多的差异,但是经过探索发现了不少对于界面和组件美化有很大作用的方法。
需要用到以下几个方法:
JTextField.setHorizontalAlignment(JTextField.RIGHT );//设置输入框又对齐
JTextField.setEnabled(boolean);//设置使能
JButton.setMargin(new Insets(top,left,bottom,right));//设置文本周围和边缘的空白区域的大小
JButton.setForeground(Color.color);//设置字体颜色
JButton.setFont(new Font(String,int,int));//设置文本字体的大小,风格,粗细
经过练习,对JButton 和JTextField的部分方法熟悉了不少