Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 23rd, 2005, 05:58 PM
zapata zapata is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 96 zapata User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 19 h 36 m 16 sec
Reputation Power: 6
Event in UserInterface - organizing classes

Hello

This doubt ocurred while working on the design of a UI to a simple app. It's java.

The user interface is a JFrame that contains 3 JPanel objects. Two of these JPanel will have to listen to actions (buttons clickfor example) as well as the JFrame itself.

1) UI.java ---- JFrame, creates and lanches the UI, JMenu events
2) LeftPanel.java ---- JPanel, contains a JList, JList selections events
3) CenterPanel.java ----- JPanel, contains some text
4) RightPanel.java ----- JPanel, contains buttons, button click

How do you suggest the organization for this?

-> Using the main JPanel/JFrame to implement Action Listener

-> New class wich implements Action Listener
then in the JPanel an instance of that class is passed to the addActionListener method

-> there's also that syntax

button1.addActionListener ( new ActionListener() { ... } )

however that seams kind of strange.

-> Other ways?

Thanks

Reply With Quote
  #2  
Old September 24th, 2005, 09:48 PM
eworley eworley is offline
Cypher
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: La Jolla, CA
Posts: 121 eworley User rank is Lance Corporal (50 - 100 Reputation Level)eworley User rank is Lance Corporal (50 - 100 Reputation Level)eworley User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 57 m 6 sec
Reputation Power: 5
Quote:
Originally Posted by zapata
Hello

This doubt ocurred while working on the design of a UI to a simple app. It's java.

The user interface is a JFrame that contains 3 JPanel objects. Two of these JPanel will have to listen to actions (buttons clickfor example) as well as the JFrame itself.

1) UI.java ---- JFrame, creates and lanches the UI, JMenu events
2) LeftPanel.java ---- JPanel, contains a JList, JList selections events
3) CenterPanel.java ----- JPanel, contains some text
4) RightPanel.java ----- JPanel, contains buttons, button click

How do you suggest the organization for this?

-> Using the main JPanel/JFrame to implement Action Listener

-> New class wich implements Action Listener
then in the JPanel an instance of that class is passed to the addActionListener method

-> there's also that syntax

button1.addActionListener ( new ActionListener() { ... } )

however that seams kind of strange.

-> Other ways?

Thanks


I would have each panel implement the listening interface that they are concerned with.

Cypher

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > Event in UserInterface - organizing classes


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT