Swing控件(JLabel,JButton....)设置字体和大小
来源:互联网 发布:淘宝求好评短信模板 编辑:程序博客网 时间:2024/06/05 21:17
有很多方法可以给Swing的控件设置字体和样式,我这里介绍一种直观的。
首先我们要定义一种字体例如:
Font f = new Font("隶书",Font.PLAIN,15);
然后我们利用UIManager全局的给控件设置样式,例如:
UIManager.put("Label.font",font);
这样我们就给所有的JLabel设置了字体的样式即15号隶书。
这样的好处就是我们可以利用一个全局的方法,精确控制各种控件的字体和大小。
当然关于JLabel,您还可以用更灵活的方法,JLabel里的内容是支持html标签的。例如:
下面是UIManager的详细参数
文章地址:http://javapub.iteye.com/blog/753739
首先我们要定义一种字体例如:
Font f = new Font("隶书",Font.PLAIN,15);
然后我们利用UIManager全局的给控件设置样式,例如:
UIManager.put("Label.font",font);
这样我们就给所有的JLabel设置了字体的样式即15号隶书。
这样的好处就是我们可以利用一个全局的方法,精确控制各种控件的字体和大小。
当然关于JLabel,您还可以用更灵活的方法,JLabel里的内容是支持html标签的。例如:
- JLabel demoLabel = new JLabel();
- //demoLabel.setText("<b>这是一号标题</b>");
- //demoLabel.setText("<li>这是一号标题<li>");
- demoLabel.setText("<h1>这是一号标题</h1>");
下面是UIManager的详细参数
- Font f = new Font("隶书",Font.PLAIN,15);
- UIManager.put("Button.font",font);
- UIManager.put("ToggleButton.font",font);
- UIManager.put("RadioButton.font",font);
- UIManager.put("CheckBox.font",font);
- UIManager.put("ColorChooser.font",font);
- UIManager.put("ToggleButton.font",font);
- UIManager.put("ComboBox.font",font);
- UIManager.put("ComboBoxItem.font",font);
- UIManager.put("InternalFrame.titleFont",font);
- UIManager.put("Label.font",font);
- UIManager.put("List.font",font);
- UIManager.put("MenuBar.font",font);
- UIManager.put("Menu.font",font);
- UIManager.put("MenuItem.font",font);
- UIManager.put("RadioButtonMenuItem.font",font);
- UIManager.put("CheckBoxMenuItem.font",font);
- UIManager.put("PopupMenu.font",font);
- UIManager.put("OptionPane.font",font);
- UIManager.put("Panel.font",font);
- UIManager.put("ProgressBar.font",font);
- UIManager.put("ScrollPane.font",font);
- UIManager.put("Viewport",font);
- UIManager.put("TabbedPane.font",font);
- UIManager.put("TableHeader.font",font);
- UIManager.put("TextField.font",font);
- UIManager.put("PasswordFiled.font",font);
- UIManager.put("TextArea.font",font);
- UIManager.put("TextPane.font",font);
- UIManager.put("EditorPane.font",font);
- UIManager.put("TitledBorder.font",font);
- UIManager.put("ToolBar.font",font);
- UIManager.put("ToolTip.font",font);
- UIManager.put("Tree.font",font);
文章地址:http://javapub.iteye.com/blog/753739
- Swing控件(JLabel,JButton....)设置字体和大小
- Java Swing简单控件实例(JButton,JLabel,JMenuBar,JComboBo)
- Java Swing简单控件实例(JButton,JLabel,JMenuBar,JComboBo)
- Java Swing简单控件实例(JButton,JLabel,JMenuBar,JComboBo)
- Swing笔记(一)——JLabel和JButton组件
- java Swing: JLabel 设置字体颜色 换行
- Swing JButton设置背景图片
- Java中怎么设置JLabel的字体样式,大小,颜色?
- VC控件大小和字体设置
- JAVA swing JLabel JButton标签文本文字内容的换行
- JButton 设置大小
- 在Swing中设置字体的大小
- JLabel、JButton换行问题
- JLabel, JButton换行显示
- JLabel、JButton换行问题
- ImageButton swing 设置Jbutton背景图片的方法
- java swing技巧1:基于图像的组件-JLabel、JButton、JPanel
- 部件大小和字体设置
- yaffs2
- Tomcat 5.5默认不解析EL表达式的解决办法
- gridview自带分页获取行号问题
- 常用sql---查看一张表里是否有同名员工
- Java基础----MessageBox的用法
- Swing控件(JLabel,JButton....)设置字体和大小
- microsoft-HTTPAPI占用80端口,导致APACHE,WAMP,PHPNOW无法启动解决方法
- Linux下编译动态链接库
- 运行可执行程序时提示文件不存在解决方法
- GIT和repo使用方法,下载android-2.6.29内核
- Java Swing Border(Swing 边框) 归纳
- AJax 返回 json
- Android中更新UI的线程:Thread 、Handler 、Loopper 、TimerTask等
- 1001超级最小公倍数