Bienvenido: ( Identificarse | Registrarse )      
Foros de Trucos Windows
Closed TopicStart new topicStart Poll

Outline · [ Estándar ] · Lineal+

> JTable SIN EDITAR ?

blizknight
post Jan 30 2007, 05:34 AM
Publicado: #1


Maestro
*****

Grupo: Members
Mensajes: 266
Registrado: 12-September 04
Miembro nº: 18.538



Hola a todos... pues mi duda es ... como hacer un JTable sin la posiblidad de que el usuario modifique los datos ?
bueno eso es todo...

aca les dejo el panel...
ojala se pueda hacer algo
saludos

CODE
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;

public class Tabla extends JPanel {

DefaultTableModel model;
JTable table;
JScrollPane sc;

public Tabla(){

setLayout(null);

model = new DefaultTableModel();
   table = new JTable(model);
 


sc = new JScrollPane(table);
   sc.setBounds(0,0,580,220);
   add(sc);
 
}

}



User is offlineProfile CardPM
Go to the top of the page
+Quote Post
rob1104
post Jan 30 2007, 09:41 PM
Publicado: #2


Xbox Live... The best thing ever happened around videogames
Group Icon

Grupo: Moderadores
Mensajes: 1.709
Registrado: 7-March 05
Desde: Matamoros, Tamaulipas, México
Miembro nº: 93.342



Hola blizknight, para conseguir que un JTable no lo pueda editar el usaurio agrega el siguiente metodo al constructor
CODE
public boolean isCellEditable(int row, int column)
{
   return false;
}

Saludos thumbsup.gif


User is offlineProfile CardPM
Go to the top of the page
+Quote Post
blizknight
post Jan 30 2007, 09:53 PM
Publicado: #3


Maestro
*****

Grupo: Members
Mensajes: 266
Registrado: 12-September 04
Miembro nº: 18.538



Rob..
Bueno
cree la tabla en otro archivo

PanelTabla = new Tabla();
PanelTabla.isCellEditable(1,1);

y sigue siendo editable....


User is offlineProfile CardPM
Go to the top of the page
+Quote Post
rob1104
post Jan 30 2007, 10:39 PM
Publicado: #4


Xbox Live... The best thing ever happened around videogames
Group Icon

Grupo: Moderadores
Mensajes: 1.709
Registrado: 7-March 05
Desde: Matamoros, Tamaulipas, México
Miembro nº: 93.342



Blizknight, en ningun momento te dije que llamaras al metodo en si biggrin20jy.gif whistling.gif , solo que lo heredaras y lo retornes, pon este código tal como te lo escribo entre {} despues de model = new DefaultTableModel();, que quede asi:
CODE
model = new DefaultTableModel();
{
   public boolean isCellEditable(int row, int column)
   {
       return false;
   }
};


ph34r.gif

Mensaje modificado por robbie110487 el Jan 31 2007, 11:01 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
blizknight
post Feb 1 2007, 04:22 AM
Publicado: #5


Maestro
*****

Grupo: Members
Mensajes: 266
Registrado: 12-September 04
Miembro nº: 18.538



Gracias!! problema resuelto XP
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
blizknight
post Feb 2 2007, 10:36 PM
Publicado: #6


Maestro
*****

Grupo: Members
Mensajes: 266
Registrado: 12-September 04
Miembro nº: 18.538



bueno... ahora me surgio otra duda.... quiero pintar x fila donde se encuentre x dato.....

digamos tengo una tabla con datos a,b,c ... quiero que el fondo de la celda de a se pinte de color azul....

como lo haria??
y en el caso de querer elimnarlo ?
saludos flowers.gif
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
Closed TopicTopic OptionsStart new topic

Collapse

> Topicos similares

No puedo editar con fax y visor de windows Anukdp 39 1 Oct 30 2008, 04:16 PM
By: Kbite
Editar PDFs jalamako 76 2 Oct 23 2008, 10:00 PM
By: jalamako
programa para editar pelicula ? (subtitulos) TequilaGT 712 7 Oct 17 2008, 01:30 AM
By: TequilaGT
Editar un comando en ms-dos desde otro ordenador cuttysark 185 1 Oct 7 2008, 02:01 PM
By: cuttysark
quiero editar menu, boton derecho en inicio andr3s 219 1 Sep 23 2008, 11:25 AM
By: patricioirrazabal