🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #7496

Re: changing the language in JColorChooser and JFileChooser dialogs

#7496
From: Torsten Welches
Date: Wed, 24 Jan 2001 22:14
53 lines
2898 bytes
Luc,

>Does a  UIManager slot exist for each of these properties and if yes, how
do
>you find them out ?

yes. UIManager.getDefaults() returns an UIDefaults, which is a Hashtable.
Here's a method do show all slots with values in a JTable. (I got this from
somewhere on the net, so the fame is not mine... <g>)

Torsten

public static void showUIDefaults() {
    UIDefaults uid = UIManager.getDefaults();
    //we use a TreeMap for sorting
    final TreeMap dataX = new TreeMap();
    Object k, v;
    for(Enumeration e=uid.keys();e.hasMoreElements();) {
      k=e.nextElement();
      v=uid.get(k);
      try {dataX.put(k.toString(),v.toString());} catch (Exception ignore)
{}
    }
    //put TreeMap's keys in one Vector...
    final Vector keys = new Vector();
    for(Iterator e = dataX.keySet().iterator(); e.hasNext();) {
      keys.add(e.next());
    }
    //... and it's values in another
    final Vector data = new Vector(dataX.values());
    //now populate a JTable...
    AbstractTableModel dataModel = new AbstractTableModel() {
      public int getColumnCount() { return 2; }
      public int getRowCount() { return data.size();}
      public Object getValueAt(int row, int col) { return(col == 0 ?
keys.elementAt(row) : data.elementAt(row));}
      public String getColumnName(int column) {return (column == 0 ? "Keys"
: "Values");}
      public boolean isCellEditable(int row, int col) {return false;}
      public void setValueAt(Object aValue, int row, int column) { }
      public Class getColumnClass(int c) {return getValueAt(0,
c).getClass();}
    };
    JTable jt=new JTable(dataModel);
    JScrollPane jsp=new JScrollPane(jt);
    //...and show it in a dialog
    JOptionPane UIPane=null;
    JDialog UIDialog=null;
    if(UIPane==null)UIPane = new JOptionPane(jsp);
    if(UIDialog==null)UIDialog = UIPane.createDialog(null, "UI
Defaults...");
    UIDialog.show();
  }
Technical Details
Message-ID: <3a6f5470$1_2@dnews>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!bornews.borland.com!dnews!195.14.250.167
References: <94miun$odh5@bornews.inprise.com> <3a6edc71$1_2@dnews> <94muh9$ai11@bornews.inprise.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,e9ad02bd7857a1b
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2001-01-24 14:22:03 PST
From: "Torsten Welches" <torsten.welches@who.cares.netcologne.de>
Newsgroups: borland.public.jbuilder.java.swing
References: <94miun$odh5@bornews.inprise.com>  <3a6edc71$1_2@dnews> <94muh9$ai11@bornews.inprise.com>
Subject: Re: changing the language in JColorChooser and JFileChooser dialogs
Date: Wed, 24 Jan 2001 23:14:03 +0100
Lines: 56
X-Newsreader: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
NNTP-Posting-Host: 195.14.250.167
Message-ID: <3a6f5470$1_2@dnews>
X-Trace: 24 Jan 2001 14:17:20 -0800, 195.14.250.167
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!bornews.borland.com!dnews!195.14.250.167