Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1273

How do you set an Icon in

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Phil Powell" <phil.powell@THRWHITE.remove-dii-this>
Subject How do you set an Icon in
Message-ID <1174578176.010750.176730@l77g2000hsb.googlegroups.com> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 50
Date Wed, 27 Apr 2011 15:32:21 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918341 96.60.20.240 (Wed, 27 Apr 2011 10:32:21 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:32:21 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:1273

Show key headers only | View raw


  To: comp.lang.java.gui
I thought my method would handle this dynamically, but I was way off:

[code]
       /**
         * Handle {@link javax.swing.JButton}
         * @param button {@link javax.swing.JButton}
         */
        private void handleButton(JButton button) {
            try {
                String text = button.getText();
                ImageIcon icon = new ImageIcon(
 
System.getProperty("com.ppowell.applications.globals.rockpaperscissorsglobals.SRC_PATH")
+
 
FileFunctionality.buildFilePath(RockPaperScissorsGlobals.IMAGE_PATH_ARRAY,
true) /* EXCLUDE 1 BACKSLASH */ +
                        File.separator +
                        button.getText().toLowerCase().trim() +
".ico");
                button = new JButton(text, icon);
                Dimension dim = new Dimension(icon.getIconWidth(),
icon.getIconHeight());
                button.setSize(dim);
                button.setPreferredSize(dim);
                button.setMaximumSize(dim);
            } catch (Exception e) {
                e.printStackTrace();
            }
            button.setFocusable(false);
            button.setSelected(false);
            button.addActionListener(RockPaperScissors.this);
            button.setMnemonic(button.getText().charAt(0));
            button.setFont(RockPaperScissorsGlobals.FONT);
        }
[/code]

Instead I see JButtons with no icons, looking dead normal, and worse,
setFocusable(false) is ignored; the JButtons look like they've been
clicked!

What did I do so wrong this time?
Thanx
Phil

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextNext in thread | Find similar | Unroll thread


Thread

How do you set an Icon in "Phil Powell" <phil.powell@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: How do you set an Ico "Ian Wilson" <ian.wilson@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
    Re: How do you set an Ico "Phil Powell" <phil.powell@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000

csiph-web