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


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

Re: JComboBox with IDentifiers

From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: JComboBox with IDentifiers
Date 2012-08-10 15:26 -0700
Organization http://groups.google.com
Message-ID <79bebafa-1f43-4a8b-aff1-df1493d1c05a@googlegroups.com> (permalink)
References <08a4e9e5-be46-4a15-94c4-e6bfab71d781@googlegroups.com>

Show all headers | View raw


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

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


Thread

JComboBox with IDentifiers Roberto Sagoleo <roberto.sagoleo@gmail.com> - 2012-08-10 14:41 -0700
  Re: JComboBox with IDentifiers markspace <-@.> - 2012-08-10 15:14 -0700
  Re: JComboBox with IDentifiers Lew <lewbloch@gmail.com> - 2012-08-10 15:26 -0700
  Re: JComboBox with IDentifiers "Sax@DIST" <roberto.sagoleo@gmail.com> - 2012-08-12 14:03 -0700
    Re: JComboBox with IDentifiers markspace <-@.> - 2012-08-12 14:37 -0700
      Re: JComboBox with IDentifiers "Sax@DIST" <roberto.sagoleo@gmail.com> - 2012-08-13 09:22 -0700
        Re: JComboBox with IDentifiers Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-08-13 18:49 +0200
  Re: JComboBox with IDentifiers Roedy Green <see_website@mindprod.com.invalid> - 2012-08-14 18:02 -0700
  Re: JComboBox with IDentifiers "Sax@DIST" <roberto.sagoleo@gmail.com> - 2012-08-22 03:30 -0700

csiph-web