adding combobox in netbeans jtable

Posted on 2008-10-19
Last Modified: 2013-12-14
i m using netbeans 6.0.i have a panel,on that panel i hv a scrollpane,on that scrollpane i have dragged n dropprd a jtable.i want to use a combobox in one of the ells and button in another i can do that?
Question by:mithunda5011
  • 3
  • 2

Expert Comment

ID: 22751911
Make sure you have read the sun tutorial. There is a part of using JTable. There is also an example of adding a combobox to a column.

For adding a JButton to a cell you can also look at the solution at

If you have any problems regarding to this do not hesitate to post your question.


Author Comment

ID: 22751933
thnx, but netbeans jtable has some different is not that simple jtable

Expert Comment

ID: 22751970
You can add the code in a separate init code block.
In your code there is a method called initComponents(); right?
After this method call you can add another method call. For example init();

And add a new method in your code where you add the code for the table.

Now you have added the code to your table.
private void init() {

        TableColumn comboboxColumn = jTable1.getColumnModel().getColumn(1);

        JComboBox comboBox = new JComboBox();



        comboBox.addItem("Chasing toddlers");

        comboBox.addItem("Speed reading");

        comboBox.addItem("Teaching high school");


        comboboxColumn.setCellEditor(new DefaultCellEditor(comboBox));

 // ... etc.


Open in new window


Author Comment

ID: 22752054
exellent....i hv added combobox...using the same coding i am unable to add button in another cell...

TableColumn comboboxColumn_new = jTable1.getColumnModel().getColumn(2);
        JButton jbutton = new JButton("add");
        comboboxColumn_new.setCellEditor(new DefaultCellEditor(jbutton));

it is giving error at DefaultCellEditor

Accepted Solution

manuel_m earned 500 total points
ID: 22752209
You have to create a renderer and an editor for this cell to add a jbutton to it.
As I have posted in my first post there you will find a solution. For example at this site

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java Message handling in Service Layer 3 55
ArrayIndexOutOfBoundException 9 67
thymeleaf natural templating vs JSP 2 66
arguments to jar 5 13
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now