This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Radiobutton in Jtable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Radiobutton in Jtable" Watch "Radiobutton in Jtable" New topic
Author

Radiobutton in Jtable

abhijeet nagare
Greenhorn

Joined: Jun 11, 2013
Posts: 12
hello guys
i am using developing swing appication
and inserting radiobutton in jTABLE
BUT instead of that i am getting its true/false value...
pleasse give me solution...if any

my code is...

/**
*
*/
package appointmentFinal;


import java.awt.FlowLayout;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;

public class Jtable1 extends JFrame
{
JTable t;
Jtable1()
{
String col[]={"Employee","Start_Date","Client","Product or Services","tax","cost"};

JCheckBox ch=new JCheckBox();
Object [][] data = {
{"Kathy", "Smith",
"Snowboarding", new Integer(5), ch,1},
{"John", "Doe",
"Rowing", new Integer(3), new Boolean(true),1},
{"Sue", "Black",
"Knitting", new Integer(2), new Boolean(false),1},
{"Jane", "White",
"Speed reading", new Integer(20), new Boolean(true),1},
{"Joe", "Brown",
"Pool", new Integer(10), new Boolean(false),1}
};

DefaultTableModel tb =new DefaultTableModel(data,col);
t=new JTable( tb);


for(int i=0;i<6;i++)
{
t.getColumnModel().getColumn(i).setPreferredWidth(150);
t.setRowHeight(30);
}



add(t);
setLayout(new FlowLayout());
setSize(700, 500);
setLocation(300, 150);
setTitle("Ticket_Information");
setVisible(true);


}
public static void main (String []args)
{
new Jtable1();
}
}




Paul Mrozik
Ranch Hand

Joined: Feb 10, 2013
Posts: 117

abhijeet nagare wrote: hello guys
i am using developing swing appication
and inserting radiobutton in jTABLE
BUT instead of that i am getting its true/false value...
pleasse give me solution...if any



Please try using the Code button, it makes things easier to read.

As far as your question goes, have a look at this:



It does exactly what you want it to do. You're creating a and that's what you get in the table.

If you want a JRadioButton in your cell, you'll need to read about Cell Renderers



Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4531
    
    5

... and cell editors too.


luck, db
There are no new questions, but there may be new answers.
abhijeet nagare
Greenhorn

Joined: Jun 11, 2013
Posts: 12
can you please eloborate with some example ..please...
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4531
    
    5

Read the API for JTable and follow the link to the Swing tutorial on How to Use Tables where you will find several examples.
abhijeet nagare
Greenhorn

Joined: Jun 11, 2013
Posts: 12
Darryl Burke wrote:Read the API for JTable and follow the link to the Swing tutorial on How to Use Tables where you will find several examples.



thanks bro... i am working on it...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Radiobutton in Jtable