menu screen for a program, anyone know a way of writing the code more elagantly.
I'm attempting to write a menu screen for a program, and am a complete noob at swing. I am using JLabel's to display the graphics that I have chosen for the buttons. At the moment the code for changing the menu screen is just under the MouseClicked method for the JLabel. So for one JLabel I will have;
public void MouseClicked(){
remove(all items in this screen);
add(all items for the next screen, dependant on which button was clicked);
}
This does work, but is extremely messy, and I am certain that their is a better way of doing it. Does anyone have any ideas? On how to neaten it up.
Re: menu screen for a program, anyone know a way of writing the code more elagantly.
Why don't you create multiple frames, each having it's own components and simply on some event hide the previous frame and show the one, event is triggered for?
Re: menu screen for a program, anyone know a way of writing the code more elagantly.
lol, I don't really know how to do that.
Although if I work it out it is a good idea.
Re: menu screen for a program, anyone know a way of writing the code more elagantly.
Thanks, I worked out how to to that, after a bit... [embarrassed] thnx.
Re: menu screen for a program, anyone know a way of writing the code more elagantly.
Still got a problem :O
If a new frame opens, windows plays the "window openy animation." when the window kind of zooms up to the position it is meant to be in. Is there any way of stopping this.
Re: menu screen for a program, anyone know a way of writing the code more elagantly.
Quote:
Originally Posted by
handuel
Still got a problem :O
If a new frame opens, windows plays the "window openy animation." when the window kind of zooms up to the position it is meant to be in. Is there any way of stopping this.
What do you mean?
Re: menu screen for a program, anyone know a way of writing the code more elagantly.
the answer you gave requires opening a new frame/window when a button is clicked. On windows, when a window is opened, the image of the frame zooms outward from the centre of the screen, before actually being able to be used. This, when it happens in my program, gives the impression that a new frame/window has been opened, instead of the contents of the current frame changing.
Re: menu screen for a program, anyone know a way of writing the code more elagantly.
I think I've solved it, I'm messing around with card layouts and they seem to work.
Thankyou mr777 for all your help.
Once I've finished I will post the code, so people can tell me if it's an improvement.