public class UploadImage extends JPanel { static File file=null; int index; JButton button; BufferedImage bi, bufferImage; int w, h;
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new UploadImage(); frame.getContentPane().add(panel); frame.setSize(300, 100); frame.setVisible(true); } public UploadImage(){ button=new JButton("Browse"); this.add(button); button.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ JFileChooser chooser = new JFileChooser(); chooser.addChoosableFileFilter(new ImageFileFilter()); int returnVal = chooser.showOpenDialog(null); if(returnVal == JFileChooser.APPROVE_OPTION) { file = chooser.getSelectedFile(); try{ bi = ImageIO.read(file); w = bi.getWidth(null); h = bi.getHeight(null); if (bi.getType() != BufferedImage.TYPE_INT_RGB) { BufferedImage bi2 = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics big = bi2.getGraphics(); big.drawImage(bi, 0, 0, null); bufferImage = bi = bi2; button.setVisible(true); } } catch(Exception ex){} } } }); } public Dimension getPreferredSize() { return new Dimension(w, h); } public void paint(Graphics g) { filterImage(); g.drawImage(bufferImage, 0, 0, null); } public void filterImage(){ BufferedImageOp op = null; switch (index){ case 0: bufferImage = bi; return; case 1: } bufferImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); op.filter(bi, bufferImage); } } class ImageFileFilter extends javax.swing.filechooser.FileFilter { public boolean accept(File file) { if (file.isDirectory()) return false; String name = file.getName().toLowerCase(); return (name.endsWith(".jpg") || name.endsWith(".png")|| name.endsWith(".gif")); } public String getDescription() { return "Images (*.gif,*.bmp, *.jpg, *.png )"; } } Thanks
Related Pages:
about swing - Java Beginners about swing how implement a program of adding two numbers by entering two numbers separately by other user on the input dialog box and after that also show the result of the addition in other dialog box...
your regardly
about java swing - Java Beginners aboutjavaswing How to upload the pictures and photo on the panel in javaswing ,plz help
thank a lot. Hi Friend,
Try the following code:
import java.awt.*;
import java.io.*;
import javax.swing.*;
import
about java swing - Java Beginners aboutjavaswing How to send date in data base if i use the combobox like as dd,mm,yyyy.
plz reply
thanx a lot Hi Friend,
Try the following code:
import java.sql.*;
import java.awt.*;
import javax.swing.
swing
swing Write a javaswing program to delete a selected record from a table
Swing
Swing Write a javaswing program to search the details of the students. Searching is performed on studentā??s first name. The details of all those students having same name as in given in searching criterion will be displayed
Swing
Swing Write a javaswing program to search the details of the students. Searching is performed on studentā??s first name. The details of all those students having same name as in given in searching criterion will be displayed
ABOUT Jtable ABOUT Jtable My Project is Exsice Management in javaswing Desktop Application.
I M Use Netbeans & Mysql .
How can retrive Data in Jtable from Mysql Database in Net Beans
Sitemap Java Swing Tutorial
-to-One Relationship |
JPA-QL Queries
JavaSwing Tutorial Section
JavaSwing Introduction |
Java 2D
API |
Data Transfer in JavaSwing |
Internationalization in JavaSwing |
Localization |
What
is javaswing
About jcombobox - Swing AWT About jcombobox Hi all,
I am new to this forum.
Can we do auto suggest jcombobox in swing? If yes is there any jar file for that or any code if you have.
Thanks in advance. Hi Friend,
Try the following code
about swings - Java Beginners
:
http://www.roseindia.net/java/example/java/swing/
Hope...about swings Dear sir,Good evening,
i am doing mca sir,i am doing the project in swings,so plz provide the material about swings sir
java swing problem - Java Beginners javaswing problem i doesn't know about the panel in swings here i had created one frame then created a panel and i added that to my frame but which is not adding any item and it not showing that item on the panel tell me how
JAVA SWING JTabbedPane - Java Beginners JAVASWING JTabbedPane Hi all,
I would like to ask a question about how to place a tab in JTabbedPane in the middle rather than from left... = makeTextPanel("Java Tutorial");
tabbedPane.addTab("One", icon, panel1, "Does
Swing Applet Example in java Java - Swing Applet Example in java
Introduction
In this section we will show you about using swing in an applet. In this example,
you will see that how resources of swing
What is Java Swing?
What is JavaSwing?
Here, you will know about the Javaswing. The JavaSwing provides... and GUIs components. All JavaSwing classes imports form the import
java swing - Swing AWT java swing how i can insert multiple cive me exampleolumn and row in one JList in swing?plz g Hi Friend,
Please clarify your question.
Thanks
Java swing Java swing what are the root classes of all classes in swing
Java swing Java swing Does Swing contains any heavy weight component
java swing java swing view the book details using swing
AutoSuggestion Box in Java Swing
Auto Suggestion Box in JavaSwing
In this section, you will learn how to create autosuggestion/autocomplete box in javaswing.
For this, we have created combo box and add array of countries using
DefaultComboBoxModel to it. Now
How to convert a swing form to PDF
How to convert a swing form to PDF Sir,
I want to know about how convert a swing form containing textbox,JTable,JPanel,JLabel, Seperator etc swing menus to a PDF file using java code
java swing java swing what is javaswingSwing is a principal GUI toolkit for the Java programming language. It is a part of the JFC (Java Foundation Classes), which is an API for providing a graphical user interface for Java
java swing java swing how to connect database with in grid view in javaswing
Hi Friend,
Please visit the following link:
Grid view in javaswing
Thanks
java swing - Swing AWT java swing how to add image in JPanel in Swing? Hi Friend,
Try the following code:
import java.awt.*;
import java.awt.image....:
http://www.roseindia.net/java/example/java/swing/
Thanks
java swing java swing add two integer variables and display the sum of them using javaswing
Java swing Java swing Write a javaswing program to calculate the age from given date of birth
java swing - Swing AWT javaswing how i can insert in JFrame in swing? Hi Friend,
Try the following code:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class FormDemo extends JFrame {
JButton ADD;
JPanel
java swing - Swing AWT javaswing Iam developing a java web browser.Actually my code works fine ie. i can load a web page without proxy.But in my place i have only proxy... a proxy or how to make my java web browser to listen to proxy setting??? please help
java swing. javaswing. Hi
How SetBounds is used in java programs.The values in the setBounds refer to what?
ie for example setBounds(30,30,30,30) and in that the four 30's refer to what
Java Swing Tutorials swing?
Here, you will know about the Javaswing. The JavaSwing provides...
In Java
In this section, you will learn about the event handling for a swing... JavaSwing Tutorials
 
Java swing
to the database using javaswing...Java swing I create one table. That table contains task ID and Task Name. When I click the task ID one more table will be open and that table
Java swing
are displayed in the table..I need the source code in javaswing...Java swing If i am login to open my account the textfield,textarea and button are displayed. if i am entering the time of the textfield
java swing - Swing AWT java swing how to save data in sql 2005 while insert in textfield Hi Friend,
Try the following code:
import java.sql.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import
Java swing Java swing how to create simple addition program using javaswing?
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class SumOfNumbers extends JFrame
{
SumOfNumbers(){
JLabel lab1=new
swing - Java Beginners Swing application testing What are the conventions for testing a Javaswing application
Swing Program Swing Program Write a javaswing program to calculate the age from given date of birth
Swing paint - Swing AWT
the Swing Applet, use html file with the following code:
Java Applet Demo...Swing paint hi,
i want to print something on window using swing applet..
m doing dis..
protected void paintComponent(Graphics g
Java swing Java swing when i enter the time into the textbox and activities into the textarea the datas saved into the database.the javaswing code for the above item
import java.sql.*;
import java.awt.*;
import javax.swing.
Java swing Java swing How to combine two java files
java swing java swing what is code for diplay on javaswing internal frame form MYSQL DB pls send
Here is a code of creating form on jinternalframe and connect to mysql.
import java.io.*;
import java.sql.*;
import java.awt.
Progress Bar in Java Swing
Progress Bar in JavaSwing
 ... in javaswing. This section shows you how the progress bar starts and stops....
The label display the information about the Downloading
process whether completed
swing program swing program Write a javaswing program to getname and email id. Display the message if email id contains the name of theuser
Java swing Java swing What method is used to specify a container's layout
Java swing Java swing What methods are used to get and set the text label displayed by a Button object
Java Swing Java Swing I want scroll bar in a frame is it possible? if it is possible means i want coding for that please send me a reply
How to save data - Swing AWT
);
frame.setVisible(true);
}
}
For more information on Swing visit to :
http://www.roseindia.net/java/example/java/swing/
Thanks...How to save data Hi,
I have a problem about how to save data
java swing java swing iam using my project text box, label , combobox and that the same time i want menubar and popmenu. plz give me code for this. i want immediately plz send me that code
java swing java swing iam using my project text box, label , combobox and that the same time i want menubar and popmenu. plz give me code for this. i want immediately plz send me that code