🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #1506

Re: ComboBoxModel

#1506
From: Jacklondon Chen
Date: Tue, 16 Dec 2003 02:42
71 lines
3833 bytes
I mean ComboBoxModel just work like AbstractComboBoxModel is because
ComboBoxModel just do nothing, act something like "Abstract". In most case,
we have to write a subclass of ComboBoxModel  or just use
DefaultComboBoxModel.

In windows programing, for example, use CBuilder, we can use VCL for simple
application, Windows API for others.
In java programing, there is no choice for simple appliction or not simple.
Most java technical, such as MVC, not good for simple application.
programmer need write more code for simple application than CBuilder/VB.

I think a good way is that sun give some tools good for simple application,
others good for complex application.

for example, In most case, we use JComboBox for add string data and show and
select. Sun can give a new class for this case:


//--------------------------------------------------------------------------
------------------------------------>
public class JSimpleComboBox extends JComboBox {

  public JSimpleComboBox() {
    super(new DefaultComboBoxModel());
  }

  public void addElement(Object obj) {
    DefaultComboBoxModel dataModel = (DefaultComboBoxModel) getModel();
    dataModel.addElement(obj);
  }

}
//<-------------------------------------------------------------------------
-------------------------------------

I think in this way, programmer no need to write subclass of ComboBoxModel
each time. It's good for simple application.

"John McGrath [TeamB]" <ng-b@JPMcGrath.net>
??????:3fde551a$1@newsgroups.borland.com...
> On 12/15/2003 at 1:13:58 AM, Jacklondon Chen wrote:
>
> > I think the default model of JComboBox should be DefaultComboBoxModel
> > , that can make us to write less code.
> > But java has so many bad "default".
>
> The default model for a JComboBox *is* a DefaultComboBoxModel.
>
> > Do not use ComboBoxModel, it work something like as
> > AbstractComboBoxModel, can do nothing.
> > Use DefaultComboBoxModel .
>
> A DefaultComboBoxModel *is* a ComboBoxModel, so if you are using
> DefaultComboBoxModel, you are using ComboBoxModel.
>
> The DefaultComboBoxModel may be an appropriate class to use in some
> (even many) situations, but it is not always the best class to use.
> Without knowing some more details about the application, it is not
> possible to say which is the best ComboBoxModel to use.
>
> P.S.  There is no standard "AbstractComboBoxModel" class, but there is
> an "AbstractListModel".
>
> --
> Regards,
>
> John McGrath [TeamB]
>
> ---------------------------------------------------
> Before sending me e-mail, please read:
>     http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <3fde70fb$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f143b59$1@newsgroups.borland.com> <3fdd32b5$1@newsgroups.borland.com> <3fdd5106@newsgroups.borland.com> <3fde551a$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,80c2106396f99c07
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2003-12-15 19:09:44 PST
Reply-To: "Jacklondon Chen" <jacklondon.chen@tom.com>
From: "Jacklondon Chen" <jacklondon.chen@tom.com>
Newsgroups: borland.public.jbuilder.java.swing
References: <3f143b59$1@newsgroups.borland.com> <3fdd32b5$1@newsgroups.borland.com> <3fdd5106@newsgroups.borland.com> <3fde551a$1@newsgroups.borland.com>
Subject: Re: ComboBoxModel
Date: Tue, 16 Dec 2003 10:42:35 +0800
Lines: 73
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 210.22.158.131
Message-ID: <3fde70fb$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1071542523 210.22.158.131 (15 Dec 2003 18:42:03 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail