• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A few questions

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

1) On the network client gui, the user can enter the port number and IP address. I just want to confirm that the IP address string could either be an actual IP address (xxx.xxx.xxx.xxx) or the string "localhost". Is this correct?

2)


The ConfigurationDialog provides a dialog window to the user to enter the ip address, port number and database location based on the applicationMode ( network, standalone or server )and also two buttons, Connect and Exit.
Connect will validate the user data and return back to the MainWindow. Exit will set local flag (userSelectToExit) and return back to the MainWindow.
The method userExited() effectively returns the value of userSelectToExit flag.

In the MainWindow(), the userExited() is invoked and if true, will perform "System.exit(0)" to exit the application.
However, most of the times, the returned value from userExited () is correct ie set to reflect whether user selected Connect or Exit, but on the odd occasion, it is incorrect. Any possible explanation for this behaviour ?

3) Finally, when I exit the application, I perform "System.exit(0)". The window closes, however, I have noticed under the Windows Task Manager, the "jawac.exe" process assoicated with the run does not terminate. I have had to manually end the process. Any possible explanation for this behaviour ?

As always any help would be appreciated.

Regards
Pete



 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there again.

Ok Q1 - the answer really depends on how you "bind" the server. I recommend using IP address. One experiment you may want to do to verify this is to start your server saving "localhost" and try connecting client using IP address "127.0.0.1"... this would in fact NOT connect.

Q3 - did you set the EXIT_ON_CLOSE for the main window?

Q2 - one question. In your setup triggering "exit" will display the main window?

Connect will validate the user data and return back to the MainWindow. Exit will set local flag (userSelectToExit) and return back to the MainWindow.



In your main window - when are you executing userExited() method? What "return" value are you referring to?
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pete,

Little remark: xxx.xx.x.x could also be a valid ip-address

Kind regards,
Roel
 
Pete Palmer
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Appologises for asking three questions in one post. Will not happen again.

Hi K,

I did take up your advice of using a dialog and it is much simpler and works a treat...well almost except for Q2.

Q1) I actually support both localhost, hostname & IP address.
using 127.0.0.1 url is rmi://127.0.0.1:1099/RemoteBusinessServiceObject
using localhost url is rmi://localhost:1099/RemoteBusinessServiceObject

Q3 - did you set the EXIT_ON_CLOSE for the main window?


Yes I do as shown here :-


Q2 - one question. In your setup triggering "exit" will display the main window?



The MainWindow is only displayed if execution gets past line 21 in the code shown above. So if clientConfiguration.userExited() returns a "true", I perform System.exit(0) and exit the application before the MainWindow is displayed. Is this answering your question ?

In your main window - when are you executing userExited() method? What "return" value are you referring to?


The userSelectToExit flag is private to ConfigurationDialog class, which provides the user with the facility to enter ip address, db location, port number AND also two buttons - Connect & Exit. If the user selects Connect, the user data is validated ( & assuming thats ok), the userSelectToExit flag is set to TRUE, close the ConfigurationDialog window and return. If the user selects Exit, the userSelectToExit flag is set to FALSE, close the ConfigurationDialog window and return. The method userExited() will return the value of userSelectToExit. It is the value of userSelectToExit that I refer to as the return value.

Hi Roel,
Thank you for the valid comment.


Regards

Pete
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pete,

Seems you are following the example from Andrew's book.

Pete Palmer wrote:
If the user selects Connect, the user data is validated ( & assuming thats ok), the userSelectToExit flag is set to TRUE, close the ConfigurationDialog window and return. If the user selects Exit, the userSelectToExit flag is set to FALSE, close the ConfigurationDialog window and return.



I would expect it to be just the other way round: if user hits Exit, userSelectToExit is set to true instead of false. But i would guess that's just a flaw in your explanation The odd occasion the return value is incorrect, could it be the closing of the ConfigurationDialog by pressing the X in the upper right corner? The only explanation i can think of, because if you hit a button always the same code is executed, so if it's correct the first time, it should always be correct.
 
Pete Palmer
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roel,

My original approach was using as per the book but I had trouble with JOptionPane. So I changed the approach to use JDialog as suggested by K.

if it's correct the first time, it should always be correct.


Agree. Can you see anything wrong with the code below ? As mentioned, this problem is very occasional.

Regards

Pete

PS. As you can see you were correct w.r.t userExitSelected setting.

 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
off-topic: why adding the networkClientConfigurationPanel twice?



what happens if you just close the dialog by the X in the upper right corner?

do you have any more info about when the odd thing happens? Maybe after first entering some invalid parameters? Because just based on your code i could not see anything wrong

i hope CONNECT and EXIT refer to 2 different strings

Now i'm gonna watch belgian football and record MotD
 
Pete Palmer
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roel,

off-topic: why adding the networkClientConfigurationPanel twice?


no reason, just guilty of poor coding

what happens if you just close the dialog by the X in the upper right corner?


dialog closes nicely.

i hope CONNECT and EXIT refer to 2 different strings


Indeed they are.
private static final String CONNECT = "Connect";
private static final String EXIT = "Exit";

I can't get it to fail now ... so I think I will put this issue on monitor.

Now i'm gonna watch belgian football and record MotD


What about the championship at crucible ? Enjoy

Pete

 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

dialog closes nicely.



And is it handled as the user choose to exit?

What about the championship at crucible ?



I'll spend a lot of time coming 2 weeks in front of the tv, hope i don't have to press to often the red button to follow it on another bbc channel than bbc 1 or 2
 
Pete Palmer
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good Day Roel,

And is it handled as the user choose to exit?


Yes but not nicely. The userExitSelected was initialised to true.
private boolean userExitSelected = true;
So when the user did close the window via "X", the userExitSelected value read back in the MainWindow was effectively correct. However, I have added to the following :-


Pete
 
reply
    Bookmark Topic Watch Topic
  • New Topic