ahmedali mohd

Greenhorn
+ Follow
since Apr 14, 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 ahmedali mohd


Hi all,


I want to capture the dynamic label name which i added on JFrame using mouse click. How i can do that, if i use getX() and getY()
of mouse events . I know these are methods of MouseEvent but both mouse coordinates and frame cordiantes are different. Please let help me out asap how to do it.


Regards
Ahmed

I ve performed action listeners to button already and i 've used mouselisteners also to do the operations, but it is not working... please let me know .
13 years ago
Hi all,

I m opening Server Socket chat window from my JFrame using mouse click operation. It is getting hang in the sense it is connecting to client but actually it is not display anything on the screen, Totally blur / white window with only title window but behind the screen, Client able to send mssg to server but server couldn't becoz of blur. Without calling through JFrame, both Client and server are working fine ...

Code for Server Socket which making my frame and server chat window itself becoming hang... Why i don't know, please let me
I tried painting using repaint() but still not coming properly.
if(me.getClickCount() == 1 )
{
// Server2 myobj=new Server2(); // This is fine ...
// myobj.myServer(); //When i calling this method, it is hanging.. This method contains the following code as follows
}

/// myServer() code

try {
server=new ServerSocket(12345,100);
while( true )
{
try {
System.out.println("yes");
System.out.println(" Before waiting connection");
mywaitConnection();
System.out.println(" After connecting to client and before stream data");
getMyStreamData();
System.out.println(" After stream data but before process connections");
processMyConnection();

}
catch(EOFException ef)
{ System.err.println("error"+ef); }


I want to delete a file when i click the JButton or unchecked the JCheckBox option.. I m added actions to these components a well. Doing action but not deleting the file Why i don't know.
See the code ... I tried on deleteonExit() as well. But it is not doing if im doing through main() method that normal class, i can delete it ...

addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
update_user();
// delete_operation();
//System.exit(0);
}

public void windowClosed(WindowEvent e) {

File f1=new File("ahmedali.dat");
System.out.println("You are in Foperations"+f1);
System.out.println(" Inside delete");
if(f1.exists()) { System.out.println("File is deleted:");f1.delete(); }
f1=null;
}

}

);
13 years ago
Hi All

Here is my problem. My application is chat application which normally it is doing correctly between client and server with SWING components seperately. Client and Server having two seperate windows which are working fine when they seperately chat to each other.
Now problem creating when i m embedded this application into JFrame window. I m using Main window(JFrame by keep layout as null) like yahoo chat. Client and Server layouts are different it means they are using GridLayout and panel. I added one dynamic button in Main window which performs an action to open Server program. Server program having a run method where ServerSocket initialise are present.

Button having code like this using actionlistener or mouselistener for label

Server2 myobj=new Server2(); //This line is fine
myobj.myServer(); // But problem from this line ...

When i m clicking on that dynamic button. My server socket chat window becomes blur means nothing it is display on the screen except only Title bar even though every component set properly and running fine while doing seperately with the client.

When Client is sending the data to Server. Connection established properly and getting the result in the background flow of Server program but not in the text area of Server chat window.

When i m terminating the client application. What ever the messages client window had sent to server window i can see it ...
So, I need you people to help me how to overcome this problem , it is very urgent please help me out from this situation.

Server window should highlight all its button once i click to button. Why it is totally becoming white in color( without displaying nothing ). When Client windows terminates, then only it is showing ... So why and give me code where i need to make a change

When i m invoking this method, it is hiding everything. Is't the problem with the layout betwen two windows ( main & Server window) or . Any flow is wrong ? ...Please let me know


Code for Server -


public void myServer()
{
//for receive connections
try {
server=new ServerSocket(12345,100);
while( true )
{
try {
System.out.println("yes");
System.out.println(" Before waiting connection");
mywaitConnection();
System.out.println(" After connecting to client and before stream data");
getMyStreamData();
System.out.println(" After stream data but before process connections");
processMyConnection();

}
catch(EOFException ef)
{ System.err.println("error"+ef); }
finally { closeConnection(); ++counter;
} //step 5 connection close

} //end of while
} // end of outer try
catch( IOException ioe ) { ioe.printStackTrace(); }

}









13 years ago
Hi all,


In my application, I would like to use the format in my application like as follows

User1
:User2
User3

I want simple code for either using JButton or JLabel. I 've used JLabel due to its aligment properties which looks good but JLabel doesn't have action listeners to perform some operations. If i use JButton then I m not able to align the same i've mention above user left side image then afterwards user_name. Using button, there is gap between image and user_name which looks bad.

Is't there any other components which is very easy to implement except JTree.

It is very urgent. Please let me know quickly
13 years ago
Hi all,

I m using JFrame and added JLabel by fetching user name from database. When i m adding a new record through this application then i m recalling a method to add JLabel once to update my frame as per no of user in the table. I m using repaint to do that as well

But when i m sigout, then signout screen showing the background user added in front of main screen. Its means still is visible behind the screen. Actually it should be invisible on my main screen. I m doing repaint(), setVisible(false) and remove() ( all the components ) still , i m able to see those users...

Please let me know what to do next to update the screen and when i signout, it shouldn't show the behind users.

It is very urgent, help me out....

13 years ago

Got it, Thanks to all - very happy .. I m giving .txt.txt then only it is working ....




Still getting error please help me out ..

yes :\\192.168.0.3\save data\ahmed\hello.txt
Exception in thread "main" java.io.FileNotFoundException: \\192.168.0.3\save dat
a\ahmed\hello.txt (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
at URLReader.main(URLReader.java:11)
I 've used "file:" as well ... I new to java... please tell me piece of code

C:\Till_now>java URLReader
yes :file:/192.168.0.3/save data/ahmed/hello.txt
Exception in thread "main" java.io.FileNotFoundException: \192.168.0.3\save data
\ahmed\hello.txt (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown So
urce)
at java.net.URL.openStream(Unknown Source)
at URLReader.main(URLReader.java:8)
Could you please tell me line of code for FileInputStream ..


Hi all,

I m getting the following exceptions when i m connect with URL class . I want to access remote file without socket it means through shared directory . I 've write permission to the shared directory as well . But still i m getting exceptions
in the following code

import java.net.*;
import java.io.*;

public class URLReader {
public static void main(String[] args) throws Exception {
URL h = new URL("\\\\192.168.0.3\\save data\\ahmed\\hello.txt.txt");
System.out.println(" yes :"+h);
BufferedReader in = new BufferedReader(new InputStreamReader(h.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}

Output:
Exception in thread "main" java.net.MalformedURLException: no protocol: \\192.168.0.3\save data\ahmed\hello.txt.txt
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at URLReader.main(URLReader.java:6)

Please help me it is very urgent

I 've write access to that shared directory as well... Please provide me the code... I m trying URL class and getURLConnection also but it is giving me errors...
I 've a shared directory for that server on my machine... I want to create the file or if exists ...i want to read it ...

Thanks for your reply ....Please help me out.....
Hi all,

Can any one help me out to create a file on network system without socket options