Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #17692

Re: JComboBox with IDentifiers

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!53ab2750!not-for-mail
From "Lew" <lew@1:261/38.remove-pjg-this>
Subject Re: JComboBox with IDentifiers
Message-ID <50269FCE.56639.calajapr@time.synchro.net> (permalink)
X-Comment-To All
Newsgroups comp.lang.java.programmer
X-FTN-AREA COMP.LANG.JAVA.PROGRAMMER
X-FTN-MSGID 1:261/38 d1673c9e
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.16a-Win32 NewsLink 1.98]
Lines 102
Date Sat, 11 Aug 2012 18:17:51 GMT
NNTP-Posting-Host 69.21.70.65
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1344709071 69.21.70.65 (Sat, 11 Aug 2012 13:17:51 CDT)
NNTP-Posting-Date Sat, 11 Aug 2012 13:17:51 CDT
Organization tds.net
Xref csiph.com comp.lang.java.programmer:17692

Show key headers only | View raw


From: Lew <lewbloch@gmail.com>

Sax@DIST wrote:
> here I am again with another amazing trouble!   08-)
>
> I need to create a JComboBox containing a list of Items, each of which has
its own IDentifier!
>
> So: when I select an Item of the JComboBox, I need to get its IDentifier (ie:
its ID in a DataBase Table).
>
> I wrote the following four classes example, and I hope this could help
someone else with my same needs!

It would be a lot more useful if your code followed the Java Coding 
Conventions.

More seriously, you fail to respect that GUI actions must happen on the EDT.

It's a rookie mistake.

Idioms like:

  String l_nam;
  l_nam = this.m_jsx_java_nam;
  return( l_nam );

should be replaced with the more readable

  return this.jsxName;

Why create a throwaway reference?
Why the redundant parenteses on the return value?

You use code comments in an unusual way, and worse, in lieu of Javadoc 
comments.

  }//constructor

rather than

  /**
   * Constructor.
   */

Import-on-demand is not a best practice.

  import java.util.*;

Comments should actually provide information.

  ///////////////////////////////////////////////////////////////////
  //
  // Class.
  //

Really?

Declare the widest type applicable. In particular, prefer interfaces to 
concrete types.

  ArrayList<JSX_JAVA_NamVal> m_namval_list;

should be

  List<JsxName> names;

Which brings up the point that variables should be named in terms of the 
problem
domain, not the implementation domain. The fact that the variable is a list in 
this
case should not be part of the name.

Variables should be scoped as locally as applicable, and declared as close as 
convenient to their point of use.

None of this:

 private void UpdateIndexAndIdentifier( )
                {
                Integer  l_selectedIndex      ;
                Integer  l_selectedIDentifier ;
                String   l_index_str          ;
                String   l_identifier_str     ;

Setting member variables to their default values in initializers or 
constructors is usually
unnecessary and always redundant.

  this.m_jsx_java_val = 0;

You should fix these issues before proffering your code to the programming 
public.
As it stands your code is not professional.

--
Lew

--- BBBS/Li6 v4.10 Dada-1
 * Origin: Prism bbs (1:261/38)
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread


Thread

Re: JComboBox with IDentifiers "Lew" <lew@1:261/38.remove-pjg-this> - 2012-08-11 18:17 +0000

csiph-web