Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Applet GUI

 
Timothy Leong
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is a Swing GUI, you can use the Border concept to draw those lines, particularly LineBorder.
 
Timothy Leong
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Timothy Leong
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Timothy Leong
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has nothing to do with applets any more, so I'm moving the thread to our GUI forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic