有没有办法在setBorder方法中为Text1和Text2文本定义自己的字体和配色方案。java新手,在SUN教程中找不到它。
我的代码
//Create Positions Table
JPanel SpreadPanel = new JPanel();
SpreadPanel.setBorder(BorderFactory.createTitledBorder(" Text 1 Text 2"));向Simon致敬
发布于 2013-01-01 15:29:46
setBorder(BorderFactory.createTitledBorder(null, "text", TitledBorder.CENTER, TitledBorder.BOTTOM, new Font("times new roman",Font.PLAIN,12), Color.yellow));第一个参数null或另一个边框(用于复合边框)第二个参数显示的文本的第三个和第四个参数参数2中的文本的对齐方式和位置
第四个参数和第五个参数是设置字体和颜色的两个参数
发布于 2010-12-31 02:51:59
如果您希望同一TitledBorder中的每个字符串(例如Text1和Text2)使用不同的字体和颜色,则可能需要扩展AbstractBorder并覆盖paintBorder()。现有的实现对于单个标题只有一种字体和一种颜色。
发布于 2016-07-26 20:32:51
文本字体:
((javax.swing.border.TitledBorder) panel_1.getBorder()).setTitleFont(new Font("Tahoma", Font.PLAIN, 20));文本颜色:
((javax.swing.border.TitledBorder)panel_1.getBorder()).setTitleColor(Color.WHITE);https://stackoverflow.com/questions/4564755
复制相似问题