Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / June 2005

Tip: Looking for answers? Try searching our database.

help needed in swing

Thread view: 
rg.iitk@gmail.com - 18 Jun 2005 21:02 GMT
I am writing a swing program which basically writes the content of a
text area when a button is pressed, it seems to me the code is correct
but i get the following exception at when i press the button execute.
The code follows the error snippet, look into TextInputPanel class for
the relevant part.

ERROR---------
Exception in thread "AWT-EventQueue-1"
java.security.AccessControlException: access denied
(java.io.FilePermission abc.txt write)
       at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
       at
java.security.AccessController.checkPermission(AccessController.java:427)
       at
java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
       at
java.lang.SecurityManager.checkWrite(SecurityManager.java:962)
       at java.io.FileOutputStream.<init>(FileOutputStream.java:169)
       at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
       at TextInputPanel.actionPerformed(InputPanel.java:41)
       at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
       at
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
       at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
       at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
       at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
       at java.awt.Component.processMouseEvent(Component.java:5488)
       at
javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
       at java.awt.Component.processEvent(Component.java:5253)
       at java.awt.Container.processEvent(Container.java:1966)
       at java.awt.Component.dispatchEventImpl(Component.java:3955)
       at java.awt.Container.dispatchEventImpl(Container.java:2024)
       at java.awt.Component.dispatchEvent(Component.java:3803)
       at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
       at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
       at
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
       at java.awt.Container.dispatchEventImpl(Container.java:2010)
       at java.awt.Component.dispatchEvent(Component.java:3803)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
       at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
       at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
       at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
       at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
       at
java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

CODE
-------------------------------

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

public class InputPanel extends JApplet
{

    public  void init()
    {
        JTabbedPane jtp= new JTabbedPane();
        jtp.addTab("TextInput", new TextInputPanel());
        jtp.addTab("PathInput", new PathInputPanel());
        getContentPane().add(jtp);

    }

}
class TextInputPanel extends JPanel implements ActionListener
{
   JTextField jtf1=new JTextField("Enter the name of the file to be
created");
    JTextArea jta= new JTextArea(32,30);

   public TextInputPanel()
   {
    JLabel jl=new JLabel("Enter the text for conversion here in the space
provided",JLabel.CENTER);
    add(jl);
    jta.setLineWrap(true);
    add(jta);
    JButton jb= new JButton("Execute");

    jb.addActionListener(this);
    add(jb);
    add(jtf1);
   }
   public void actionPerformed(ActionEvent ae)
   {
    String s= jtf1.getText();
    String s1=jta.getText();
    try
    {
        FileOutputStream fout= new FileOutputStream(s);
        OutputStreamWriter bw= new OutputStreamWriter(fout);
        bw.write(s1);
        bw.close();
        fout.close();
    }catch(FileNotFoundException e)
    {
        System.out.println("Unable to open the file");
    }
    catch(IOException e)
    {
        System.out.println("File Error");
    };
   }
}
class PathInputPanel extends JPanel
{
   public PathInputPanel()
   {
    JLabel jl=new JLabel("Enter the path for the text file in the space
provided",JLabel.CENTER);
    add(jl);
    JTextField jtf= new JTextField();
    jtf.setHorizontalAlignment(JTextField.LEFT);
    add(jtf);
       
   }
}
Andrew Thompson - 18 Jun 2005 21:14 GMT
> I am writing a swing program ..

[1]

> java.security.AccessControlException: access denied
...
>  public class InputPanel extends JApplet

[1]  An Applet, as distinct from an application, therefore..
<http://www.physci.org/codes/javafaq.jsp#security>

To free your aplet from the applet security sandbox, either
jar and sign it, or adjust the browser's security settings
to allow your applet to run (the latter is only really
suited to testing purposes).

HTH

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Rohit Gupta - 18 Jun 2005 23:50 GMT
Im using jdk1.5, I dont have anything like javakey so how am i going to
sign the applets.
Andrew Thompson - 19 Jun 2005 06:49 GMT
> Im using jdk1.5, I dont have anything like javakey so how am i going to
> sign the applets.

To sign a Java applet, you only need the basic
Java tools provided by Sun, and reading lots
of documentation.

My PhySci software suite is digitally signed using
a 'self signed' certificate I created, it cost '$0'.

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Andrey Kuznetsov - 19 Jun 2005 20:50 GMT
> My PhySci software suite is digitally signed using
> a 'self signed' certificate I created, it cost '$0'.

you can also use thawte email certificate - it cost also '$0'

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Andrew Thompson - 19 Jun 2005 21:30 GMT
>> My PhySci software suite is digitally signed using
>> a 'self signed' certificate I created, it cost '$0'.
>
> you can also use thawte email certificate - it cost also '$0'

Huhh?  Last time I checked there seemed to be either a lot
of red tape or ..something (it was a long time ago).

Do you actually know someone that has got one of these 0
cost certificates?  I would like some more details if so.
( How hard to get?  Do you have to sign your soul away?
Restrictions on distribution?  Constant renewal required? )

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Andrey Kuznetsov - 20 Jun 2005 11:11 GMT
> Do you actually know someone that has got one of these 0
> cost certificates?
yeah, I got such one.

> I would like some more details if so.
you'll find very good guide how to do it here:
http://www.dallaway.com/acad/webstart/

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Andrew Thompson - 20 Jun 2005 11:17 GMT
(Security certificates..)
>> ..($)0 cost certificates?
..
> you'll find very good guide how to do it here:
> http://www.dallaway.com/acad/webstart/

Thanks!  I'll check it out.

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Andrey Kuznetsov - 20 Jun 2005 11:58 GMT
>> you'll find very good guide how to do it here:
>> http://www.dallaway.com/acad/webstart/
>
> Thanks!  I'll check it out.

np

Andrew, if you like you can vote for
JGui (categorie Best Java Component)
and Unified I/O (categorie Best Java Class Library)
at http://jdj.sys-con.com/general/readerschoice.htm

I have only 10 days to get the first place ;-)

Cheers

Andrey

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Andrew Thompson - 20 Jun 2005 12:39 GMT
> Andrew, if you like you can vote for
> JGui (categorie Best Java Component)
> and Unified I/O (categorie Best Java Class Library)
> at http://jdj.sys-con.com/general/readerschoice.htm

..hmm - seems you have your work cut out beating that
'Oracle ADF Business Components'!  Though you have a good
shot at beating QuickServer or JDock.

And ..wow - people seem to really like SWT 3.0.

But then, is it really valid to compare between
'Java Class Libraries' in general?

After all, me thinks - "API for interrogating arcane
aspects of entomology in the Amazon basin" - will
always lose out to "API for free nude pics".

Or to put that a more sensible way, the popularity
of an API is mostly attributable to just how many
developers need/use that area of functionality.
Only comparisons between API's that do similar things
would seem to be of relevance.

[ So it will be interesting to see how your JGui does against
the (assumedly similar areas) - JDock from APISoft or your
Unified IO does against the IBM (a heavyweight there!)
offering 'Asynchronous IO' (are they close in functionality?)  ]

Unfortunately though, I am not really familiar enough with
any of the listed components/API's to comment.

I have played with your Imagero (image) API a bit, as that
is of greater interest to me (I like it - very powerful),
though I haven't had a chance to look at Unified I/O yet.
Sorry.

> I have only 10 days to get the first place ;-)

All the best.   :-)

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Andrey Kuznetsov - 20 Jun 2005 15:24 GMT
> But then, is it really valid to compare between
> 'Java Class Libraries' in general?

