Re: JComboBox with IDentifiers

Discussion in 'Java' started by Lew, Aug 11, 2012.

  1. Lew

    Lew Guest

    From: Lew <>

    Sax@DIST wrote:
    > here I am again with another amazing trouble! 0:cool:
    >
    > 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
    Lew, Aug 11, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    335
    Roedy Green
    Apr 22, 2008
  2. Roberto Sagoleo

    JComboBox with IDentifiers

    Roberto Sagoleo, Aug 10, 2012, in forum: Java
    Replies:
    8
    Views:
    368
    Sax@DIST
    Aug 22, 2012
  3. markspace

    Re: JComboBox with IDentifiers

    markspace, Aug 11, 2012, in forum: Java
    Replies:
    0
    Views:
    213
    markspace
    Aug 11, 2012
  4. -nlb-this

    Re: JComboBox with IDentifiers

    -nlb-this, Aug 13, 2012, in forum: Java
    Replies:
    3
    Views:
    283
    Daniele Futtorovic
    Aug 13, 2012
  5. Sax
    Replies:
    1
    Views:
    253
    markspace
    Aug 13, 2012
Loading...

Share This Page