473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

An Experiment using Swings

I have implemented the following code :
-----------------------------------------------------------------------------------------------------------------
import javax.swing.*;
import java.awt.*;

public class FileChooseDemo{
public static void main(String args[])
{
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(new JFrame());
}
}
------------------------------------------------------------------------------------------------------------------
But my problem is that i want to implement the same with help of an applet so that i can use it in a browser , can anyone help me solve that and i've already written some code but it is not working...........check this modified code below:

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

public class FileChooseDemo extends JApplet{

public void init(){
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(new JFrame());
}

public static void main(String args[])
{
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
init();
}
});
}
}

}

/* <applet code="FileChooseDemo.class" height=400 width=400></applet>*/

help me please!
Nov 8 '06 #1
5 2796
r035198x
13,262 8TB
I have implemented the following code :
-----------------------------------------------------------------------------------------------------------------
import javax.swing.*;
import java.awt.*;

public class FileChooseDemo{
public static void main(String args[])
{
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(new JFrame());
}
}
------------------------------------------------------------------------------------------------------------------
But my problem is that i want to implement the same with help of an applet so that i can use it in a browser , can anyone help me solve that and i've already written some code but it is not working...........check this modified code below:

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

public class FileChooseDemo extends JApplet{

public void init(){
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(new JFrame());
}

public static void main(String args[])
{
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
init();
}
});
}
}

}

/* <applet code="FileChooseDemo.class" height=400 width=400></applet>*/

help me please!
What do you mean it is not working. You need to be more clear. While you are at it, you might want to look at applets and security.
Nov 8 '06 #2
What do you mean it is not working. You need to be more clear. While you are at it, you might want to look at applets and security.
I mean will it work with an applet or not?

First of all i want to clarify whether we could implement "JFileChooser" with applet or not?

Second ,if yes then how to implement that ?

Do my code make any sense ?
Nov 8 '06 #3
Problem solved but there is another problem......

the code in applet is not executing on my machine ... but it's fine on my colleagues machine .....

i'm using jdk1.4.1 and the other machine is running jdk1.6.0

the modified code is like this

import javax.swing.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.filechooser.*;
public class FileChooseDemo extends JApplet implements ActionListener
{
//JPanel p;
JButton b1;
JFileChooser chooser;
public void init(){

b1 = new JButton("vachay");
add(b1);
b1.addActionListener(this);
}

public void actionPerformed(ActionEvent ae)
{
chooser = new JFileChooser();
if(ae.getSource().equals(b1))
{
chooser.showOpenDialog(FileChooseDemo.this);
}
}
}



/* <applet code="FileChooseDemo.class" height=400 width=400></applet>*/

can u explain what could be the problem?
Nov 9 '06 #4
r035198x
13,262 8TB
Problem solved but there is another problem......

the code in applet is not executing on my machine ... but it's fine on my colleagues machine .....

i'm using jdk1.4.1 and the other machine is running jdk1.6.0

the modified code is like this

import javax.swing.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.filechooser.*;
public class FileChooseDemo extends JApplet implements ActionListener
{
//JPanel p;
JButton b1;
JFileChooser chooser;
public void init(){

b1 = new JButton("vachay");
add(b1);
b1.addActionListener(this);
}

public void actionPerformed(ActionEvent ae)
{
chooser = new JFileChooser();
if(ae.getSource().equals(b1))
{
chooser.showOpenDialog(FileChooseDemo.this);
}
}
}



/* <applet code="FileChooseDemo.class" height=400 width=400></applet>*/

can u explain what could be the problem?
When adding things to JFrames or Applets in 1.4, you use
getContentPane().add(item);
instead of just add
Nov 9 '06 #5
i already did that and after that i'm not able to handle event .. i.e., when i click the button
Nov 9 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

54
by: CoreyWhite | last post by:
The following experiment is a demonstration of TIME TRAVEL. When writing this program, and testing it out I found that sometimes the program would engage itself in time travel but other times it...
4
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of...
0
by: maverick19 | last post by:
Hi could any one give some references for pagination with caching in swings
11
by: ravindarjobs | last post by:
hi friends, i have just moved from vba to java. i am quite new to java. but unexpectedly i was given a task to build a chart for a table stored in oracle database. we have to use only swings...
1
by: better | last post by:
I want to take help for the Table Handling in java and the Trees handling. I am not having any clues about it. I just downlad a cuple of of books on it but they does not explain these things but just...
1
by: gaya3 | last post by:
Hi, I have craeted JTable in Swings.I would like to make the contents in that JTable as "hyper link". I have generated JTable as follows. String fields = {"col1", "col2"}; String data ={ ...
17
by: gaya3 | last post by:
hi, can any one please say me the equivalent for "\n" in Swings. because i'm having the data in JTable like For Example Apple Mango orange i need the output format like Apple mango
1
by: swatiawasthy | last post by:
hi i am developing a gui in java swings and i am getting my database displayed in jtable... i have a textfield labeled CUSTID and my table also has its sec column as CUSTID (which is not a primary...
34
by: vippstar | last post by:
On Nov 17, 1:43 pm, Ertugrul Söylemez <e...@ertes.dewrote: Well your blog entry starts with which is untrue and a bad way to start an article. Reading further, in your code...
2
by: satyabhaskar | last post by:
hi all, i want to know the perfect example where we can use only awt or we can use only swings in the GUI programming... can any plz clear my doubt thanks
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.