this system is a bit stupid and not really objective.
You can't compare things which are uncomparable,
like a Swing components and J2EE components.

Who can tell me why this products has so much votes:
A. Java Date Picker has more votes then JIDEsoft(!)
B. Components! JavaBeans has 119 votes.
Although "Components! JavaBeans" sounds good,
they contains actually only Calender and Calculator!

> I have played with your Imagero (image) API a bit,
now much more features!
see http://reader.imagero.com/tutorial.html

> as that
> is of greater interest to me (I like it - very powerful),
> though I haven't had a chance to look at Unified I/O yet.
this is the I/O basis for Imagero Reader.
Makes (programmer's) life much easier.

> or your
> Unified IO does against the IBM (a heavyweight there!)
> offering 'Asynchronous IO' (are they close in functionality?)  ]
no, however it is unclear why IBM offers "Asynchronous IO"
after SUN introduced NIO (which also supports non blocking IO).

Unified I/O is just a decorator over standard java I/O,
however it can gain much speed, because of intelligent buffering,
configurable memory management and (new - beta) open files management
(i.e. you can read 10000 files simultaneously,
although your OS allows to have only 2000 open files )

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Andrew Thompson - 20 Jun 2005 15:36 GMT
>>  ..the IBM .. offering 'Asynchronous IO' ...

> ..it is unclear why IBM offers "Asynchronous IO"
> after SUN introduced NIO (which also supports non blocking IO).

<being a wag (as opposed to taking a WAG)>
..maybe they got a lot of votes from email's like
sue1218@noconnectionwith.ibm.com    ;-)
</being a wag (as opposed to taking a WAG)>

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Andrey Kuznetsov - 20 Jun 2005 16:52 GMT
> <being a wag (as opposed to taking a WAG)>
> ..maybe they got a lot of votes from email's like
> sue1218@noconnectionwith.ibm.com    ;-)
> </being a wag (as opposed to taking a WAG)>

;-)

since it is allowed to vote for own products,
IBM could win just if some of its associates vote for it

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.