Thread View: borland.public.jbuilder.java.swing
9 messages
9 total messages
Started by Tzel
Tue, 15 Jul 2003 17:37
ComboBoxModel
Author: Tzel
Date: Tue, 15 Jul 2003 17:37
Date: Tue, 15 Jul 2003 17:37
5 lines
1022 bytes
1022 bytes
How could i put data to a ComboBox using the ComboBox model? Any examples or sites would be appreciatable Thanks
Re: ComboBoxModel
Author: Lori Olson (TeamB)
Date: Tue, 15 Jul 2003 17:43
Date: Tue, 15 Jul 2003 17:43
37 lines
2053 bytes
2053 bytes
Tzel wrote:
> How could i put data to a ComboBox using the ComboBox model?
>
> Any examples or sites would be appreciatable
>
> Thanks
>
>
Here's the basic tutorial on Comboboxes.
http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html
Just create your Combobox using the constructor that takes a model as a
parameter, or set the model using the Combobox method "setModel()"
It really isn't that difficult. Try it, and if it doesn't work, then
post your code and we'll help out.
--
Regards,
Lori Olson (TeamB)
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Re: ComboBoxModel
Author: Jacklondon Chen
Date: Mon, 15 Dec 2003 04:04
Date: Mon, 15 Dec 2003 04:04
20 lines
1598 bytes
1598 bytes
Do not use ComboBoxModel, it work something like as AbstractComboBoxModel,
can do nothing.
Use DefaultComboBoxModel .
DefaultComboBoxModel defaultComboBoxModelData = new
DefaultComboBoxModel();
JComboBox jComboBoxData = new JComboBox(defaultComboBoxModelData);
defaultComboBoxModelData.addElement("hello");
defaultComboBoxModelData.addElement("heihei");
"Tzel" <stzelis@yahoo.gr> д����Ϣ����:3f143b59$1@newsgroups.borland.com...
> How could i put data to a ComboBox using the ComboBox model?
>
> Any examples or sites would be appreciatable
>
> Thanks
>
>
Re: ComboBoxModel
Author: Jacklondon Chen
Date: Mon, 15 Dec 2003 06:13
Date: Mon, 15 Dec 2003 06:13
30 lines
1841 bytes
1841 bytes
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".
"Jacklondon Chen" <jacklondon.chen@tom.com> д����Ϣ����
:3fdd32b5$1@newsgroups.borland.com...
> Do not use ComboBoxModel, it work something like as AbstractComboBoxModel,
> can do nothing.
> Use DefaultComboBoxModel .
>
> DefaultComboBoxModel defaultComboBoxModelData = new
> DefaultComboBoxModel();
> JComboBox jComboBoxData = new JComboBox(defaultComboBoxModelData);
> defaultComboBoxModelData.addElement("hello");
> defaultComboBoxModelData.addElement("heihei");
>
>
>
> "Tzel" <stzelis@yahoo.gr> �� ? :3f143b59$1@newsgroups.borland.com...
> > How could i put data to a ComboBox using the ComboBox model?
> >
> > Any examples or sites would be appreciatable
> >
> > Thanks
> >
> >
>
>
Re: ComboBoxModel
Author: John McGrath [TeamB]
Date: Mon, 15 Dec 2003 23:43
Date: Mon, 15 Dec 2003 23:43
31 lines
2190 bytes
2190 bytes
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
Re: ComboBoxModel
Author: Jacklondon Chen
Date: Tue, 16 Dec 2003 02:42
Date: Tue, 16 Dec 2003 02:42
71 lines
3833 bytes
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
Re: ComboBoxModel
Author: John McGrath [TeamB]
Date: Thu, 18 Dec 2003 05:34
Date: Thu, 18 Dec 2003 05:34
49 lines
2929 bytes
2929 bytes
On 12/15/2003 at 9:42:35 PM, Jacklondon Chen wrote:
> In most case, we have to write a subclass of ComboBoxModel or just
> use DefaultComboBoxModel.
I think you have the basic idea, but I have some problems with how you
describe interfaces. You do not write a *subclass* of ComboBoxModel,
since it is an interface, not an abstract class. You can *implement*
an interface, not *subclass* it.
> 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.
There is no need to write a subclass of ComboBoxModel (or of JComboBox)
each time. I do not see any functionality provided by the above code
that is not provided by the JComboBox superclass.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Re: ComboBoxModel
Author: John McGrath [TeamB]
Date: Thu, 18 Dec 2003 22:14
Date: Thu, 18 Dec 2003 22:14
14 lines
1646 bytes
1646 bytes
On 12/18/2003 at 12:34:24 AM, John McGrath [TeamB] wrote:
> There is no need to write a subclass of ComboBoxModel
I should have said: there is no need to *implement* ComboBoxModel.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Re: ComboBoxModel
Author: Jacklondon Chen
Date: Fri, 19 Dec 2003 05:59
Date: Fri, 19 Dec 2003 05:59
19 lines
1825 bytes
1825 bytes
Never say never. "John McGrath [TeamB]" <ng-b@JPMcGrath.net> ??????:3fe234e0$1@newsgroups.borland.com... > On 12/18/2003 at 12:34:24 AM, John McGrath [TeamB] wrote: > > > There is no need to write a subclass of ComboBoxModel > > I should have said: there is no need to *implement* ComboBoxModel. > > -- > Regards, > > John McGrath [TeamB] > > --------------------------------------------------- > Before sending me e-mail, please read: > http://www.JPMcGrath.net/newsgroups/e-mail.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads