zoukankan      html  css  js  c++  java
  • Java:终于找到了在alloy中的JFileChooser中的弹出式菜单不显示文字的解决办法

    alloy界面可以说是我写过的最漂亮的一种JAVA界面。

    可惜不知为什么,至从几年前推出1.4版后,就再也没有更新了。

    随着java版本的升级,一直很担心alloy有一天不再适用于java的最新版。

    现在在java6.0上用alloy,感觉还是很不错的,就是JFileChooser对话框上点右键时,弹出的菜单上的文字都是空白的,让人感觉不舒服。

    今天我终于找到了解决的办法:

    我首先找到了一个对于JFileChooser来说很关键的类:sun.swing.FilePane

    我不明白,为什么要把FilePane放在sun.swing包中。

    网上搜索了一下,看到有不少人说这个FilePane类没有的供源代码,可我感觉问题与这个类很有关系。

    到网上下载了一个java反编译软件,然后到jdk目录将rt.jar解压缩,用反编译软件FilePane类反编译了一下,在我一行一行的检查之后,终于找到了问题之所在:

    FilePane.java

    protected void installDefaults()
         {
             java.util.Locale locale = getFileChooser().getLocale();
             listViewBorder = UIManager.getBorder("FileChooser.listViewBorder");
             listViewBackground = UIManager.getColor("FileChooser.listViewBackground");
             listViewWindowsStyle = UIManager.getBoolean("FileChooser.listViewWindowsStyle");
             readOnly = UIManager.getBoolean("FileChooser.readOnly");
             viewMenuLabelText = UIManager.getString("FileChooser.viewMenuLabelText", locale);
             refreshActionLabelText = UIManager.getString("FileChooser.refreshActionLabelText", locale);
             newFolderActionLabelText = UIManager.getString("FileChooser.newFolderActionLabelText", locale);
             viewTypeActionNames = new String[2];
             viewTypeActionNames[0] = UIManager.getString("FileChooser.listViewActionLabelText", locale);
             viewTypeActionNames[1] = UIManager.getString("FileChooser.detailsViewActionLabelText", locale);
             kiloByteString = UIManager.getString("FileChooser.fileSizeKiloBytes", locale);
             megaByteString = UIManager.getString("FileChooser.fileSizeMegaBytes", locale);
             gigaByteString = UIManager.getString("FileChooser.fileSizeGigaBytes", locale);
         }

    解决办法:

    UIManager.put("FileChooser.viewMenuLabelText","视图");
    UIManager.put("FileChooser.newFolderActionLabelText","新建文件夹");
    UIManager.put("FileChooser.refreshActionLabelText","刷新");
    UIManager.put("FileChooser.listViewActionLabelText","列表");  
    UIManager.put("FileChooser.detailsViewActionLabelText","详细信息");

    2007-10-27

  • 相关阅读:
    npm start 时报 node_modules/nan 错误
    webpack 插件依赖
    reducer-form 数组字段 在removeField/removeField 之后 dirty 不改变的问题
    sass 入门教程
    解决国内gem不能用的问题
    nrm 快速切换 NPM 源
    数值补全指定位数
    文本溢出使用省略号
    css/js效果笔记
    用MyEclipse,只要一开css文件就报错,按下任何键都报错
  • 原文地址:https://www.cnblogs.com/personnel/p/4582909.html
Copyright © 2011-2022 走看看