Vishnu Sharma

Ranch Hand
+ Follow
since Feb 03, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vishnu Sharma

Hi all,

I have a requirement, in which i need to do this. Let me cler by this example: I have two files, A.java & B.java, A file contains one textfield, txt. I need to set the value of txt as null, but from B file. Both of these files are in same package Miniproject of c drive.
Please suggest me the appropriate. Thanks in advance.
13 years ago
Thanks a lot pete.
13 years ago

Michael Dunn wrote:> Please provide solution

please provide code:
1) adding actionListener to the button, or
2) how mentioned textfields are 'seen' by ClearHandler



Code for ClearHandler is i already pasted in previous quote. The text fields are not getting cleared. Whatever value i am putting into them, it should be cleared after pressing the button. But it is not happening.
13 years ago
In my application, i have made one JButton, named "Clear", i have placed its handler named ClearHandler in other file with ClearHandler.java. The functionality of the handler is, whenever button is pressed, it should clear all the textfields. For which, i have used following code:

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class ClearHandler extends GUIApps implements ActionListener{
public void actionPerformed(ActionEvent e){
String s="";
idfield.setText(s);
descfield.setText(s);
ratefield.setText(s);
quantfield.setText(s);
unitfield.setText(s);
System.out.print("Event:="+e.getActionCommand());
}
}


i am not able to get the functionality. after pressing button, i am getting on console, "Event: Clear", but no textfield is getting cleared. Please provide solution.
13 years ago

Henry Wong wrote:
The synchronization mechanism and wait-notify mechanism are not different ways of doing the same thing. In fact, wait-notify depends on synchronization. In "threads speak", the first is an implementation of a mutex, and the second is a implementation of a condition variable.

The Sun tutorial on threads is a good start to learn the topic.

http://java.sun.com/docs/books/tutorial/essential/concurrency/

Henry



Thanks Henry.
Is there difference in transient keyword, if it is used with fields and if it is used with objects?
14 years ago
What is exact difference in between these two approaches?? Synchronize is doing the same thing, it holds the object lock and says to the another thread to wait. When it releases the object lock, it is notifying the other thread, that it can now use the object.

Manish Chhabra wrote:Hi Vishnu,

It would be easier to identify the problem if you share some code.

By the way are you flushing out and closing the data stream before your program finishes?

Check out flush( ) method in BufferedWriter (I am guessing you are using BufferedWriter, there is no such class "BufferedStreamWriter" in java io).

Cheers,
Manish



Hi, PFB the code:

14 years ago
I am getting following exception, while using readObject() method:

DeSerializeDate.java:11: unreported exception java.lang.ClassNotFoundException;
must be caught or declared to be thrown
d=(Date) s.readObject();
^


Please give solution for it...
14 years ago
The end user is entering the data on console and i am storing it in a two dimensional String array of 10X10. I am using BufferedStreamWriter to pick one line from the array and write in a text file. But i am not getting the output in file. For loop is being used for writing from array to the text file.
Please tell me the mistake, i am doing.....
14 years ago
The end user is entering the data on console and i am storing it in a two dimensional String array of 10X10. I am using BufferedStreamWriter to pick one line from the array and write in a text file. But i am not getting the output in file.
For loop is being used for writing from array to the text file.
Please tell me the mistake, i am doing.....
14 years ago

Nicola Garofalo wrote:The problem is that the method name is readLine() not readline().

Anyway if you clicked on the link you created with your post you would have seen in the API documentation the answer to your question.



Thanks Nicola. I did not check the API.
14 years ago

Jesper Young wrote:Look at the API documentation of those classes. BufferedReader has two constructors, which both take a Reader object. So to create a BufferedReader you'll need another Reader object first, for example a FileReader. You can't pass a FileInputStream directly to the constructor of BufferedReader (because a FileInputStream is not a Reader). Likewise for BufferedWriter.



Ok. Thanks.
14 years ago
I am getting the following error in BufferedStream readline method:

BufferedTest.java:25: cannot find symbol
symbol : method readline()
location: class java.io.BufferedReader
s=bin.readline();
^

Please tell me the reason for this and what the solution for it???
14 years ago
While creating object of BufferedReader or BufferedWriter class, do we need to pass, FileInputStream & FileOutputStream Objects, as parameters only??
Or, we can also instantiate these objects else way??
14 years ago