日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java 做ui_【原创】JavaApplication的UI也可以做的很美

發布時間:2024/7/23 java 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 做ui_【原创】JavaApplication的UI也可以做的很美 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

最近在做Java Application的項目,對于ui的美觀,做了一些嘗試。有幸看到了JGoodIdes的LookAndFeel包。

效果大家可以看看如下連接

http://www.jgoodies.com

經過試驗,解決了中文亂碼問題,下面將經驗和大家共分享。

LookAndFeel如同css一樣,具體的概念大家可以參考其他文章,這里不做贅述。

http://www.blogjava.net/Files/itaogo/plastic-1.1.3.zip

1,加載附件plastic-1.1.3.jar到lib path,我用的是jbuilderX

2,創建一個新類AppFont.java

import java.awt.*;

import javax.swing.UIManager;

public class AppFont()

{

public static void setFont(Font pFont){

UIManager.put("Button.font", pFont);

UIManager.put("ToggleButton.font", pFont);

UIManager.put("RadioButton.font", pFont);

UIManager.put("CheckBox.font", pFont);

UIManager.put("ColorChooser.font", pFont);

UIManager.put("ToggleButton.font", pFont);

UIManager.put("ComboBox.font", pFont);

UIManager.put("ComboBoxItem.font", pFont);

UIManager.put("InternalFrame.titleFont", pFont);

UIManager.put("Label.font", pFont);

UIManager.put("List.font", pFont);

UIManager.put("MenuBar.font", pFont);

UIManager.put("Menu.font", pFont);

UIManager.put("MenuItem.font", pFont);

UIManager.put("RadioButtonMenuItem.font", pFont);

UIManager.put("CheckBoxMenuItem.font", pFont);

UIManager.put("PopupMenu.font", pFont);

UIManager.put("OptionPane.font", pFont);

UIManager.put("Panel.font", pFont);

UIManager.put("ProgressBar.font", pFont);

UIManager.put("ScrollPane.font", pFont);

UIManager.put("Viewport", pFont);

UIManager.put("TabbedPane.font", pFont);

UIManager.put("TableHeader.font", pFont);

UIManager.put("Table.font", pFont);

UIManager.put("TextField.font", pFont);

UIManager.put("PasswordFiled.font", pFont);

UIManager.put("TextArea.font", pFont);

UIManager.put("TextPane.font", pFont);

UIManager.put("EditorPane.font", pFont);

UIManager.put("TitledBorder.font", pFont);

UIManager.put("ToolBar.font", pFont);

UIManager.put("ToolTip.font", pFont);

UIManager.put("Tree.font", pFont);

}

}

3,尋找您的java application 的主程序

//引入

import com.jgoodies.plaf.LookUtils;

import com.jgoodies.plaf.plastic.PlasticLookAndFeel;

//修改程序如下

//Main method

public static void main(String[] args) {

try {

//原來的,請注釋掉;jbuilder是如此寫法。

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

//修改為

UIManager.put("ClassLoader", LookUtils.class.getClassLoader());

UIManager.setLookAndFeel(new PlasticLookAndFeel());

AppFont.setFont(new java.awt.Font("宋體", 0, 12));

}

catch(Exception e) {

e.printStackTrace();

}

new MainApp();

}

4,附件2 UISample.rar是jbuilder的一個簡單效果的項目。下載地址 http://www.blogjava.net/Files/itaogo/UISample.rar

總結

以上是生活随笔為你收集整理的java 做ui_【原创】JavaApplication的UI也可以做的很美的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。