aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Java Applet GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Java Applet GUI" Watch "Java Applet GUI" New topic
Author

Java Applet GUI

Timothy Leong
Ranch Hand

Joined: May 25, 2005
Posts: 55
Dear All, how do you create the interface like this?



This is an elevator may go up and down to pick up or send the passenger. When the passenger presses a left button, say �F3�, the elevator goes up from F1. After it arrives, the passenger presses a right button, say �F7�, the elevator goes up and stops on F7. After then it checks whether there is any left button pressed. Assume that the initial position of the elevator is on the first floor (F1), and the display information about the elevator will be updated

This is what I think

I should have 4 panels in a Frame in GridLayout
1 on top as label panel
1 on the left as button panel outside the lift
1 on the right as button panel in the lift
1 which shows the location of the lift.

There's a problem which I cannot understand. How should I draw the line of every storey and make sure the line coincides with the buttons and every components are still in proportion when user max or min the applet??

Thank you very much
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
If this is a Swing GUI, you can use the Border concept to draw those lines, particularly LineBorder.


Ping & DNS - my free Android networking tools app
Timothy Leong
Ranch Hand

Joined: May 25, 2005
Posts: 55
hi Ulf Dittmer, where do you mean by Border concept?
Are you saying that I should have 1 row of F8 , 1 row of F7......
each row has 3 columns??
All rows are added into a frame?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
No, I was talking about the javax.swing.border package.
But come to think about it, I would not use 4 panels, but only 2: one for the label, and one for all of the graphics. That way you will not have alignment problems.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Timothy Leong
Ranch Hand

Joined: May 25, 2005
Posts: 55
Wow , thanks Craig. However I have done the GUI myself but my coding is not as professional as yours.

btw, I need to do some event handling.

When user click "F6", the elevator will move up/down to Level 6.
Do I have to use 2 listeners??

1 actionevent listener for UITest to handle buttons
and 1 actionevent listener for CenterPanel for timer to draw elevator??

This is what I have done. Can the experts here suggest to me what's the most efficient way of handling buttons and painting the elevator?

Thank you very much.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

I'm not at all thrilled to see that Craig's given a complete solution to what's obviously a homework problem. Craig, your code examples are often very helpful, but please consider whether letting the poster do some of the work themselves wouldn't be more helpful in the long run.


[Jess in Action][AskingGoodQuestions]
Timothy Leong
Ranch Hand

Joined: May 25, 2005
Posts: 55
hi guys,

Suppose I have many panels. How can I call a component in a particular panel from another panel?

For example, I have a panel 1 with a Jbutton. I have another panel 2 with a JLabel. both panels are in different class. Is there a way to get JLabel object of panel 2 from panel 1 so that I can change the Label content?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
This has nothing to do with applets any more, so I'm moving the thread to our GUI forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Applet GUI