I have developed an applicatio using RMI to broad cast some messages to the clients from the server. When we send message from the server it will be displayed in the clients in a message box.

But the displayed message box is behind all other active windows, and the client user does'nt know that he/she has recieved a message.

So I want to display the message box on top of all active windows. Can any body help me to achieve this?

Good suggessions are well apreciated.

Thanks in advance.

Most versions of most OSs will (quite rightly) prevent you from overriding the user and plastering your stuff across his current window whenever you want. A"correct" way would be to have a notification area icon for your app and display a pop-up message next to the icon. From Java 6 (version 1.6) you can do this with the java.awt.SystemTray class (eg)

...
trayIcon = new TrayIcon(...);
...
trayIcon.displayMessage("Message", 
   "You have a new broadcast message",
   TrayIcon.MessageType.INFO);

http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/systemtray/

window.setAlwaysOnTop(boolean);
window is the name of your jframe and replace boolean with true or false depending if you want the visible to be on top.

Also do what msn does, play a sound.

Most versions of most OSs will (quite rightly) prevent you from overriding the user and plastering your stuff across his current window whenever you want. A"correct" way would be to have a notification area icon for your app and display a pop-up message next to the icon. From Java 6 (version 1.6) you can do this with the java.awt.SystemTray class (eg)

...
trayIcon = new TrayIcon(...);
...
trayIcon.displayMessage("Message", 
   "You have a new broadcast message",
   TrayIcon.MessageType.INFO);

http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/systemtray/

:icon_smile: Thanks for your suggestion.

I'm already using the SystemTrayIcon. But still I need the MessageBox to be displayed so it will attract the user immediately to the message sent and the SystemTray popup message can be missed by the user who is concentrating the application for a certain while.

:) Any way once again thanks alot for your valuable suggestion, because it will help the people who reads this thread in the feuture.

Try this.

message_box_name.setModel(true);

I have tried.

msgBox.setModel(true);

But, still it is not getting displayed in the front, It goes behind all.

Thanks of giving this suggestion. If anybody knows any other way please help me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.