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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Rahul Dubey
Add a fram
1 Answer(s)      a year and 11 months ago
Posted in : Swing AWT


I want to put an image on frame on my GUI(Net Beans).please tell me the way to put this. only for frame..

thanks and regards, Rahul Dubey


Advertisement
View Answers

December 4, 2012 at 11:04 AM


Here is an example that displays an image on jframe.

import java.awt.*;
import java.io.*;
import javax.swing.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;

public class DisplayImage extends JPanel {
BufferedImage image;
DisplayImage(){
String f="c:/fruit.png";
File file = new File(f);
try{
image = ImageIO.read(file);
}
catch(Exception ex){}
repaint();
}
public void paint(Graphics g) {
g.drawImage( image, 0, 0, null);

}
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel p=new DisplayImage();
frame.add(p);
frame.setSize(300, 300);
frame.setVisible(true);
}
}


Related Tutorials/Questions & Answers:
Add a fram
Add a fram  I want to put an image on frame on my GUI(Net Beans).please tell me the way to put this. only for frame.. thanks and regards, Rahul Dubey   Here is an example that displays an image on jframe. import
how to convert java fram to java servlets
how to convert java fram to java servlets   hi every java master or java professional can you teach me how to convert JFram to Java Servlets program hope yours can reply me Thank you. below this is my own coding import
Advertisements
add
How to add two numbers in Java  add two number   Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers { public static void main(String[] args
add
add two no in Java  Java Add Example that accepts two integer from the user and find their sum  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers
add
How to add two int numbers in Java Example  How to add two int numbers in Java Example  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers
add
Java Example to add two numbers  Java Example to add two numbers  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers { public static void main
add
Java Program to add two numbers  Java Program to add two numbers  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers { public static void main
Add Employee
Add Employee  coding for adding an employee
add to cart
add to cart  sir, i want to do add to cart to my shopping application each user using sessions. Plz help thnaks in advance
add
How to add
How to add   Hi, I want to make a website which will recommend users books according to the genre selected by them. I am using PHP, JavaScript and mySQL. The problem is that there will me almost more than 100 books
add uibarbuttonitem to uinavigationbar
add uibarbuttonitem to uinavigationbar  add uibarbuttonitem to uinavigationbar
Add multiple UIBarButtonItem
Add multiple UIBarButtonItem  add multiple uibarbuttonitem
How to add JTable in JPanel
How to add JTable in JPanel  How to add JTable in JPanel
how to add to numbers in java
how to add to numbers in java  how to add to numbers in java
uinavigationcontroller add multiple buttons
uinavigationcontroller add multiple buttons  How to add multiple buttons to the UINavigationController
add new package java
add new package java  How to add new package in Java
sql add comment to column
sql add comment to column  Sql query to add comments to column
uiscrollview add images
uiscrollview add images  How to add dynamic images to UIScrollView
add Buttons in JavaScript
add Buttons in JavaScript  How to add Buttons in JavaScript
how to add mulitiple projections
how to add mulitiple projections  how to add mulitiple projections and return them
Sql add columns
Sql add columns  How to add columns before existing columns. please help me out
add a property to instance variable
add a property to instance variable  How to add a property to instance variable in iPhone SDK
how to add dynamic data
how to add dynamic data  how to add dynamic data to an existing web application
ADD ROW - JSP-Servlet
ADD ROW  Hi Sir, How to use add row and delete row concept in jsp .  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/add-element.shtml Thanks
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
Add as a friend - JSP-Servlet
Add as a friend  in chat project how we send a request to add as a friend and how other peaple add me in his friend list. i want jsp-servlet and java code also.\plz.. help me on this topic
add XMl to JTable
add XMl to JTable  Hi.. i saw the program of adding add XMl to JTable using DOM parser,but i need to do that in JAXB ,is it possible to do? help me
Add UITabbarController to a View
Add UITabbarController to a View  How to add a UITabbarController to UIView in iPhone SDK?   iPhone TabBar Application Tutorial   iPhone TabBar Application Tutorial
Add a root element
Add a root element  i have one doubt, This is my current xml doc. ? But I want add a tag at first and last line of a xml by using JDOM(SAX Builder). Like
add imageview to uiview
add imageview to uiview  i want to add an image to UIView background...:[UIImage imageNamed:@"imageName.png"]];    You need to add a UIImageView to UIView Add an Image or Image URL to your ImageView. Code: UIImageView
 

 

 

DMCA.com