Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di 1sirena
    Registrato dal
    Mar 2008
    Messaggi
    163

    Jframe - inserimento Jpanel (problema Jtable)

    salve a tutti!!! come avrete capito dal titolo del topic ... ho un problema!!!

    sono riuscita a realizzare in un'unica finestra (jdialog) la creazione di una table e di un panel, all'interno del quale sono presenti delle textfield, delle label e dei bottoni tramite il quale vengono gestite la cancellazione, la modifica e l'aggiornamento della table, con l'aggiunta o la cancellazione dal db e della riga relativa della jtable ...

    il nostro problema sta' nel fatto di creare un frame, all'interno del quale inserire 2 jpanel, in 1 andra' la jtable e nell'altro i bottoni e le textfield.

    sono riuscita ad inserire nel frame i due panel, ma il Row Listener da' problemi!!!

    allego quindi il codice funzionante:
    1) jdialog jtable e panel

    codice:
    package org.schedule.Admin;
    
    import *;
    
    public class DatiDocenti_Admin {
    	private JTable t;
    	public Connection conn;
    	public JButton cancella;
    	public JButton modifica;
    
    	public JButton aggiorna;
    	public JTextField id;
    	public JTextField password;
    	public JTextField nominativo;
    	public JTextField username;
    	public JTextField img;
    	public JTextField dipartimento;
    	public JTextField email;
    	public JTextField tipo;
    	public JTextField fax;
    
    	public JTextField jTextField1;
    	
    	public JTextField telefono;
    
    	public void leggitabella2(ActionEvent e) throws SQLException{
    
    		// costruzione nuova finestra
    
    		JDialog finestra2 = new JDialog();
    
    		@SuppressWarnings("unused")
    		//JTextArea lavagna2 = new JTextArea();
    		Font f2 = new Font(null, Font.BOLD,15); 
    		ModTab miomodello = new ModTab("utente");
    		t = new JTable(miomodello);
    		t.setPreferredScrollableViewportSize(new Dimension(1000, 90));
    		t.getSelectionModel().addListSelectionListener(new RowListener());
    
    		/* Pulsante per cambiare i dati di un record. */
    
    		/*Pulsante per cancellare i dati di un record*/
    
    		finestra2.add("North", t);
    
    		finestra2.add(t);
    		{
    			JPanel PannelloBottoni = new JPanel();
    			finestra2.getContentPane().add(PannelloBottoni, BorderLayout.SOUTH);
    			{
    				nominativo = new JTextField();
    				PannelloBottoni.add(nominativo);
    				nominativo.setBounds(320, 85, 196, 22);
    			}
    			{
    				username = new JTextField();
    				PannelloBottoni.add(username);
    				username.setBounds(541, 84, 233, 22);
    			}
    			{
    				password = new JTextField();
    				PannelloBottoni.add(password);
    				password.setBounds(786, 82, 199, 22);
    			}
    			{
    				id = new JTextField();
    				PannelloBottoni.add(id);
    				id.setBounds(36, 85, 275, 22);
    				id.setEnabled(false);
    			}
    			{
    				cancella = new JButton();
    				PannelloBottoni.add(cancella);
    				cancella.setBounds(94, 238, 256, 85);
    				cancella.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/BottoneCancella.png")));
    				cancella.setBackground(new java.awt.Color(255,128,255));
    				cancella.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    				cancella.setOpaque(false);
    				cancella.setBorderPainted(false);
    				cancella.setDebugGraphicsOptions(DebugGraphics.BUFFERED_OPTION);
    				cancella.setRolloverIcon(new ImageIcon(getClass().getResource("/img/BottoneCancella2.png")));
    				cancella.setPressedIcon(new ImageIcon(getClass().getResource("/img/BottoneCancella3.png")));
    				cancella.setMnemonic(KeyEvent.VK_UNDEFINED);
    				cancella.setFocusCycleRoot(true);
    				cancella.setSelected(true);
    				cancella.setFocusPainted(false);
    				cancella.setFocusTraversalPolicyProvider(true);
    				cancella.setContentAreaFilled(false);
    				
    				cancella.addActionListener(new ActionListener(){
    					public void actionPerformed(ActionEvent e) { 
    						try {
    							//System.out.println("ciao....");
    							cancellaRiga(e);
    						//	Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(getContentPane());
    						} catch (SQLException ex) {
    							ex.printStackTrace();
    						} catch (ClassNotFoundException ex) {
    							ex.printStackTrace();
    						}
    					}
    				});
    			}
    			{
    				modifica = new JButton ("");
    				PannelloBottoni.add(modifica);
    				modifica.setBounds(510, 238, 256, 85);
    				modifica.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/BottoneModifica.png")));
    				modifica.setBackground(new java.awt.Color(255,128,255));
    				modifica.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    				modifica.setOpaque(false);
    				modifica.setBorderPainted(false);
    				modifica.setDebugGraphicsOptions(DebugGraphics.BUFFERED_OPTION);
    				modifica.setRolloverIcon(new ImageIcon(getClass().getResource("/img/BottoneModifica2.png")));
    				modifica.setPressedIcon(new ImageIcon(getClass().getResource("/img/BottoneModifica3.png")));
    				modifica.setMnemonic(KeyEvent.VK_UNDEFINED);
    				modifica.setFocusCycleRoot(true);
    				modifica.setSelected(true);
    				modifica.setFocusPainted(false);
    				modifica.setFocusTraversalPolicyProvider(true);
    				modifica.setContentAreaFilled(false);
    
    				
    				modifica.addActionListener(new ActionListener() {
    					public void actionPerformed(ActionEvent e) { 
    						try {
    							//System.out.println("ciao....");
    							modificaarchivio(e);
    						} catch (SQLException ex) {
    							ex.printStackTrace();
    						} catch (ClassNotFoundException ex) {
    							ex.printStackTrace();
    						}
    					}
    				});
    			}
    			{
    				aggiorna = new JButton ();
    				PannelloBottoni.add(aggiorna);
    				aggiorna.setBounds(893, 238, 256, 85);
    				aggiorna.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/BottoneAggiorna.png")));
    				aggiorna.setBackground(new java.awt.Color(255,128,255));
    				aggiorna.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    				aggiorna.setOpaque(false);
    				aggiorna.setBorderPainted(false);
    				aggiorna.setDebugGraphicsOptions(DebugGraphics.BUFFERED_OPTION);
    				aggiorna.setRolloverIcon(new ImageIcon(getClass().getResource("/img/BottoneAggiorna2.png")));
    				aggiorna.setPressedIcon(new ImageIcon(getClass().getResource("/img/BottoneAggiorna3.png")));
    				aggiorna.setMnemonic(KeyEvent.VK_UNDEFINED);
    				aggiorna.setFocusCycleRoot(true);
    				aggiorna.setSelected(true);
    				aggiorna.setFocusPainted(false);
    				aggiorna.setFocusTraversalPolicyProvider(true);
    				aggiorna.setContentAreaFilled(false);
    
    				aggiorna.addActionListener(new ActionListener(){
    					public void actionPerformed(ActionEvent e){
    						try {
    							leggitabella2(e);
    						} catch (SQLException ex) {
    							ex.printStackTrace();
    						} 
    					}
    				});
    			}
    			{
    				JLabel labnominativo = new JLabel("");
    				PannelloBottoni.add(labnominativo);
    				labnominativo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Nominativo.png")));
    				labnominativo.setBounds(318, 60, 159, 26);
    			}
    			{
    				JLabel labusername = new JLabel ("");
    				PannelloBottoni.add(labusername);
    				labusername.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/username.png")));
    				labusername.setBounds(547, 59, 174, 26);
    			}
    			{
    				JLabel labpassword = new JLabel ("");
    				PannelloBottoni.add(labpassword);
    				labpassword.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Password.png")));
    				labpassword.setBounds(781, 59, 198, 26);
    			}
    			{
    				JLabel labid = new JLabel ("") ;
    				PannelloBottoni.add(labid);
    				labid.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Id utente.png")));
    				labid.setBounds(36, 59, 238, 29);
    			}
    			{
    				telefono = new JTextField();
    				PannelloBottoni.add(telefono);
    				telefono.setBounds(324, 178, 192, 22);
    			}
    			{
    				JLabel labtelefono = new JLabel("");
    				PannelloBottoni.add(labtelefono);
    				labtelefono.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Telefono.png")));
    				labtelefono.setBounds(324, 151, 238, 29);
    			}
    			{
    				fax = new JTextField();
    				PannelloBottoni.add(fax);
    				fax.setBounds(547, 176, 224, 22);
    			}
    			{
    				tipo = new JTextField();
    				PannelloBottoni.add(tipo);
    				tipo.setBounds(1004, 82, 233, 22);
    			}
    			{
    				email = new JTextField();
    				PannelloBottoni.add(email);
    				email.setBounds(789, 176, 198, 22);
    			}
    			{
    				dipartimento = new JTextField();
    				PannelloBottoni.add(dipartimento);
    				dipartimento.setBounds(40, 178, 275, 22);
    			}
    			{
    				img = new JTextField();
    				PannelloBottoni.add(img);
    				img.setBounds(1005, 177, 203, 22);
    			}
    			{
    				JLabel labfax = new JLabel("");
    				PannelloBottoni.add(labfax);
    				labfax.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Fax.png")));
    				labfax.setBounds(547, 149, 159, 29);
    			}
    			{
    				JLabel labtipo = new JLabel ("");
    				PannelloBottoni.add(labtipo);
    				labtipo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Tipo Utente.png")));
    				labtipo.setBounds(998, 57, 238, 29);
    			}
    			{
    				JLabel labemail = new JLabel ("");
    				PannelloBottoni.add(labemail);
    				labemail.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/E-mail.png")));
    				labemail.setBounds(789, 148, 167, 29);
    			}
    			{
    				JLabel labdipartimento = new JLabel("");
    				PannelloBottoni.add(labdipartimento);
    				labdipartimento.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Dipartimento.png")));
    				labdipartimento.setBounds(39, 151, 275, 29);
    			}
    			{
    				JLabel labimmagine = new JLabel("") ;
    				PannelloBottoni.add(labimmagine);
    				labimmagine.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Foto.png")));
    				labimmagine.setBounds(1005, 150, 238, 29);
    			}
    		
    			
    			
    		
    			
    			PannelloBottoni.setLayout(null);
    			PannelloBottoni.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
    			PannelloBottoni.setBackground(new Color(0, 51, 255));
    			PannelloBottoni.setPreferredSize(new java.awt.Dimension(927, 367));
    		}
    		finestra2.setFont(f2);
    		finestra2.setTitle("Dati Docenti");
    		finestra2.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/img/logo_uni.png")));
    		finestra2.setSize(1280, 775);
    		//finestra2.setLocation(0,0);
    		finestra2.setVisible(true); 
    		finestra2.setLayout(new BorderLayout());
    		finestra2.add(BorderLayout.NORTH,new JScrollPane(t)); 
    		finestra2.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); 
    
    
    
    		} // fine leggitabella 
    
    		private class RowListener implements ListSelectionListener {
    		    public void valueChanged(ListSelectionEvent event) {
    		        if (event.getValueIsAdjusting()) {
    		            return;
    		            
    		        }
    		        int row = t.getSelectedRow();
    				System.out.println("hai selezionato la riga:" + row);
    
    				id.setText ((String) t.getValueAt (row,0));
    				nominativo.setText ((String) t.getValueAt (row,1));
    				username.setText ((String) t.getValueAt (row,2));
    				password.setText ((String) t.getValueAt (row,3));
    				tipo.setText ((String) t.getValueAt (row,4));
    				dipartimento.setText ((String) t.getValueAt (row,5));
    				telefono.setText ((String) t.getValueAt (row,6));
    				fax.setText ((String) t.getValueAt (row,7));
    				email.setText ((String) t.getValueAt (row,8));
    				img.setText ((String) t.getValueAt (row,9));
    		    
    		    }
    
    			}
    		public void cancellaRiga(ActionEvent e)throws SQLException, ClassNotFoundException{
    			
    
    			SQLManager sqlm =  new SQLManager ("com.mysql.jdbc.Driver","jdbc:mysql://localhost:3306/schedule","root","root");
    			
    			String query = "delete from utente where id_utente = '"+ id.getText() +"'";
    			
    
    			 sqlm.esegui(query); 
    		sqlm.close(); 
    
    		nominativo.setText(""); 
    		username.setText(""); 
    		password.setText("");  
    		id.setText("");
    		telefono.setText("");
    		fax.setText("");
    		tipo.setText ("");
    		email.setText ("");
    		dipartimento.setText ("");
    		img.setText ("");
    
    
    		}
    		public void modificaarchivio(ActionEvent e)throws SQLException, ClassNotFoundException{
    			
    
    			SQLManager sqlm = new SQLManager("com.mysql.jdbc.Driver","jdbc:mysql://localhost:3306/schedule","root","root");
    			
    			String query = "update Utente set nominativo = '"+ nominativo.getText()+"', username= '"+ username.getText() +"', password ='"+ password.getText() +"', tipo_utente = '"+ tipo.getText() +"'," +
    			" dipartimento = '"+ dipartimento.getText() +"', telefono = '"+ telefono.getText() +"',fax = '"+ fax.getText() +"',  email = '"+ email.getText() +"'," +
    					" img ='"+ img.getText() +"' where  id_utente = '"+ id.getText() +"'";
    
    			
    			 sqlm.esegui(query); 
    		sqlm.close(); 
    
    		nominativo.setText(""); 
    		username.setText(""); 
    		password.setText("");  
    		id.setText("");
    		telefono.setText ("");
    		fax.setText ("");
    		tipo.setText ("");
    		email.setText ("");
    		dipartimento.setText ("");
    		img.setText ("");
    
    		}
    		
    		
    		
    
    }

  2. #2
    Utente di HTML.it L'avatar di 1sirena
    Registrato dal
    Mar 2008
    Messaggi
    163

    2^ PARTE

    2)jframe 2panel(1jtable e 1panelBottoni)

    - Frame
    codice:
    package Schedule.PannelloBottoni;
    
    import j*;
    
    public class Frame extends JFrame {
    
    	private static final long serialVersionUID = 1L;
    	private JPanel jContentPane = null;
    	public  Bottoni bottoni;
    	public Tabella tab;
    
    	/**
    	 * This is the default constructor
    	 */
    	public Frame() {
    		super();
    		this.setSize(1300, 800);
    		this.setContentPane(getJContentPane());
    		this.setTitle("JFrame");		
    	}
    
    	
    
    	private JPanel getJContentPane() {
    		if (jContentPane == null) {
    			jContentPane = new JPanel();
    			jContentPane.setLayout(null);
    			jContentPane.setBackground(new Color(204, 0, 204));
    			
    			Tabella tab = new Tabella();
    			jContentPane.add("NORTH", tab);
    			tab.setBounds(0, 0, 1284, 400);
    			//tab.setBounds();
    
    			Bottoni bottoni= new Bottoni();
    			jContentPane.add("SOUTH", bottoni);
    			bottoni.setBounds(0, 398, 1284, 365);
    			//bottoni.setBounds();
    
    		}
    		return jContentPane;
    	}
    
    }
    -Tabella
    codice:
    package Schedule.PannelloBottoni;
    
    
    import *;
    
    public class Tabella extends JPanel {
    
    	@SuppressWarnings("unused")
    	private JTable t;
    	private static final long serialVersionUID = 1L;
    	public Connection conn;
    	public JButton cancella;
    	public JButton modifica;
    
    	public JButton aggiorna;
    	
    
    			
    
    
    	public Tabella() {
    		super();
    		initialize();
    		
    		
    		ModTab miomodello = new ModTab("utente");
    		//t.getSelectionModel().addListSelectionListener(new RowListener());
    
    //		this.add( t);
    		{
    			t = new JTable(miomodello);
    			this.add(t);
    			t.setPreferredScrollableViewportSize(new Dimension(1000, 90));
    			t.setBounds(0, 0, 1300, 139);
    		}
    		
    
    
    
    		/* Pulsante per cambiare i dati di un record. */
    
    		/*Pulsante per cancellare i dati di un record*/
    
    
    
    		
    	}
    
    	
    	private void initialize() {
    		this.setSize(1300, 400);
    		this.setLayout(null);
    		this.setName("this");
    		
    	}
    
    	/*
    	private class RowListener implements ListSelectionListener {
    	    public void valueChanged(ListSelectionEvent event) {
    	        if (event.getValueIsAdjusting()) {
    	            return;
    	            
    	        }
    	        int row = t.getSelectedRow();
    	        Bottoni b = new Bottoni();
    	        
    			System.out.println("hai selezionato la riga:" + row);
    
    			b.id.setText ((String) t.getValueAt (row,0));
    			b.nominativo.setText ((String) t.getValueAt (row,1));
    			b.username.setText ((String) t.getValueAt (row,2));
    			b.password.setText ((String) t.getValueAt (row,3));
    			b.tipo.setText ((String) t.getValueAt (row,4));
    			b.dipartimento.setText ((String) t.getValueAt (row,5));
    			b.telefono.setText ((String) t.getValueAt (row,6));
    			b.fax.setText ((String) t.getValueAt (row,7));
    			b.email.setText ((String) t.getValueAt (row,8));
    			b.img.setText ((String) t.getValueAt (row,9));
    	    
    	    }
    
    	}
    	*/
    	}

  3. #3
    Utente di HTML.it L'avatar di 1sirena
    Registrato dal
    Mar 2008
    Messaggi
    163

    3^ PARTE

    -Bottoni
    codice:
    package Schedule.PannelloBottoni;
    
    import *;
    
    public class Bottoni extends JPanel {
    	public JButton cancella;
    	public JTable t;
    	public JButton modifica;
    
    	public JButton aggiorna;
    	public JTextField id;
    	public JTextField password;
    	public JTextField nominativo;
    	public JTextField username;
    	public JTextField img;
    	public JTextField dipartimento;
    	public JTextField email;
    	public JTextField tipo;
    	public JTextField fax;
    
    	
    	
    	public JTextField telefono;
    
    	private static final long serialVersionUID = 1L;
    
    	public Bottoni() {
    		super();
    		initialize();
    
    		{
    			nominativo = new JTextField();
    			this.add(nominativo);
    			nominativo.setBounds(274, 85, 242, 22);
    		}
    		{
    			username = new JTextField();
    			this.add(username);
    			username.setBounds(541, 84, 233, 22);
    		}
    		{
    			password = new JTextField();
    			this.add(password);
    			password.setBounds(786, 82, 199, 22);
    		}
    		{
    			id = new JTextField();
    			this.add(id);
    			id.setBounds(36, 85, 204, 22);
    			id.setEnabled(false);
    		}
    		{
    			cancella = new JButton();
    			this.add(cancella);
    			cancella.setBounds(94, 238, 256, 85);
    			cancella.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/BottoneCancella.png")));
    			cancella.setBackground(new java.awt.Color(255,128,255));
    			cancella.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    			cancella.setOpaque(false);
    			cancella.setBorderPainted(false);
    			cancella.setDebugGraphicsOptions(DebugGraphics.BUFFERED_OPTION);
    			cancella.setRolloverIcon(new ImageIcon(getClass().getResource("/img/BottoneCancella2.png")));
    			cancella.setPressedIcon(new ImageIcon(getClass().getResource("/img/BottoneCancella3.png")));
    			cancella.setMnemonic(KeyEvent.VK_UNDEFINED);
    			cancella.setFocusCycleRoot(true);
    			cancella.setSelected(true);
    			cancella.setFocusPainted(false);
    			cancella.setFocusTraversalPolicyProvider(true);
    			cancella.setContentAreaFilled(false);
    			
    			cancella.addActionListener(new ActionListener(){
    				public void actionPerformed(ActionEvent e) { 
    					try {
    						//System.out.println("ciao....");
    						cancellaRiga(e);
    					//	Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(getContentPane());
    					} catch (SQLException ex) {
    						ex.printStackTrace();
    					} catch (ClassNotFoundException ex) {
    						ex.printStackTrace();
    					}
    				}
    			});
    		}
    		{
    			modifica = new JButton ("");
    			this.add(modifica);
    			modifica.setBounds(510, 238, 256, 85);
    			modifica.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/BottoneModifica.png")));
    			modifica.setBackground(new java.awt.Color(255,128,255));
    			modifica.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    			modifica.setOpaque(false);
    			modifica.setBorderPainted(false);
    			modifica.setDebugGraphicsOptions(DebugGraphics.BUFFERED_OPTION);
    			modifica.setRolloverIcon(new ImageIcon(getClass().getResource("/img/BottoneModifica2.png")));
    			modifica.setPressedIcon(new ImageIcon(getClass().getResource("/img/BottoneModifica3.png")));
    			modifica.setMnemonic(KeyEvent.VK_UNDEFINED);
    			modifica.setFocusCycleRoot(true);
    			modifica.setSelected(true);
    			modifica.setFocusPainted(false);
    			modifica.setFocusTraversalPolicyProvider(true);
    			modifica.setContentAreaFilled(false);
    
    			
    			modifica.addActionListener(new ActionListener() {
    				public void actionPerformed(ActionEvent e) { 
    					try {
    						//System.out.println("ciao....");
    						modificaarchivio(e);
    					} catch (SQLException ex) {
    						ex.printStackTrace();
    					} catch (ClassNotFoundException ex) {
    						ex.printStackTrace();
    					}
    				}
    			});
    		}
    		{
    			aggiorna = new JButton ();
    			this.add(aggiorna);
    			aggiorna.setBounds(897, 239, 256, 85);
    			aggiorna.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/BottoneAggiorna.png")));
    			aggiorna.setBackground(new java.awt.Color(255,128,255));
    			aggiorna.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    			aggiorna.setOpaque(false);
    			aggiorna.setBorderPainted(false);
    			aggiorna.setDebugGraphicsOptions(DebugGraphics.BUFFERED_OPTION);
    			aggiorna.setRolloverIcon(new ImageIcon(getClass().getResource("/img/BottoneAggiorna2.png")));
    			aggiorna.setPressedIcon(new ImageIcon(getClass().getResource("/img/BottoneAggiorna3.png")));
    			aggiorna.setMnemonic(KeyEvent.VK_UNDEFINED);
    			aggiorna.setFocusCycleRoot(true);
    			aggiorna.setSelected(true);
    			aggiorna.setFocusPainted(false);
    			aggiorna.setFocusTraversalPolicyProvider(true);
    			aggiorna.setContentAreaFilled(false);
    
    			aggiorna.addActionListener(new ActionListener(){
    				public void actionPerformed(ActionEvent e){
    					try {
    						
    						
    						DatiDocenti_Admin d= new DatiDocenti_Admin();
    						d.leggitabella2(e);
    						//taleggitabella2bella = aggiornaTabella();
    						//
    					} catch (SQLException ex) {
    						ex.printStackTrace();
    					} 
    				}
    			});
    		}
    		{
    			JLabel labnominativo = new JLabel("");
    			this.add(labnominativo);
    			labnominativo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Nominativo.png")));
    			labnominativo.setBounds(280, 60, 238, 26);
    		}
    		{
    			JLabel labusername = new JLabel ("");
    			this.add(labusername);
    			labusername.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/username.png")));
    			labusername.setBounds(547, 59, 221, 26);
    		}
    		{
    			JLabel labpassword = new JLabel ("");
    			this.add(labpassword);
    			labpassword.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Password.png")));
    			labpassword.setBounds(781, 59, 198, 26);
    		}
    		{
    			JLabel labid = new JLabel ("") ;
    			this.add(labid);
    			labid.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Id utente.png")));
    			labid.setBounds(36, 59, 238, 29);
    		}
    		{
    			telefono = new JTextField();
    			this.add(telefono);
    			telefono.setBounds(324, 178, 192, 22);
    		}
    		{
    			JLabel labtelefono = new JLabel("");
    			this.add(labtelefono);
    			labtelefono.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Telefono.png")));
    			labtelefono.setBounds(324, 151, 238, 29);
    		}
    		{
    			fax = new JTextField();
    			this.add(fax);
    			fax.setBounds(547, 176, 224, 22);
    		}
    		{
    			tipo = new JTextField();
    			this.add(tipo);
    			tipo.setBounds(1004, 82, 233, 22);
    		}
    		{
    			email = new JTextField();
    			this.add(email);
    			email.setBounds(789, 176, 198, 22);
    		}
    		{
    			dipartimento = new JTextField();
    			this.add(dipartimento);
    			dipartimento.setBounds(40, 178, 275, 22);
    		}
    		{
    			img = new JTextField();
    			this.add(img);
    			img.setBounds(1005, 177, 203, 22);
    		}
    		{
    			JLabel labfax = new JLabel("");
    			this.add(labfax);
    			labfax.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Fax.png")));
    			labfax.setBounds(547, 149, 159, 29);
    		}
    		{
    			JLabel labtipo = new JLabel ("");
    			this.add(labtipo);
    			labtipo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Tipo Utente.png")));
    			labtipo.setBounds(998, 57, 238, 29);
    		}
    		{
    			JLabel labemail = new JLabel ("");
    			this.add(labemail);
    			labemail.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/E-mail.png")));
    			labemail.setBounds(789, 148, 167, 29);
    		}
    		{
    			JLabel labdipartimento = new JLabel("");
    			this.add(labdipartimento);
    			labdipartimento.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Dipartimento.png")));
    			labdipartimento.setBounds(39, 151, 275, 29);
    		}
    		{
    			JLabel labimmagine = new JLabel("") ;
    			this.add(labimmagine);
    			labimmagine.setIcon(new ImageIcon(getClass().getClassLoader().getResource("img/Foto.png")));
    			labimmagine.setBounds(1005, 150, 238, 29);
    
    		}
    	
    		
    		
    	
    		
    
    		
    		
    	}
    
    	/**
    	 * This method initializes this
    	 * 
    	 * @return void
    	 */
    	private void initialize() {
    		this.setSize(1300, 400);
    		this.setLayout(null);
    		this.setName("this");
    		Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
    			}
    
    	public void cancellaRiga(ActionEvent e)throws SQLException, ClassNotFoundException{
    		
    
    		SQLManager sqlm =  new SQLManager ("com.mysql.jdbc.Driver","jdbc:mysql://localhost:3306/schedule","root","root");
    		
    		String query = "delete from utente where id_utente = '"+ id.getText() +"'";
    		
    
    		 sqlm.esegui(query); 
    	sqlm.close(); 
    
    	nominativo.setText(""); 
    	username.setText(""); 
    	password.setText("");  
    	id.setText("");
    	telefono.setText("");
    	fax.setText("");
    	tipo.setText ("");
    	email.setText ("");
    	dipartimento.setText ("");
    	img.setText ("");
    
    
    	}
    	public void modificaarchivio(ActionEvent e)throws SQLException, ClassNotFoundException{
    		
    
    		SQLManager sqlm = new SQLManager("com.mysql.jdbc.Driver","jdbc:mysql://localhost:3306/schedule","root","root");
    		
    		String query = "update Utente set nominativo = '"+ nominativo.getText()+"', username= '"+ username.getText() +"', password ='"+ password.getText() +"', tipo_utente = '"+ tipo.getText() +"'," +
    		" dipartimento = '"+ dipartimento.getText() +"', telefono = '"+ telefono.getText() +"',fax = '"+ fax.getText() +"',  email = '"+ email.getText() +"'," +
    				" img ='"+ img.getText() +"' where  id_utente = '"+ id.getText() +"'";
    
    		
    		 sqlm.esegui(query); 
    	sqlm.close(); 
    
    	nominativo.setText(""); 
    	username.setText(""); 
    	password.setText("");  
    	id.setText("");
    	telefono.setText ("");
    	fax.setText ("");
    	tipo.setText ("");
    	email.setText ("");
    	dipartimento.setText ("");
    	img.setText ("");
    
    	}
    
    
    
    /*
    	private class RowListener implements ListSelectionListener {
    	    public void valueChanged(ListSelectionEvent event) {
    	        if (event.getValueIsAdjusting()) {
    	            return;
    	            
    	        }
    	        int row = t.getSelectedRow();
    			System.out.println("hai selezionato la riga:" + row);
    			
    			id.setText ((String) t.getValueAt (row,0));
    			nominativo.setText ((String) t.getValueAt (row,1));
    			username.setText ((String) t.getValueAt (row,2));
    			password.setText ((String) t.getValueAt (row,3));
    			tipo.setText ((String) t.getValueAt (row,4));
    			dipartimento.setText ((String) t.getValueAt (row,5));
    			telefono.setText ((String) t.getValueAt (row,6));
    			fax.setText ((String) t.getValueAt (row,7));
    			email.setText ((String) t.getValueAt (row,8));
    			img.setText ((String) t.getValueAt (row,9));
    	    
    	    }
    
    		}
    
    */
    
    
    
    
    
    
    }
    
    
    
    
    
    
    }

    AIUTATEMI!!!!

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.