How to add icons on a button or any component in java

How to add icons on a button or any component in java

View Answers

October 14, 2008 at 4:16 PM

Hi,


import javax.swing.*;
import java.awt.*;

public class IconButtonDemo{
public static void main(String[] args){
JFrame frame = new JFrame("Icon on button");
JButton button = new JButton("Roseindia.net");
Icon imgicon = new ImageIcon("icon_confused.gif");
JPanel panel = new JPanel();
button.setIcon(imgicon);
panel.add(button);
frame.add(panel, BorderLayout.NORTH);
frame.setSize(400, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

------------------------------------------

Visit for more information.

http://www.roseindia.net/java/example/java/swing/

Thanks.









Related Tutorials/Questions & Answers:
How to add icons on a button or any component in java - Java Beginners
How to add icons on a button or any component in java  How to add icons on a button or any component in java?  Hi, import... main(String[] args){ JFrame frame = new JFrame("Icon on button
Icons - Java Beginners
Icons  How to add icons on button and on a label   Hi friend, Please specify the problem in details. Thanks
Advertisements
how to add components (like button , checkbox etc) in a table column in core java
how to add components (like button , checkbox etc) in a table column in core java  plz tell me how to add components(like button, checkbox, radiobutton etc)in a table column in core java
how to add a update button in the following jsp
how to add a update button in the following jsp  Once the excel from the following jsp is loaded to the broswer, how to add a button in the jsp to allow the user to update the excel? thanks, <%@page import="java.io.*"%>
how to add save,discard,& cancel button in a message box - Struts
how to add save,discard,& cancel button in a message box  how to add save,discard,& cancel button in a message box
How to add a columns with a button set to a Jtable built with database result set
How to add a columns with a button set to a Jtable built with database result..., there should be another button to get further details of a account such as transactions... that button column to the table which is built with database result set. i would thank
How to add radio button value in a table for particular field?
How to add radio button value in a table for particular field?  Hi,I... dynamically from other table and two radio button one for present and the second... one radio button for text field then it insert only one value absent OR present
dynamicly add component to jsf page.
dynamicly add component to jsf page.  i want display image or text from database on jsf page. so i want to add components dynamicly. how am i do this. thanks for answers...   Please visit the following link: http
uinavigationcontroller add right button
uinavigationcontroller add right button  Hi, How to add the right button programatically to a UINavigation Controller? Thanks   Hi, You can use the following code: - (void)viewDidLoad { [super viewDidLoad
Java component
Java component  What is the preferred size of a component
How to find java jobs at any where in india
How to find java jobs at any where in india   Hi, I want information about java related jobs in india.where can i find that details
How to call java method on Button click in jsp?
How to call java method on Button click in jsp?  How to call java method on Button click in jsp
Selecting a Radio Button component in Java
Selecting a Radio Button component in Java       In this section, you will learn how to set the radio... on any radio button from a ButtonGroup the text of the selected radio button
how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers
how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers  how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers
Creating Flex ActionScript Custom Component extending Button
; } Creating Flex ActionScript Custom Component extending Button  ...,  a custom button component is created by extending Button class.  ...;. This indicates that the prefix CompRI will be used to refer any component
Write an applet program to transfer the content of the text field into the component on clicking a button
Write an applet program to transfer the content of the text field into the component on clicking a button  Write an applet program to transfer the content of the text field into the component on clicking a button
Create a JRadioButton Component in Java
Create a JRadioButton Component in Java   ... button in java swing. Radio Button is like check box. Differences between check... it once. Here, you will see the JRadioButton component creation procedure in java
add button to the frame - Swing AWT
add button to the frame  i want to add button at the bottom...); JScrollPane scrollPane = new JScrollPane(table); frame.getContentPane().add... JFrame implements ActionListener { JButton button = new JButton("Button
Container or Component - Java Beginners
about the realtionship between Components and Containers in Java GUI? 1) a component is a subclass of a container which means any container can hold a component 2) a component is allowed to hold other components including containers. 3
How to Hide Button using Java Swing
How to Hide Button using Java Swing  Hi, I just begin to learn java programming. How to hide the button in Java programming. Please anyone suggest... Programming application how to hide the buttons using Java Swing. Please Visit
how to add to numbers in java
how to add to numbers in java  how to add to numbers in java
Java component class
Java component class  Which method of the Component class is used to set the position and size of a component
com.craterdog.maven-parent-poms - java-component version 3.21 Maven dependency. How to use java-component version 3.21 in pom.xml?
of java-component in pom.xml? How to use java-component version 3.21...com.craterdog.maven-parent-poms  - Version 3.21 of java-component Maven... com.craterdog.maven-parent-poms  - Version 3.21 of java-component in project
How to add BigDecimal in Java?
How to add BigDecimal in Java?  Hi, I have two BigDecimal variables. I want to add these two values. How to add BigDecimal in Java? Thanks   Hello, I will show you how you can add two BigDecimal? Suppose you have
How to solve button problem - Java Beginners
How to solve button problem  I have created button (Open File Dialog) , List, JTabbedpane and MenuBar . By clicking btnBrowse button I am getting... equal space So button size also increasing. Could you please guide me how
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA24 is released. Learn to use fx-icons version 0.17-BETA24 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA24 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA24 java library
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA24.1 is released. Learn to use fx-icons version 0.17-BETA24.1 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA24.1 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons...-icons released The developers of   com.dua3.fx - fx-icons project have
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA25 is released. Learn to use fx-icons version 0.17-BETA25 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA25 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA25 java library
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA26 is released. Learn to use fx-icons version 0.17-BETA26 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA26 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA26 java library
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA27 is released. Learn to use fx-icons version 0.17-BETA27 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA27 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA27 java library
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA23.2 is released. Learn to use fx-icons version 0.17-BETA23.2 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA23.2 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons...-icons released The developers of   com.dua3.fx - fx-icons project have
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA17 is released. Learn to use fx-icons version 0.17-BETA17 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA17 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA17 java library
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA23.1 is released. Learn to use fx-icons version 0.17-BETA23.1 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA23.1 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons...-icons released The developers of   com.dua3.fx - fx-icons project have
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA23 is released. Learn to use fx-icons version 0.17-BETA23 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA23 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA23 java library
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA22 is released. Learn to use fx-icons version 0.17-BETA22 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA22 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA22 java library
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA21 is released. Learn to use fx-icons version 0.17-BETA21 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA21 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA21 java library
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA20 is released. Learn to use fx-icons version 0.17-BETA20 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA20 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA20 java library
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA19 is released. Learn to use fx-icons version 0.17-BETA19 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA19 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA19 java library
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA18 is released. Learn to use fx-icons version 0.17-BETA18 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA18 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA18 java library
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA16 is released. Learn to use fx-icons version 0.17-BETA16 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA16 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA16 java library
Maven dependency for com.dua3.fx - fx-icons version 0.21.1 is released. Learn to use fx-icons version 0.21.1 in Maven based Java projects
( com.dua3.fx - fx-icons version 0.21.1 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons version 0.21.1 in project? Steps to use  com.dua3.fx - fx-icons version 0.21.1 in Java projects
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA15 is released. Learn to use fx-icons version 0.17-BETA15 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA15 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA15 java library
Maven dependency for com.dua3.fx - fx-icons version 0.17.0 is released. Learn to use fx-icons version 0.17.0 in Maven based Java projects
( com.dua3.fx - fx-icons version 0.17.0 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons version 0.17.0 in project? Steps to use  com.dua3.fx - fx-icons version 0.17.0 in Java projects
Maven dependency for com.dua3.fx - fx-icons version 0.17.0-RC8 is released. Learn to use fx-icons version 0.17.0-RC8 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17.0-RC8 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons version... and includes  com.dua3.fx - fx-icons version 0.17.0-RC8 java library in your
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA11 is released. Learn to use fx-icons version 0.17-BETA11 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA11 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA11 java library
Maven dependency for com.dua3.fx - fx-icons version 0.19.0 is released. Learn to use fx-icons version 0.19.0 in Maven based Java projects
( com.dua3.fx - fx-icons version 0.19.0 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons version 0.19.0 in project? Steps to use  com.dua3.fx - fx-icons version 0.19.0 in Java projects
Maven dependency for com.dua3.fx - fx-icons version 0.18.1 is released. Learn to use fx-icons version 0.18.1 in Maven based Java projects
( com.dua3.fx - fx-icons version 0.18.1 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons version 0.18.1 in project? Steps to use  com.dua3.fx - fx-icons version 0.18.1 in Java projects
Maven dependency for com.dua3.fx - fx-icons version 0.18.0 is released. Learn to use fx-icons version 0.18.0 in Maven based Java projects
( com.dua3.fx - fx-icons version 0.18.0 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons version 0.18.0 in project? Steps to use  com.dua3.fx - fx-icons version 0.18.0 in Java projects
Maven dependency for com.dua3.fx - fx-icons version 0.18.0-RC1 is released. Learn to use fx-icons version 0.18.0-RC1 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.18.0-RC1 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons version... and includes  com.dua3.fx - fx-icons version 0.18.0-RC1 java library in your
Maven dependency for com.dua3.fx - fx-icons version 0.17-BETA10 is released. Learn to use fx-icons version 0.17-BETA10 in Maven based Java projects
this version ( com.dua3.fx - fx-icons version 0.17-BETA10 ) in their Java project if it is based on Maven and Gradle. How to use  com.dua3.fx - fx-icons... and includes  com.dua3.fx - fx-icons version 0.17-BETA10 java library

Ads