Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot

Closed Thread
 
LinkBack (1) Thread Tools Display Modes
Old 28-07-2007, 08:36 PM   1 links from elsewhere to this Post. Click to view. #1 (permalink)
I am Optimus Prime
 
navjotjsingh's Avatar
 
Join Date: Feb 2005
Location: Delhi, India
Posts: 1,919
Default Java programming query

I have a problem with the following java program. I am using JDK 1.6.0

Can somebody suggest solution to the problem?

Here is the code

Code:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
//<applet code=Login height=300 width=400></applet>
public class Login extends JApplet implements ActionListener
{
 JTextField textCustName;
 JPasswordField textPassword;
 JLabel labelCustName, labelPassword;
 JButton loginButton;
 
 public void init()
 {
  createApplet();  
 }
 
 public void createApplet()
 {
  JPanel panel;
  panel = new JPanel();
  getContentPane().add(panel);
  panel.setLayout(new FlowLayout());
  labelCustName = new JLabel("Customer login Name:");
  textCustName = new JTextField(10);
  labelPassword = new JLabel("Password:");
  textPassword = new JPasswordField(10);
  loginButton = new JButton("Login");
  panel.add(labelCustName);
  panel.add(textCustName);
  panel.add(labelPassword);
  panel.add(textPassword);
  panel.add(loginButton);
  loginButton.addActionListener(this);     
 }
 public void actionPerformed(ActionEvent evt)
 {
  Object obj = evt.getSource();
  if (obj == loginButton)
  {
   String entry = textCustName.getText() + ":" + new String(textPassword.getPassword());
   try
   {
    RandomAccessFile logfile = new RandomAccessFile("Customer.txt","rw");
    logfile.seek(logfile.length());
    logfile.writeBytes(entry);    
   }
   catch(IOException e)
   {
    showStatus("Cannot write on to the logfile"+e);
   }
  }
 }
}
Please help.
navjotjsingh is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 28-07-2007, 11:18 PM   #2 (permalink)
>:)I-):(|)8-X
 
Charan's Avatar
 
Join Date: Sep 2004
Location: ಬೆಂಗಳೂರು (Bengaluru)
Posts: 3,512
Default Re: Java programming query

What is the problem navjtoh? Though I dont know Java this looks very similar to C#. By looking at it , you may have some problem with event handler.
__________________
i5 2400 | DH67BL | G.Skill Ripjaw 4 GB | FSP SAGA II 500W | CM 430 Black Elite | MSI R6850 Cyclone PE/OC | XBox 360 Controller | 21.5" Samsung Sync Master 2233 | 4 Mbps UL
Charan is online now  
Old 29-07-2007, 08:22 PM   #3 (permalink)
I am Optimus Prime
 
navjotjsingh's Avatar
 
Join Date: Feb 2005
Location: Delhi, India
Posts: 1,919
Default Re: Java programming query

Try running this code under JDK 1.6.0 and you will know what's the problem.

Hey no java programmer here? I want this answer fast.

Last edited by navjotjsingh; 29-07-2007 at 08:22 PM. Reason: Automerged Doublepost
navjotjsingh is offline  
Old 04-08-2007, 04:10 PM   #4 (permalink)
I am Optimus Prime
 
navjotjsingh's Avatar
 
Join Date: Feb 2005
Location: Delhi, India
Posts: 1,919
Default Re: Java programming query

Hey, please somebody answer my query. I know there are many programmers here.

Posted screenshot of error:


Last edited by navjotjsingh; 04-08-2007 at 04:19 PM.
navjotjsingh is offline  
Old 26-10-2007, 10:16 AM   #5 (permalink)
Alpha Geek
 
sachin_kothari's Avatar
 
Join Date: Dec 2004
Location: Pune
Posts: 566
Default Re: Java programming query

^^ You are getting this error because you are using applets.
Untrusted Applets restricts access to files. You need to sign them to access files.
This should clarify your doubts.
sachin_kothari is offline  
Old 27-10-2007, 12:38 AM   #6 (permalink)
I am Optimus Prime
 
navjotjsingh's Avatar
 
Join Date: Feb 2005
Location: Delhi, India
Posts: 1,919
Default Re: Java programming query

Thanks for such a speedy reply. I already fixed it.
navjotjsingh is offline  
Old 27-10-2007, 01:09 AM   #7 (permalink)
>:)I-):(|)8-X
 
Charan's Avatar
 
Join Date: Sep 2004
Location: ಬೆಂಗಳೂರು (Bengaluru)
Posts: 3,512
Default Re: Java programming query

ROLF .. when I saw this thread bumped I thought navjoth still didnot fix the problem.
__________________
i5 2400 | DH67BL | G.Skill Ripjaw 4 GB | FSP SAGA II 500W | CM 430 Black Elite | MSI R6850 Cyclone PE/OC | XBox 360 Controller | 21.5" Samsung Sync Master 2233 | 4 Mbps UL
Charan is online now  
Old 27-10-2007, 01:18 AM   #8 (permalink)
I am Optimus Prime
 
navjotjsingh's Avatar
 
Join Date: Feb 2005
Location: Delhi, India
Posts: 1,919
Default Re: Java programming query

Quote:
Originally Posted by sachin_kothari
^^ You are getting this error because you are using applets.
Untrusted Applets restricts access to files. You need to sign them to access files.
This should clarify your doubts.
second way is to use applet policy file which i did.
navjotjsingh is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


LinkBacks (?)
LinkBack to this Thread: http://www.thinkdigit.com/forum/programming/64100-java-programming-query.html
Posted By For Type Date
Thread java programming for 10 th std icse | Digit Forum | BoardReader This thread Refback 06-07-2011 11:39 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
free online certificate in java programming Ramakrishnan Technology News 11 03-11-2009 04:14 PM
Java programming..how can I distribute java program....? Manojap Programming 5 16-05-2009 02:46 PM
Need help for my project using Java Programming pritzdj Programming 6 28-04-2009 06:14 AM
Simple programming Error in Java nitish_mythology Programming 2 15-10-2005 12:01 AM
JAVA PROGRAMMING BLITZ~KRIEG! Programming 5 23-12-2004 02:21 PM


All times are GMT +5.5. The time now is 01:25 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2