public class UIResourceTest extends javax.swing.JFrame
{
/** Creates new form UIResourceTest */
public UIResourceTest() {
initComponents();
}
private void initComponents() {
//GEN-BEGIN:initComponents
jTextArea1 = new javax.swing.JTextArea("Test",10,10);
//jTextArea1.set
jScrollPane1 = new javax.swing.JScrollPane(jTextArea1);
button = new javax.swing.JButton("TestButton");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
getContentPane().add(button, java.awt.BorderLayout.SOUTH);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(200, 150));
setLocation((screenSize.width-150)/2,(screenSize.height-100)/2);
}
//GEN-END:initComponents
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
//GEN-FIRST:event_exitForm
System.exit(0);
}
//GEN-LAST:event_exitForm
/*** @param args the command line arguments*/
public static void main(String args[]) {
try{
javax.swing.UIDefaults ui = javax.swing.UIManager.getDefaults();
java.util.Enumeration enum = ui.keys();
java.awt.Font font = new java.awt.Font("宋体", java.awt.Font.BOLD, 20);
while (enum.hasMoreElements()) {
String key = (String)enum.nextElement();
System.out.println(key); if (key.indexOf(".font") > 0) {
javax.swing.UIManager.put(key, font);
}
} javax.swing.UIManager.put("ScrollBar.thumb", new javax.swing.plaf.ColorUIResource(33,129,176));
javax.swing.UIManager.put("Button.foreground", new javax.swing.plaf.ColorUIResource(255,0,0));
}catch(Exception e){
e.printStackTrace();
}
UIResourceTest test = new UIResourceTest();
test.show();
}
// Variables declaration - do not modify
//GEN-BEGIN:variables
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JButton button;
// End of variables declaration
//GEN-END:variables
}
{
/** Creates new form UIResourceTest */
public UIResourceTest() {
initComponents();
}
private void initComponents() {
//GEN-BEGIN:initComponents
jTextArea1 = new javax.swing.JTextArea("Test",10,10);
//jTextArea1.set
jScrollPane1 = new javax.swing.JScrollPane(jTextArea1);
button = new javax.swing.JButton("TestButton");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
getContentPane().add(button, java.awt.BorderLayout.SOUTH);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(200, 150));
setLocation((screenSize.width-150)/2,(screenSize.height-100)/2);
}
//GEN-END:initComponents
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
//GEN-FIRST:event_exitForm
System.exit(0);
}
//GEN-LAST:event_exitForm
/*** @param args the command line arguments*/
public static void main(String args[]) {
try{
javax.swing.UIDefaults ui = javax.swing.UIManager.getDefaults();
java.util.Enumeration enum = ui.keys();
java.awt.Font font = new java.awt.Font("宋体", java.awt.Font.BOLD, 20);
while (enum.hasMoreElements()) {
String key = (String)enum.nextElement();
System.out.println(key); if (key.indexOf(".font") > 0) {
javax.swing.UIManager.put(key, font);
}
} javax.swing.UIManager.put("ScrollBar.thumb", new javax.swing.plaf.ColorUIResource(33,129,176));
javax.swing.UIManager.put("Button.foreground", new javax.swing.plaf.ColorUIResource(255,0,0));
}catch(Exception e){
e.printStackTrace();
}
UIResourceTest test = new UIResourceTest();
test.show();
}
// Variables declaration - do not modify
//GEN-BEGIN:variables
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JButton button;
// End of variables declaration
//GEN-END:variables
}
解决方案 »
- BorderLayout中遇到组件的大小问题
- 请写出下面代码的多次类型转化后的结果
- invalid horizontalScrollBarPolicy是怎么回事啊?在线急!
- 请问如何将另外一个工程加到一个工程里来
- 如何将STRING "2003-11-01 11:12:23" 转为系统时间long。急急~!
- jbuilder须要设置什么不???
- 求Java2核心技术(第6版)源代码,,,100分,,,不盛感激,,,
- Java继承想不明白的问题,求大神解决
- 一个简单的问题,望有人帮一下!!!
- 如何注册1!!jbuilder5.0
- 关于java和excel的连接
- 帮忙提供一个通过socket发送文件的例子,谢谢!!只有60分拉。。
javax.swing.UIManager.put(key, font);
}你可以把系统中所有字体任意替换成你想要的字体。
关于字体呢~有2中
一种是本地化与国际化,这个一般用与大型开发的语言设置问题,普通用户是不会用到的~
还有就是字体问题,这个和好解决的,在jdk中有相映的方法,就是component类提供获得 和改变当前字体信息的方法,具体方法就是楼上的