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


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

Re: JComboBox with IDentifiers

Started by"Lew" <lew@1:261/38.remove-pjg-this>
First post2012-08-11 18:17 +0000
Last post2012-08-11 18:17 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.java.programmer


Contents

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

#17692 — Re: JComboBox with IDentifiers

From"Lew" <lew@1:261/38.remove-pjg-this>
Date2012-08-11 18:17 +0000
SubjectRe: JComboBox with IDentifiers
Message-ID<50269FCE.56639.calajapr@time.synchro.net>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web