Add an icon to a button

Hello ,
I'm working with eclipse to prgram mu project
I want to add for a button an icon and when I press this button this icon will be drawed.
this is my code :
import javax.swing.Icon ;
public class Fenetre extends JFrame
     Icon img = new Icon("medias/img1.gif");
public Fenetre ()
          super();
          this.setTitle("Menu");
          this.setSize(500,500);
          this.setLocationRelativeTo(null);
          this.setResizable(false);
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     JMenu initial = new JMenu (new InitialAction(this, "initial"));
initial.setIcon(img);
I am sorry for my english is bad :s

Na prima. Du hast in dem anderen Thread gute Antworten bekommen, also gibt es keinen Grund einen neuen Thread zu starten, obwohl dieses Forum für Deine Frage besser gewesen wäre. Ich mache hier mal dicht, wenn noch Fragen sind, stell sie in Deinem anderen Thread.
Gruß, Phil

Similar Messages

  • Add icon on spark button skin

    Hello all I am trying to add different icon on different buttons. I have my skin file ready but not sure if I have to create different skin class for different button. It sounds inefficient. Any suggestions? Thanks for the reply...
    <s:Button id="pass"
          width="110"
          height="35"
          fontWeight="bold"
              fontSize="12"
          fontFamily="arial"
          label="Past Track"
         click="pass_clickHandler(event)" skinClass="skins.CustomSkin"/>      
    <s:Button id="future"
          width="110"
          height="20"
          fontWeight="bold"
          fontSize="12"
          fontFamily="arial"
          label="Future Plan"
              click="future_clickHandler(event)"
              skinClass="skins.CustomSkin"/>
    Skin.....
       <!-- layer 2: fill -->
        <!--- @private -->
        <s:Rect id="fill" left="1" right="1" top="1" bottom="1" radiusX="2">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="#304fd7"
                                 color.over="#4b6bf6"
                                 color.down="0xAAAAAA"
                                 alpha="0.85" />
                <s:GradientEntry color="#1f38a3"
                                 color.over="#3653cf"
                                 color.down="0x929496"
                                 alpha="0.85" />
            </s:LinearGradient>
        </s:fill>
    </s:Rect>
    <!-- icon --> // I could add my icon here but that would make me to create 
                      //different icon image for different button

    so you could do something like this even though it doesn't have to be a required item.
        public class ImageButton extends Button
             *  The skin part that defines the area where
             *  the user may drag to resize the window.
            [SkinPart(required="true")]
            public var buttonImage:Object
    Then , in your skin you would have an mxml image with the same name ( buttonImage ) that you would position in the skin.  In the mxml where you use the class you could just do
    <custom:ImageButton id="ib" buttonImage="assets/myButton.jpg" />
    I must warn you though , skinning is not my specialty.
    If this post was helpful please mark it as such.
    Sincerely ,
      Ubu

  • Add an icon in JBuilder

    how can i add an icon to a button in JBuilder 4. the icon property for a button allways show <none>.

    Hello,
    Borland has several newsgroups on JBuilder-issues, maybe you can get more help there. Hava a look at http://www.borland.com/newsgroups/#jbuilder.
    Regards,
    Stefan

  • How to change an icon of a button

    hi guys,
    i want to change the icon of a button when it is click
    how can i do it?
    thanks

    You register a listener for that button, e.g.:
    button.addActionListener(new...)
    Then add code to the listener class:
    button.setIcon(new...)
    If you've not come across listeners yet though, you'll need to explore these a bit first.
    Andy.

  • How to add URL Icon for each responsibility

    Hi all,
    I have a requirement where i need to add URL Icon to my custom application, i,e when i click on responsibity it will open the application so to make user to know he is in this application we need to add ICON to URL. This is possible in normal HTML just we need to include these two lines in head tab.
    <link rel="icon" type="image/ico" href="favicon.ico"></link>
    <link rel="shortcut icon" href="favicon.ico"></link>
    How can we achieve the same in the OAF?
    Thanks
    Babu

    Hi Josephine
    Please proceed as below:
    1. SE51.
    2. Change the layout.
    3. Add 2 pushbuttons at your desired location.
    4. Double click on each button for Attributes.
    5. In the attributes, give the Name, Text.
    6. Select the Icon Name from the list: Eg: ICON_OKAY and ICON_CANCEL.
    7. Go back to layout.
    8. Save & Activate
    9. Now you can test the screen to check the icons displayed in the screen.
    Hope this helps.
    Kind Regards
    Eswar

  • How can I add an icon in the firefox toolbar to access to I.E. outlook express?

    I'd like to begin using Firefox as my default browser in place of O.E. 7. However, my Google mail account is programmed to feed e-mails to Outlook Express. I can find no way to add an icon to the Firefox toolbar to easily access Outlook Express.

    In my limited knowledge there is no way for a user to add an application to this list. You might try one of these two options.
    1. Use a utility like Cocktail or Onyx to reset the launch services database. This is the database that decides which applications get launched when a file is double clicked. It may be that the Endnote application didn't get recognized. However OS X decides what applications to add to the list based on files types.
    2. The easier solution is to select one of the files you wish to open with Endnote. Right click on the file and select Get Info. Under the "Open with" menu select Other... and navigate to the Endnote application and select it. Now click the Change all button. From now on when you double click your citation file it will automatically open with the Endnote application.

  • Why don't I have any add-on icons in my View|Toolbars|Customize box?

    I just installed several extensions to my new FF 5.0.1 and want to put their icons in a toolbar as I have in the FF3.6 on my other computer. But when I select View|Toolbars|Customize none of the add-on icons show up, except Ghostery.
    I installed these extensions from a clean install of FF 5 and they were all on the Available page and have release dates within the past few months. Are they not compatible with FF 5?
    The extensions are:
    Morning Coffee 1.35
    Print Edit 5.2
    Scrapbook Plus 1.8.20.34
    Whois 2.2

    As far as Print Edit goes, I see a "Print Edit" button in the Customize Palette, but I never use it. Right-click the web page and use Print > Print Preview or Print Edit or from the orange Firefox button Print > ....
    Sorry, I have never used the other three extensions, so I can't comment beyond saying the developers of all these extensions should be providing better usage instructions for their users.

  • Adding icon to a button

    Hello
    When I put a JButton on a frame I see in Property Inspector , Visial tab a icon section which it's follow is "<none>"
    how I can use it for adding a icon to the button
    my mean is I want add an icon to button by Property Inspector , but I don't know how I can do it
    can you say to me ?
    thanks

    Hi,
    I don't think the property inspector will help you adding the icon because it needs to be added from the class loader path. In an older JCLient Demo we used the following class
    public class ImageLoader
       public ImageLoader()
       public ImageIcon getImageIcon(String name)
          return new ImageIcon(getClass().getResource(name + ".gif"));
    }This then could be called when setting the icon to a JButton at runtime, passing the icon name to it
    Frank

  • "Add shortcut icon to my desktop" options

    I'm developing a AIR Application Online game where i have 1 Game Lobby AIR App (Flex-Based AIR) and games AIR App (Flash CS4 Built Swf, Create AIR file using Flex to load the Swf file).
    The game have only 1 Lobby(air file) and Numbers of games (air files). 
    Purpose to having multiple AIR file to make use of AIR auto updates features for the lobby and all games.
    I want to remove/unchecked "Add shortcut icon to my desktop" from the Installation Preferences of AIR Application Install dialogue.
    May i know how to do remove/unchecked "Add shortcut icon to my desktop" feature?.
    Thanks.

    Try This.
    Right click on the desktop >> create a new shortcut
    Type: C:\Windows\System32\cmd.exe /c start "" "skype:"
    Click Next
    Type: ModernSkype in Type a Name for this shortcut field.
    Then Click Finish.
    You now have a desktop shortcut to Skype app.
    You can create an icon for this shortcut.
    Log on to ICO converter
    Cick Choose File and search for .png in C:\Program Files\WindowsApps\Microsoft.SkypeApp_1.6.0.114_x86__kzf8qxf38zg5c\images\skypeSmall.targetsize-32.png
    Then Click Convert. New icon will be downloaded.
    Now Right click on ModernSkype desktop shortcut  and click Propeties then Click Change Icon and locate the downloaded icon file, Click OK.
    Regards,
    Tamim
    Location - Dhaka | Bangladesh - Standard Time Zone: GMT/UTC + 06:00 hour
    If one of my replies has adequately addressed your issue, please click on the “Accept as Solution” button. If you found a post useful then please "Give Kudos" at the bottom of my post, so that this information can benefit others.
    Attachments:
    Icon.zip ‏13 KB

  • Set Icon for toggle button

    I created Icon with Borderpane, image and text which I want to set as button icon.
    @Override
        public void start(Stage primaryStage)
            final VBox vbox = new VBox();
            // create 3 toggle buttons and a toogle group for them
            ToggleButton tb1 = new ToggleButton();
            tb1.setGraphic(newConnectionIcon());
            ToggleButton tb2 = new ToggleButton();
            ToggleButton tb3 = new ToggleButton();
            final ToggleGroup group = new ToggleGroup();
            tb1.setToggleGroup(group);
            tb2.setToggleGroup(group);
            tb3.setToggleGroup(group);
            // select the first button to start with
            group.selectToggle(tb1);
            final Rectangle rect1 = new Rectangle(300, 300);
            rect1.setFill(Color.DARKOLIVEGREEN);
            final Rectangle rect2 = new Rectangle(300, 300);
            rect2.setFill(Color.LAVENDER);
            final Rectangle rect3 = new Rectangle(300, 300);
            rect3.setFill(Color.LIGHTSLATEGREY);
            tb1.setUserData(rect1);
            tb2.setUserData(rect2);
            tb3.setUserData(rect3);
            group.selectedToggleProperty().addListener(new ChangeListener<Toggle>()
                @Override
                public void changed(ObservableValue<? extends Toggle> ov, Toggle toggle, Toggle new_toggle)
                    if (new_toggle == null)
                    else
                        vbox.getChildren().set(1, (Node) group.getSelectedToggle().getUserData());
            HBox hBox = new HBox();
            hBox.getChildren().addAll(tb1, tb2, tb3);
            hBox.setPadding(new Insets(10, 10, 10, 10));
            vbox.getChildren().addAll(hBox, (Node) group.getSelectedToggle().getUserData());
            StackPane root = new StackPane();
            root.getChildren().add(vbox);
            Scene scene = new Scene(root, 800, 850);
            primaryStage.setScene(scene);
            primaryStage.show();
        private static BorderPane newConnectionIcon() {
            // Add background effect
            DropShadow ds = new DropShadow();
            ds.setOffsetY(2.0);
            ds.setOffsetX(2.0);
            ds.setColor(Color.GRAY);
            // New BorderPane which will hold the components
            bpi = new BorderPane();
            bpi.setEffect(ds);  // Add the effect
            bpi.setCache(true);
            // Set the size of the BorderPane
            bpi.setPrefSize(30, 30);
            bpi.setMaxSize(30, 30);
            // Add style       
            bpi.setStyle("-fx-background-color: linear-gradient(#f2f2f2, #d4d4d4);"
                    + "  -fx-background-insets: 0 0 -1 0, 0, 1, 2;"
                    + "  -fx-background-radius: 3px, 3px, 2px, 1px;");
            // Add Label to the Icon
            Text inftx = new Text("New Connection");
            inftx.setFont(Font.font ("Verdana", 5));   // Set font and font size
            inftx.setFill(Color.WHITE); // Set font color
            ncpic.setFitHeight(25);    // Set size of the Icon picture
            ncpic.setFitWidth(25);
            // Internal StackPane which will hold the picture and the Icon Label
            StackPane stack = new StackPane();
            stack.getChildren().addAll(ncpic, inftx);   // Add the picture and the Label
            // Add the StackPane to the main BorderPane       
            bpi.setCenter(stack);
            // Change the border of the Icon when the mouse is over the Icon
            bpi = mouseOver(bpi);
            // Navigate to new Panel when the user clicks on the Icon
            bpi.setOnMouseClicked(new EventHandler<MouseEvent>() {
                @Override
                public void handle(MouseEvent t) {
            return bpi;
    How I can remove the default togglebutton and use the my custom icon as a button?

    Yes, they are icons and they are called "handles". The easiest way to change then is to use UIManager.
    If you haven't done so before, look through the hash table UIManager.getLookAndFeelDefaults().
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    public class TreeIcons {
         public static void main(String[] args) throws MalformedURLException {
              String prefix = "http://forum.java.sun.com/images/";
              UIManager.put("Tree.openIcon", new ImageIcon(new URL(prefix + "dont_save.gif")));
              UIManager.put("Tree.closedIcon", new ImageIcon(new URL(prefix + "save.gif")));
              UIManager.put("Tree.leafIcon", new ImageIcon(new URL(prefix + "forum_new.gif")));
              UIManager.put("Tree.expandedIcon", new ImageIcon(new URL(prefix + "email_faded.gif")));
              UIManager.put("Tree.collapsedIcon", new ImageIcon(new URL(prefix + "email.gif")));
              JFrame f = new JFrame("TreeIcons");
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.getContentPane().add(new JTree());
              f.setSize(new Dimension(300,400));
              f.setLocationRelativeTo(null);
              f.setVisible(true);
    }

  • Turning an icon into a button in a table

    Currently, I access a database in my program, and if I find an 'X' in a specific column, I place an icon in that field. What I would like to do is have that icon act as a button, that will pop up a screen with further information about the table line item. I am new at Java, and not sure what to do next.
    Here is the code for my table model:
    class sciTableModel extends javax.swing.table.DefaultTableModel
         public sciTableModel()
              super();
         public sciTableModel(java.util.Vector data, java.util.Vector columnNames)
              super(data, columnNames);
    and here is the code for my renderer
    class IconRenderer extends DefaultTableCellRenderer
         public Component getTableCellRendererComponent(JTable table,
         Object value, boolean isSelected, boolean hasFocus, int row, int column)
              ImageIcon iconl = new ImageIcon("info.gif");
              String headerText = (String)value;
              // System.out.println(headerText);
              JLabel headerComponent =
              ((JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column));
              headerComponent.setHorizontalAlignment(SwingConstants.CENTER);
              if (headerText != null)
                   headerComponent.setIcon(iconl);
                   headerComponent.setText("");
              else
                   headerComponent.setIcon(null);
                   headerComponent.setText(null);
              return headerComponent;
    In the public class I set the renderer, and in the actionevent that runs the database access I use the tablemodel.
    Any help on how I can turn this icon into a button would be appreciated.

    In A JTable, the render has the job of drawing one or more cells, but it's a rubber stamp -- it doesn't
    respond to events like a true component. What you describe isn't the job of an cell editor either,
    since, obviously, nothing is being edited. That leaves JTable itself: I suggest you write a mouse
    listener for your JTable and respond appropriately when the right cell is clicked:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test {
        public static void main(String[] args) {
            JTable table = new JTable(20, 5);
            table.addMouseListener(new MouseAdapter(){
                public void mousePressed(MouseEvent evt) {
                    JTable t = (JTable) evt.getSource();
                    Point point = evt.getPoint();
                    int col = t.columnAtPoint(point);
                    int row = t.rowAtPoint(point);
                    if (col != -1 && row != -1) {
                        int modelCol = t.convertColumnIndexToModel(col);
                        System.out.println("clicked on model cell (" + row + "," + modelCol + ")");
            JFrame f = new JFrame("Test");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new JScrollPane(table));
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }As the code demonstrates, don't forget to translate from view columns to model columns.
    By the way, why are you subclassing the default table model? You aren't changing any behavior...

  • CSS inspector lacks "Add Property" icon and "tree" format.

    This probably has a very simple solution, but here's the story: In all the tutorials, the CSS inspector window shows the CSS cascade formatted as a sort of tree, with lines connecting the various properties. When I open DreamWeaver, the inspector just shows the properties in a vertical column. Is there a way I can make it display the tree outline?
    Also, there's no "Add Properties" icon on my CSS inspector.
    I sincerely hope there's a quick fix for this.

    Assuming you have CSS style rules embedded in your page or the HTML document is linked to an external stylesheet, hit the ALL button.
    To add a new rule, hit the + sign.
    More on CS5 CSS Styles Panel.
    http://help.adobe.com/en_US/dreamweaver/cs/using/WSbb8fae38174aec9d-4fb84361126e2b2aaf3-80 00.html
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • Add-ons icons

    I want an Icon to put on any tool bar to enable me to show and hide Add-ons toolbar just by one click. Do U have any suggestions ?

    *Create a Toolbar
    *Add the ICONS you need
    *Right click on the Menu bar and Check/uncheck the toolbar
    For more
    *https://support.mozilla.org/en-US/kb/customize-firefox-controls-buttons-and-toolbars
    *https://addons.mozilla.org/en-us/firefox/addon/toolbar-buttons/
    *http://kb.mozillazine.org/Toolbar_customization_-_Firefox

  • Can't open another window in firefox and add-on icons won't show

    I had to do a system restore after downloading malware which avast stopped from activating. I downloaded Spybot and scanned/fixed various things it had identified but then my laptop wouldn't start in anything but safe mode. After I did the system restore, the malware and Spybot were gone, but Firefox crashed every time I tried to open it, so I had to use Internet Explorer to get online and download Firefox. Since then I have 2 problems: Firefox will only open in one window (it will let me open multiple tabs but only in one window) and my add-on icons (the Personas fox, the Greasemonkey monkey, the Boost for facebook infinity symbol, etc) won't appear on the bottom toolbar or browser bar as they always have, nor are they in the Tools drop-down menu as they always were. I can't get into Personas favorites at all either, despite having reinstalled the Personas Plus account twice. I assume that something causing these things happened when I did the system restore, as anything Spybot "fixed" should have been undone by the system restore? I have Vista 32-bit on a Dell Inspiron 1545 laptop. Please help!

    Hi narik121,
    So the build that you downloaded for CentOS 6.4, where did you download it from?
    There are some versions of Firefox that may have been compiled by third party providers for specific Linux builds. Mozilla does not host these builds. [[Install Firefox on Linux]] is the reference to the official code for Linux.

  • How can I add more than one submit button in a jsp without use of javascrip

    I want to add more than one submit button in a jsp without use of javascript

    you can do add multiple submit button with this way
    <input type="submit" value="Previous" />
    <input type="submit" value="Next" />
    <input type="submit" value="Finish" />

Maybe you are looking for