Jump to content
Sign in to follow this  
ladyofbow

Help with Java

Recommended Posts

This what its look like,

Posted Image

 

I required to activate those toggles Metric button, by clicking it. Then the unit will convert into ft and lb instead m and kg. I'm not sure how to do it.

Also, i need to move the Pop up "message" dialog box outside into the same window, rather than separate window. Just the message itself, not the pop up

Any tips on how to do it ?

 

Thank You

Edited by ladyofbow

Share this post


Link to post
Share on other sites

I can't answer and I doubt anyone else can as you don't have enough detail.

 

You need to include the source code for anyone to comment intelligently on this one.

 

That said having a guess, you need to add a button even handler. My Java GUI is rusty but I believe it should be an ActionEvent. You connect the button to a method which handles the ActionEvent and you are away.

 

As for the dialog box, that's usually controlled by the host operating system and generally appears in the middle of the screen. You should be able however to work out the position of your application on the screen and set the message box's position either in its constructor, through a method before you "show" it or after its made.

Share this post


Link to post
Share on other sites

That said having a guess, you need to add a button even handler. My Java GUI is rusty but I believe it should be an ActionEvent. You connect the button to a method which handles the ActionEvent and you are away.

That's more or less how I did it. I havent done java interfaces for like 2 years though.

 

IIRC, which I may not, the actionevent is created as an inner class, and you activate it when the button is clicked.

Share this post


Link to post
Share on other sites

You use a dialog set as "modal dialog" to cause them to centralise into the main app window, but the main app window should extend from awt Frame or javax JFrame.

With dialogs they require a frame instance added to them at construction whether static or new , and that can have it position allocated on the screen.

As for the actionlistener , its generally implemented on the main app window and the abstract method overridden ( public void actionPerformed(ActionEvent e) ).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×