记得在一本书上看到有一个文件可以改变swing的默认ui外观!!--那位大侠提醒一下!!

lanlansky 2001-07-15 12:44:12
忘了那个文件是什么了!!

under windows platform!!

thanx!
...全文
104 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ppxstar_luoxing 2001-07-18
  • 打赏
  • 举报
回复
在JDK目录下的jrb\lib 目录里新增一个文件,文件名是swing.properties(在这个目录里还有许多其它的properties文件),内空如下
swing.defaultlaf=com.sun.java.swing.plaf.motif.MotifLookAndFeel
kevin_c 2001-07-18
  • 打赏
  • 举报
回复
加到Main中
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFell");
lanlansky 2001-07-18
  • 打赏
  • 举报
回复
多谢!ppxstar_luoxing
lanlansky 2001-07-17
  • 打赏
  • 举报
回复
lanlansky 2001-07-17
  • 打赏
  • 举报
回复
up
lanlansky 2001-07-16
  • 打赏
  • 举报
回复
我说的不是怎么改变!


在硬盘的某个地方!存放着这样的一个properties文件
它里面写默认的LookAndFeel
和所支持的LookAndFeel有那几种


我是说这个文件在哪里????
richard_1 2001-07-16
  • 打赏
  • 举报
回复
一个例子:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class PlafPanel extends JPanel
implements ActionListener
{ public PlafPanel()
{ metalButton = new JButton("Metal");
motifButton = new JButton("Motif");
windowsButton = new JButton("Windows");

add(metalButton);
add(motifButton);
add(windowsButton);

metalButton.addActionListener(this);
motifButton.addActionListener(this);
windowsButton.addActionListener(this);
}

public void actionPerformed(ActionEvent evt)
{ Object source = evt.getSource();
String plaf = "";
if (source == metalButton)
plaf = "javax.swing.plaf.metal.MetalLookAndFeel";
else if (source == motifButton)
plaf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
else if (source == windowsButton)
plaf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
try
{ UIManager.setLookAndFeel(plaf);
SwingUtilities.updateComponentTreeUI(this);
}
catch(Exception e) {}
}

private JButton metalButton;
private JButton motifButton;
private JButton windowsButton;
}


class PlafFrame extends JFrame
{ public PlafFrame()
{ setTitle("PlafTest");
setSize(300, 200);
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{ System.exit(0);
}
} );

Container contentPane = getContentPane();
contentPane.add(new PlafPanel());
}
}

public class PlafTest
{ public static void main(String[] args)
{ JFrame frame = new PlafFrame();
frame.show();
}
}
vive 2001-07-15
  • 打赏
  • 举报
回复
UIManager.setLookAndFeel(...)

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