Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners How to add icons on a button or any component in java

Have Programming Question? Ask it here!
 
 
 


tarun1
How to add icons on a button or any component in java
1 Answer(s)      5 years and 10 months ago
Posted in : Java Beginners



Advertisement
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 to numbers in java
how to add to numbers in java  how to add to numbers in java
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
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
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
how to add database in Java Applet
how to add database in Java Applet  hi every java master or Java Professional my name is vincent i'm java beginners hope u all can ,tech me how to add database in Java Applet below this code is my applet source code . thank
Java component
Java component  What is the preferred size of a component
How to add dynamic table in java
How to add dynamic table in java  How to add dynamic table in java   import java.awt.*; import java.sql.*; import java.util.*; import javax.swing.*; import java.awt.event.*; import javax.swing.table.*; public class
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 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 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
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
How to add
How to add   Hi, I want to make a website which will recommend users... to be viewed after clicking a link/button/whatever mentioning -"Next 10 recommendations". Please tell me what code should I use. Or is there any workaround
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
how to add date and change date in java - netbeans
how to add date and change date in java - netbeans  I need to code use to increase date How to get date after 30 days using netbeans
Buttons with Icons
Java: Buttons with Icons You can create buttons that show text, icons... with Icons on it.   Different images can be associated with different button... It is common to show different icons when the button is disabled, the mouse is over
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
struts2 how can we add an radio button to form using a class(doa)
struts2 how can we add an radio button to form using a class(doa)  Hi I had created an class of subscription,and iam trying to add an radio button on the registration form how to do plz help me out here is my code model
struts2 how can we add an radio button to form using a class(doa)
struts2 how can we add an radio button to form using a class(doa)  Hi I had created an class of subscription,and iam trying to add an radio button on the registration form how to do plz help me out here is my code model
How to Add JComboBox on JPanel - Java Beginners
How to Add JComboBox on JPanel  How to Add JComboBox on JPanel D:\java>javac ViewElements.java ViewElements.java:181: expected...(){ JFrame f = new JFrame("Frame in Java Swing"); f.getContentPane().setLayout(null
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
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 Create any type of Reports in Java - Java Beginners
How to Create any type of Reports in Java  Hello Sir ,How I can create any type of Reports like Crystal Reports etc(Student Result Report) in Java Application,plz Help Me Sir
Icons - MobileApplications
Icons  I want to create one folder in j2me for storing images.How to create it and how to allocate memory for that folder
Java component class
Java component class  Which method of the Component class is used to set the position and size of a component
Creating Flex ActionScript Custom Component extending Button
; } Creating Flex ActionScript Custom Component extending Button  ...,  a custom button component is created by extending Button class.  ... CompRI will be used to refer any component in mycomp package.  
JSlider Component of Java Swing
JSlider Component of Java Swing       In this section, you will learn how to create a JSlider component of Java Swing. A Slider is a Swing tool which you can use for selecting
Changing the Label of a JButton Component in Java
Changing the Label of a JButton Component in Java       This section illustrates you how to change the label of a button in java swing. JButton is the component of javax.swing.
How to add java bean in Java Application - Java Beginners
How to add java bean in Java Application  How can it be possible to plug a java bean into a target application like a frame window after creating and making the jar file. pabitra Guwahati.Assam  Hi Friend, Please
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
How to add a file in GZIP file format in Java programme.
How to add a file in GZIP file format in Java programme.  Hi please help me. How to add a file GZIP File format in Java program. If example..., This is the example and suggest link that will help you related to how to add the file
Making a component drag gable in java
Making a Component Draggable in Java       In this section, you will learn how to make a component draggable in java. This program provides the drag and drop feature from one
How to access Widows" Add/Remove Programs List"? - Java Beginners
How to access Widows" Add/Remove Programs List"?  Dear Friends, How to access the Windows' Add/Remove Program List? Is there any special jar to add for acccessing it? Kindly provide me the solution.... Thanks & Regards
how to add a file in GZIP
how to add a file in GZIP  Hi, how to add a file in GZIP using Java.   Hi, I have found a good referral site for How to Add a file in GZIP file format using Java. http://www.roseindia.net/java/examples/io
how to print JInternal frame component ?
how to print JInternal frame component ?  hello sir, i devalop a swing application .but problem is that how display report & print it. some data prefech from database & keep to jtable but how it is print with table
How to add JTable in JPanel
How to add JTable in JPanel  How to add JTable in JPanel
How can you add elements of two arrayLists in java?
How can you add elements of two arrayLists in java?  if you have an arrayList of tempArr = [hi, my, name, is, john] and another arrayList..., is d, john e] how do you go about
Component gui - Java Beginners
Component gui  Can you give me an example of Dialog in java Graphical user interface?  Hi friend, import javax.swing.*; public...://www.roseindia.net/java/example/java/swing/ Thanks
button in java
button in java  how can i compare names of two buttons after...) { System.out.println("button clicked"); } } Thanks   Hi...); p.add(b2); add(p); setVisible(true); pack
Create a JList Component in Java
Create a JList Component in Java       In this section, you will learn how to create a JList... easily add or remove items from or to the JList component of swing. The JList
how to add mulitiple projections
how to add mulitiple projections  how to add mulitiple projections and return them
how to add dynamic data
how to add dynamic data  how to add dynamic data to an existing web application
How will you add panel to a frame? - Java Interview Questions
How will you add panel to a frame?   How will you add panel to a frame?   you can simply use add method to add panel to a frame i.e panelA.add(frameA)  Hi Friend, Using add() method of JFrame. import
how to add two object in a particular file - Java Beginners
how to add two object in a particular file  Hi frend.. I have two arraylist object in which there is some data..............now i want to add these two objects in a particular file using file handling in java....and also
How do we create custom component
How do we create custom component  How do we create custom component in JSF. I couldnot find any category for JSF questions
Advertisements
 

 

 

DMCA.com