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


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

icon image on JToolBar

From "jr" <jr@THRWHITE.remove-dii-this>
Subject icon image on JToolBar
Message-ID <1175703258.865849.254000@e65g2000hsc.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:33 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Hi, I'm working on an application that uses a toolbar. I have written
the code below. My problem is that the icons that I'm using are of
different sizes that's why the the toolbar doesn't look so good. Is
there a way to make the buttons of the same sizes? Thanks..

JToolBar toolBar = new JToolBar("Tool Bar");

JButton insert, delete;

ImageIcon insertB = createImageIcon("images/open.gif");
insert = new JButton(insertB);
toolBar.add(insert);

ImageIcon deleteB = createImageIcon("images/delete.gif");
delete = new JButton(deleteB);
toolBar.add(delete);


protected static ImageIcon createImageIcon(String path) {
        java.net.URL imgURL = SSFriend.class.getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL);
        }
        else {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
    }

---
 * 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

icon image on JToolBar "jr" <jr@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
  Re: icon image on JToolBa "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000
  Re: icon image on JToolBa "Ed Tidwell" <ed.tidwell@THRWHITE.remove-dii-this> - 2011-04-27 15:33 +0000

csiph-web