• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Radiobutton in Jtable

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
}
}




 
Ranch Hand
Posts: 117
Mac Chrome Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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



 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
... and cell editors too.
 
abhijeet nagare
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you please eloborate with some example ..please...
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic