AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Mettere un JCheckBox in una JTable

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java (Italian)
View previous topic :: View next topic  
Author Message
Rigel
Guest





PostPosted: Mon Nov 27, 2006 1:00 am    Post subject: Mettere un JCheckBox in una JTable Reply with quote



Ciao a tutti,
non capisco perchè mettendo un JCheckBox in una JTable, mi compare il
valore false o true e se con il mouse faccio click si vede il JCheckBox
che è il comportamento che vorrei (e non vedere false o true). Sicuramente
ho sbagliato qualcosa, ma non ne vengo a capo.
Codice:
riga.addElement("numero");
riga.addElement(new Boolean(false));
/*
Questi sono i campi che leggo e metto in un vettore chiamato numeri.
Le colonne sono due: una stringa e una Boolean
*/
TableModel modello = new DefaultTableModel(numeri, colonne);
tabella.setModel(modello);
JCheckBox cbx = new JCheckBox();
TableColumnModel tcm = tabella.getColumnModel();
TableColumn tc = tcm.getColumn(1); //column 1 è la colonna con i
Boolean
tc.setCellEditor(new DefaultCellEditor(cbx));


Grazie
Rigel

--

questo articolo e` stato inviato via web dal servizio gratuito
http://www.newsland.it/news segnala gli abusi ad abuse (AT) newsland (DOT) it
Back to top
pole
Guest





PostPosted: Mon Nov 27, 2006 1:11 am    Post subject: Re: Mettere un JCheckBox in una JTable Reply with quote



Rigel wrote:

Quote:
Ciao a tutti,
non capisco perchè mettendo un JCheckBox in una JTable, mi compare il
valore false o true e se con il mouse faccio click si vede il JCheckBox
che è il comportamento che vorrei (e non vedere false o true). Sicuramente
ho sbagliato qualcosa, ma non ne vengo a capo.

Succede così perché hai impostato solamente il CellEditor, che appunto
compare solamente quando la cella è in editing (ovvero ci fai clic col
mouse). Per ottenere il comportamento che cerchi devi impostare anche il
renderer.

pole
--
ammentos - a lightweight persistence framework for JDK5
http://ammentos.biobytes.it
Flash tutorial: http://ammentos.biobytes.it/quickstart/quickstart.htm
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java (Italian) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.