Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / June 2005

Tip: Looking for answers? Try searching our database.

Controlling JComboBox size in JTable cell

Thread view: 
Yulia - 27 Jun 2005 19:52 GMT
Hi,

I have a JTable where each cell is huge (in purpose).
One of the columns uses DefaultCellEditor with JComboBox (so when user
edits value of this column, a combo-box is displayed).

The problem is that this combo-box is stretched and gets huge
arrow-button (with height similar to its containing cell).
How can I make the combo-box smaller, so its height will be smaller
than the height of the cell that contains it?

Thanks in advance,

Yulia
Christian Kaufhold - 27 Jun 2005 20:54 GMT
> I have a JTable where each cell is huge (in purpose).
> One of the columns uses DefaultCellEditor with JComboBox (so when user
[quoted text clipped - 4 lines]
> How can I make the combo-box smaller, so its height will be smaller
> than the height of the cell that contains it?

Use (e.g.) JPanel with JComboBox as child as editor.

Please don't multipost.

Christian
Vova Reznik - 27 Jun 2005 21:14 GMT
> Hi,
>
[quoted text clipped - 10 lines]
>
> Yulia

Method of JTable
public Component prepareEditor(TableCellEditor editor, int r, int c)
returns your combobox. You can override it and return JPanle with combobox

something like this:

public Component prepareEditor(TableCellEditor editor, int r, int c) {
    Component comp = super.prepareEditor(editor, r, c);
    editorPanel.removeAll();
    // editorPanel is JPanel defined as private class variable
    // size of your combobox should be its preferred size
    editorPanel.add(comp);
    return editorPanel;
}


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.