Visualizzazione dei risultati da 1 a 7 su 7
  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2005
    Messaggi
    16

    [JAVA]problemi per colorare una cella in una tabella dinamicamente

    ciao a tutti, ho questo problema:
    con questo programma io calcolo la consistenza di un database..in pratica faccio scegliere all'utente le tabelle/metriche che vuole verificare e gli stampo il valore desiderato..poi se la consistenza è <1 devo stampargli le tabelle interessate evidenziando le celle sbagliate all'interno di esse per dargli la possibilità di cambiare il valore sbagliato. Il problema è che non riesco a colorare queste celle!O meglio..se creo una tabella e staticamente gli dico di colorare quelle celle lo fa, ma il fatto è che io lo devo fare dinamicamente!non sapendo quali tabelle vuole vedere e quali valori sono sbagliati nn posso farlo staticamente..
    quindi ho creato questa classe

    codice:
    package datacleaning;
    
    import java.awt.Color;
    import java.awt.Component;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableCellRenderer;
    
    public class MioCellRenderer extends DefaultTableCellRenderer{
    
    	private static final long serialVersionUID = 1L;
    
    	public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){
    	Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
    	if(row==6||row==0) //per esempio
    		cell.setBackground( Color.red );
    	else
    		cell.setBackground( Color.white );
    	return cell;
    	}
    }
    e poi c'è la classe che visualizza il tutto

    codice:
    ..........
    ..........
    ..........
    	//****MENU INITIALIZE****//
    //crea i pannelli dinamicamente a seconda della dimensione del db
    	private void initialize() throws SQLException, IOException {
    		this.setVisible(true);
    		this.setBounds(0,30,1005,572);
    		this.setEnabled(true);
    		//int dim=dbConnectionProva.getDBSchema().getSize();
    		//****CREAZIONE PANNELLI****//
    		for(int i=0;i<dim;i++)
    			this.addTab(dbConnectionProva.getDBSchema().getTable(i).getNameTable().toUpperCase(),null,new JTabbedPane() , null);
    		
    		}
    
    	//****CREAZIONE PANNELLI INTERNI AL PANNELLO PRINCIPALE****//
    	private JTabbedPane getTbdPane(int i, JTabbedPane TbdPane) throws SQLException {
    		TbdPane.removeAll();
    		TbdPane.setName(dbConnectionProva.getDBSchema().getTable(i).getNameTable().toUpperCase());
    		TbdPane.setTabPlacement(JTabbedPane.LEFT);
    		PnlMod=new JPanel();
    		table = new JTable(dtm);
    		
    
    /*pensavo che con queste opzioni potessi colorare le righe!(quelle che gli avevo indicato nella classe precedente) invece da errore su table.get....*/ 
    
    		MioCellRenderer mcr = new MioCellRenderer();
    		//for(int i1=0;i1<dbConnectionProva.getDBSchema().getTable(i).getSize();i1++)
    		table.getColumnModel().getColumn(0).setCellRenderer(mcr); 
    
    
    				
    		TbdPane.addTab("MODIFICA", null, getPnlMod(dbConnectionProva.getDBSchema().getTable(i),dtm,table), null);
    		return TbdPane;
    	}
    
    ..........
    ..........
    ..........

    ho spiegato all'interno..
    e quindi quando si apre questo pannello, invece di venire fuori le tabelle, viene un pannello vuoto senza niente all'interno e compare l'errore

    Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0

    sapete darmi un aiuto?che comandi devo dargli?ho provato diverse cose ma non riesco a trovare la soluzione
    grazie!!

  2. #2
    Utente di HTML.it
    Registrato dal
    Dec 2005
    Messaggi
    16
    nessuno sa dirmi qualcosa?

  3. #3
    Utente di HTML.it
    Registrato dal
    Dec 2005
    Messaggi
    16
    scusate ragazzi nn voglio "rompervi"..il fatto è che ne avrei bisogno..nn sapete proprio darmi neanche uno spunto?
    o ditemi se ho sbagliato qualcosa nel fare il topic

  4. #4
    Puoi aggiungere una variabile (ad esempio un Vector) all'interno della classe MioCellRenderer. Quando calcoli le righe da colorare, aggiungi l'indice di tali righe all'interno di un Vector che poi passerai al costruttore della classe MioCellRenderer. All'interno del metodo getTableCellRendererComponent poi vai a verificare se la riga corrente è presente nel vector:


    codice:
    package datacleaning;
    
    import java.awt.Color;
    import java.awt.Component;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableCellRenderer;
    
    public class MioCellRenderer extends DefaultTableCellRenderer{
                 private Vector<Integer> righeRosse = new Vector<Integer>();
    	private static final long serialVersionUID = 1L;
    
                 public MioCellRenderer(Vector<Integer> v){
                       this.righeRosse = v;
                 }
    
    
    	public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){
    	Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
    	if(righeRosse.contains(row)) //per esempio
    		cell.setBackground( Color.red );
    	else
    		cell.setBackground( Color.white );
    	return cell;
    	}
    }
    Oppure se non vuoi utilizzare il costruttore puoi utlizzare un metodo setRigheRosse(Vector<Integer> v)
    Al mio segnale... scatenate l'inferno!

  5. #5
    Utente di HTML.it
    Registrato dal
    Nov 2007
    Messaggi
    12
    ciao a tutti, sto lavorando ad un progetto con valy12. grazie degli aiuti ma nn siamo ancora riuscite a risolvere il problema.

    se inseriamo la chiamata del metodo cellrender senza generare dinamicamente la tabella funziona e l'abbiamo fatto così...
    codice:
    private JTable getJTable() {
    			DefaultTableModel dt=new DefaultTableModel(10,5);
    			Object[] NomeColumn = new Object[5];
    			
    			for (int i=0;i<5;i++)
    				NomeColumn[i]= (String)"attributo ";
    			
    			dt.setColumnIdentifiers(NomeColumn);
    			
    			for(int i=0;i<10;i++)
    				for(int j=0;j<5;j++)
    			        dt.setValueAt(" ciao babba!!! ",i,j);
    			
    			jTable=new JTable(dt);
    			
    			Vector<Integer> righeRosse = new Vector<Integer>();
    			righeRosse.add(0);
    			MioCellRenderer mcr = new MioCellRenderer(righeRosse);
    			for(int i=0;i<5;i++)
    			jTable.getColumnModel().getColumn(i).setCellRenderer(mcr);
    			//jTable.getColumnModel().getColumn(2).setCellRenderer(mcr);
    			
    			jTable.setVisible(true);
    			jTable.setAutoscrolls(true);
    			jTable.setCellSelectionEnabled(false);
    			jTable.setEnabled(false);
    			jTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    	
    		return jTable;
    	}
    solo che se riportiamo lo stesso ragionamento quando creiamo le tabelle dinamiche non funziona!!!!!!!

    codice:
    private void initialize() throws SQLException, IOException {
    		this.setVisible(true);
    		this.setBounds(0,30,1005,572);
    		this.setEnabled(true);
    		//****CREAZIONE PANNELLI****//
    		for(int i=0;i<dim;i++){
    			this.addTab(dataBaseConnection.getDBSchema().getTable(i).getNameTable().toUpperCase(), null,new JTabbedPane() , null);
    
    		}
    		
    	}
    	
    	
    	//****CREAZIONE PANNELLI INTERNI AL PANNELLO PRINCIPALE****//
    	
    	private JTabbedPane getTbdPane(int i, JTabbedPane TbdPane) throws SQLException {
    		TbdPane.removeAll();
    		TbdPane.setName(dataBaseConnection.getDBSchema().getTable(i).getNameTable().toUpperCase());
    		TbdPane.setTabPlacement(JTabbedPane.LEFT);
    		table = new JTable(dtm);
    		SplitMod = new JSplitPane();
    		
    		Vector<Integer> righeRosse = new Vector<Integer>();
    		righeRosse.add(0);
    		MioCellRenderer mcr = new MioCellRenderer(righeRosse);
    		table.getColumnModel().getColumn(0).setCellRenderer(mcr);
    				
    		TbdPane.addTab("MODIFICA", null, getSplitMod(dataBaseConnection.getDBSchema().getTable(i)));
    		
    		return TbdPane;
    	}
    codice:
    public class MioCellRenderer extends DefaultTableCellRenderer{
    	/**
    	 * 
    	 */
    	
    	private Vector<Integer> righeRosse = new Vector<Integer>();
    	private static final long serialVersionUID = 1L;
    	
    	public MioCellRenderer(Vector<Integer> v){
    		this.righeRosse = v;
    	}
    	
    	
    	public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){
    		Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
    		if(righeRosse.contains(row)) //per esempio
    			cell.setBackground( Color.red );
    		else
    			cell.setBackground( Color.white );
    		return cell;
    }
    
    
    	/*private static final long serialVersionUID = 1L;
    
    	public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){
    	Component cell = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
    	if(row==0)
    		cell.setBackground( Color.red );
    	else
    		cell.setBackground( Color.white );
    	return cell;
    	}*/
    }
    e da l'errore...


    Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0 sulla riga table.getColumnModel().getColumn(0).setCellRendere r(mcr);

    ed inoltre riporta L'ERRORE sull'evento...

    codice:
    	public void stateChanged(ChangeEvent arg0){
    
    		if (arg0.getSource().getClass().toString().equals(Tool.class.toString()))
    		{
    			JTabbedPane TbdPane = (JTabbedPane) arg0.getSource(); //nn ho capito questo passaggio!
    			typeRich = TbdPane.getSelectedIndex();
    			System.out.println("numerooo"+typeRich);
    			
    			System.out.println("Questo è quello che torna:"+  TbdPane.getSelectedComponent().getClass().toString());
    			if(typeRich<dataBaseConnection.getDBSchema().getSize()){
    				try {
    					getTbdPane(typeRich, (JTabbedPane) TbdPane.getSelectedComponent());
    				} catch (SQLException e) {
    					e.printStackTrace();
    				}
    			}
    		}
    		
    	}

  6. #6
    Come viene generata la variabile dtm nella riga table = new JTable(dtm); ?

    Dal codice non lo vedo.
    Al mio segnale... scatenate l'inferno!

  7. #7
    Utente di HTML.it
    Registrato dal
    Nov 2007
    Messaggi
    12
    scusatemi tanto del ritardo ma sn stata presa da molte cose e ... per risponderti dovevo rivedere bene il codice... sai a volte dopo tanto tempo ti dimentichi quello che hai scritto!!!


    ecco qui, il dtm viene creato proprio qui all'inizio di questo metodo che identifica la tabella le cui righe vanno poi colorate....
    codice:
    private JTable getTblMod(final table t,DefaultTableModel dtm,final JTable table) throws SQLException {
    //		Nomi delle colonne
    		String str = "SELECT * FROM " + t.getNameTable();
    		final ResultSet rs=dataBaseConnection.queryDb(str);
    		rs.last();
    		//invece che +2 è +1
    		
    			dtm = new DefaultTableModel (rs.getRow(),t.getSize()+1);
    		final DefaultTableModel dtm1=new DefaultTableModel (rs.getRow(),t.getSize()+1);
    		 
    		
    //		invece che +2 è +1
    		Object[] NomeColumn = new Object[t.getSize()+1];
    		for (int i=0;i<t.getSize();i++)
    			NomeColumn[i]= (String) t.getAttibutes(i).getName();
    		//NomeColumn[t.getSize()]=("CANCELLA");
    		//era getSize+1
    		NomeColumn[t.getSize()]=("MODIFICA");
    		
    		int r=0;
    		rs.beforeFirst();
    		while (rs.next()) {
    			for(int c=0; c<t.getSize();c++){
    				System.out.println(rs.getString(c+1));
    				dtm.setValueAt(rs.getString(c+1),r,c);
    				dtm1.setValueAt(rs.getString(c+1),r,c);
    			}
    			JButton buttonMod = new JButton(new ImageIcon("swing/Img/matita giusta.jpg"));
    			dtm1.setValueAt(buttonMod,r,t.getSize());
    						
    			//era getsize+1
    			dtm.setValueAt(buttonMod,r,t.getSize());
    			buttonMod.setBackground(new java.awt.Color(207,203,238));
    			//Aggiungo dei listener ai bottoni, al loro interno andra' il codice per la rimozione
    			buttonMod.addMouseListener(new java.awt.event.MouseAdapter() {
    				public void mouseClicked(java.awt.event.MouseEvent e) {	
    					System.out.println("riga selezionata: "+table.getSelectedRow());
    					int i=0;
    					int riga=table.getSelectedRow();
    					
    					ArrayList <String> Kiave=new ArrayList <String>();
    					Kiave=t.getNameKey();
    					String query=new String("UPDATE "+dataBaseConnection.getDBSchema().getName()+"."+t.getNameTable()+" SET "); 
    					//query=query+(t.getNameTable()+"."+Kiave.get(0)+" USING utf8)='"+table.getValueAt(riga,t.getKeyColumn().get(0))+"'");
    					query=query+(t.getAttibutes(0).getName()+" = '"+table.getValueAt(riga,0)+"'");
    					for(i=1;i<t.getSize();i++){
    						query=query+(", "+t.getAttibutes(i).getName()+" = '"+table.getValueAt(riga,i).toString()+"'");
    					}
    					if(Kiave.size()==1)
    						query=query+(" WHERE "+t.getNameTable()+"."+Kiave.get(0)+" ='"+dtm1.getValueAt(riga,t.getKeyColumn().get(0))+"'");
    					else{
    						query=query+(" WHERE CONVERT ("+t.getNameTable()+"."+Kiave.get(0)+" USING utf8 ) ='"+dtm1.getValueAt(riga,t.getKeyColumn().get(0))+"'");
    						for(i=1;i<Kiave.size();i++){
    							query=query+(" AND CONVERT ("+t.getNameTable()+"."+Kiave.get(i)+" USING utf8 ) ='"+dtm1.getValueAt(riga,t.getKeyColumn().get(i))+"'");
    							
    						}
    					}	
    					query=query+(" LIMIT 1");
    					System.out.println("queryyyyyyyyyyyyyyyyyyyyyyy "+query);
    					try {
    						@SuppressWarnings("unused") int rsMod=dataBaseConnection.updateDb(query);
    					} catch (SQLException e1) {
    						JOptionPane.showMessageDialog(null,"LOOK OUT!!!: "+e1.getMessage(),"ATTENZIONE",2);
    						
    					}
    					
    					
    					
    				}
    			} );	
    			r++;
    		}
    		dtm.setColumnIdentifiers(NomeColumn);
    		
    		table.setModel(dtm);
    		
    		// Alla terza colonna,identificata per nome, applico l'editor e il render personalizzati.
    		table.getColumn("MODIFICA").setCellRenderer(new PanelRender());
    		table.getColumn("MODIFICA").setCellEditor(new PanelEditor());
    		table.setRowHeight(25); //Metto un altezza che mi consenta di vedere tutto il bottone
    		table.setEnabled(true);
    		table.setRowSelectionAllowed(true);
    		table.getColumnSelectionAllowed();
    		table.setAutoscrolls(true);
    		table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    		table.setVisible(true);
    		return table;
    	}


    la classe per intero è come segue....

    codice:
    public class Tool extends JTabbedPane implements ChangeListener{
    	
    	
    	private static final long serialVersionUID = 1L;
    	CallReadFile crf=new CallReadFile();
    	
    	
    	/*FRAME CONTENITORE*/
    	JFrame f=new JFrame("DATA CLEANING");
    	DefaultTableModel dtm;
    	int n;
    	
    	/*PANNELLO MENU*/
    	private JPanel MenuSup=new JPanel();;
    	private JLabel LblEsci = null;
    	private JLabel LblDisc = null;
    	private JLabel LblRefresh=null;
    	
    	/*PANNELLO MODIFICA*/
    	private JSplitPane SplitMod;
    	private JPanel PnlLog;
    	private JPanel PnlMod;
    	private JScrollPane ScrollPaneMuseoMod;
    	public JTable table;
    	private JScrollPane jScrollPane;
    	private JEditorPane jEditorPane;
    	
    	
    	
    	/*ALTRE VARIABILI */
    	public int typeRich;
    	int dim=dataBaseConnection.getDBSchema().getSize();
    	ReadNumMetriche rnm=new ReadNumMetriche();
    	
    	
    	//****MENU CHIAMA TUTTO****//
    	public Tool() {
    		super();
    		try {
    			this.initialize();
    			f.setSize(1000,630);
    			f.add(this);
    			f.add(getMenuSup(),null);
    			f.setVisible(true);
    			f.setResizable(false);
    		} catch (SQLException e) {
    			e.printStackTrace();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    		
    		this.addChangeListener(this);	
    		this.setSelectedIndex(1);
    		this.setSelectedIndex(0);
    	}
    	//****MENU INITIALIZE****//
    	private void initialize() throws SQLException, IOException {
    		this.setVisible(true);
    		this.setBounds(0,30,1005,572);
    		this.setEnabled(true);
    		//****CREAZIONE PANNELLI****//
    		for(int i=0;i<dim;i++){
    			this.addTab(dataBaseConnection.getDBSchema().getTable(i).getNameTable().toUpperCase(), null,new JTabbedPane() , null);
    
    		}
    		
    	}
    	
    	
    	//****CREAZIONE PANNELLI INTERNI AL PANNELLO PRINCIPALE****//
    	
    	private JTabbedPane getTbdPane(int i, JTabbedPane TbdPane) throws SQLException {
    		TbdPane.removeAll();
    		TbdPane.setName(dataBaseConnection.getDBSchema().getTable(i).getNameTable().toUpperCase());
    		TbdPane.setTabPlacement(JTabbedPane.LEFT);
    		table = new JTable(dtm);
    		SplitMod = new JSplitPane();
    		
    
     //QUI HO PROVATO A COLORARE LE RIGHE MA NULLA DA FARE, SE LE METTO MI SI BLOCCA TUTTA LA SCHERMATA...
    		/*Vector<Integer> righeRosse = new Vector<Integer>();
    		righeRosse.add(0);
    		MioCellRenderer mcr = new MioCellRenderer(righeRosse);
    		table.getColumnModel().getColumn(0).setCellRenderer(mcr);*/
     
    				
    		TbdPane.addTab("MODIFICA", null, getSplitMod(dataBaseConnection.getDBSchema().getTable(i)));
    		
    		return TbdPane;
    	}
    	
    //	SPLITPANE MODIFICA
    
    	private JSplitPane getSplitMod(table t) throws SQLException {
    			ScrollPaneMuseoMod=new JScrollPane();
    			PnlLog=new JPanel();
    			SplitMod.setDividerSize(3);
    			SplitMod.setDividerLocation(250);
    			SplitMod.setLayout(null);
    			SplitMod.setOrientation(JSplitPane.VERTICAL_SPLIT);
    			SplitMod.setTopComponent(getScrollPaneMod(t,dtm,table));
    			SplitMod.setBottomComponent(getPnlLog());
    			SplitMod.setVisible(true);
    		return SplitMod;
    	}
    	
    //	SCROLL DELLA TABELLA DEL MUSEO
    	private JScrollPane getScrollPaneMod(table t,DefaultTableModel dtm,JTable table) throws SQLException {
    		ScrollPaneMuseoMod.setBounds(new java.awt.Rectangle(0,0,842,533));
    		table=new JTable();
    		ScrollPaneMuseoMod.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(238,238,238),5));
    		ScrollPaneMuseoMod.setViewportView(getTblMod(t,dtm,table));
    		return ScrollPaneMuseoMod;
    	}
    	
    //	TABELLA MUSEO
    	private JTable getTblMod(final table t,DefaultTableModel dtm,final JTable table) throws SQLException {
    //		Nomi delle colonne
    		String str = "SELECT * FROM " + t.getNameTable();
    		final ResultSet rs=dataBaseConnection.queryDb(str);
    		rs.last();
    		//invece che +2 è +1
    		dtm = new DefaultTableModel (rs.getRow(),t.getSize()+1);
    		final DefaultTableModel dtm1=new DefaultTableModel (rs.getRow(),t.getSize()+1);
    		
    //		invece che +2 è +1
    		Object[] NomeColumn = new Object[t.getSize()+1];
    		for (int i=0;i<t.getSize();i++)
    			NomeColumn[i]= (String) t.getAttibutes(i).getName();
    		//NomeColumn[t.getSize()]=("CANCELLA");
    		//era getSize+1
    		NomeColumn[t.getSize()]=("MODIFICA");
    		
    		int r=0;
    		rs.beforeFirst();
    		while (rs.next()) {
    			for(int c=0; c<t.getSize();c++){
    				System.out.println(rs.getString(c+1));
    				dtm.setValueAt(rs.getString(c+1),r,c);
    				dtm1.setValueAt(rs.getString(c+1),r,c);
    			}
    			JButton buttonMod = new JButton(new ImageIcon("swing/Img/matita giusta.jpg"));
    			dtm1.setValueAt(buttonMod,r,t.getSize());
    						
    			//era getsize+1
    			dtm.setValueAt(buttonMod,r,t.getSize());
    			buttonMod.setBackground(new java.awt.Color(207,203,238));
    			//Aggiungo dei listener ai bottoni, al loro interno andra' il codice per la rimozione
    			buttonMod.addMouseListener(new java.awt.event.MouseAdapter() {
    				public void mouseClicked(java.awt.event.MouseEvent e) {	
    					System.out.println("riga selezionata: "+table.getSelectedRow());
    					int i=0;
    					int riga=table.getSelectedRow();
    					
    					ArrayList <String> Kiave=new ArrayList <String>();
    					Kiave=t.getNameKey();
    					String query=new String("UPDATE "+dataBaseConnection.getDBSchema().getName()+"."+t.getNameTable()+" SET "); 
    					//query=query+(t.getNameTable()+"."+Kiave.get(0)+" USING utf8)='"+table.getValueAt(riga,t.getKeyColumn().get(0))+"'");
    					query=query+(t.getAttibutes(0).getName()+" = '"+table.getValueAt(riga,0)+"'");
    					for(i=1;i<t.getSize();i++){
    						query=query+(", "+t.getAttibutes(i).getName()+" = '"+table.getValueAt(riga,i).toString()+"'");
    					}
    					if(Kiave.size()==1)
    						query=query+(" WHERE "+t.getNameTable()+"."+Kiave.get(0)+" ='"+dtm1.getValueAt(riga,t.getKeyColumn().get(0))+"'");
    					else{
    						query=query+(" WHERE CONVERT ("+t.getNameTable()+"."+Kiave.get(0)+" USING utf8 ) ='"+dtm1.getValueAt(riga,t.getKeyColumn().get(0))+"'");
    						for(i=1;i<Kiave.size();i++){
    							query=query+(" AND CONVERT ("+t.getNameTable()+"."+Kiave.get(i)+" USING utf8 ) ='"+dtm1.getValueAt(riga,t.getKeyColumn().get(i))+"'");
    							
    						}
    					}	
    					query=query+(" LIMIT 1");
    					System.out.println("queryyyyyyyyyyyyyyyyyyyyyyy "+query);
    					try {
    						@SuppressWarnings("unused") int rsMod=dataBaseConnection.updateDb(query);
    					} catch (SQLException e1) {
    						JOptionPane.showMessageDialog(null,"LOOK OUT!!!: "+e1.getMessage(),"ATTENZIONE",2);
    						
    					}
    					
    					
    					
    				}
    			} );	
    			r++;
    		}
    		dtm.setColumnIdentifiers(NomeColumn);
    		
    		table.setModel(dtm);
    		
    		// Alla terza colonna,identificata per nome, applico l'editor e il render personalizzati.
    		table.getColumn("MODIFICA").setCellRenderer(new PanelRender());
    		table.getColumn("MODIFICA").setCellEditor(new PanelEditor());
    		table.setRowHeight(25); //Metto un altezza che mi consenta di vedere tutto il bottone
    		table.setEnabled(true);
    		table.setRowSelectionAllowed(true);
    		table.getColumnSelectionAllowed();
    		table.setAutoscrolls(true);
    		table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    		table.setVisible(true);
    		return table;
    	}

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.