Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2010
    Messaggi
    47

    utilizzo delle scrollbar e dei scrollpane

    ciao ragazzi sto cercando di creare una piccola applicazione che utilizzi all'interno del frame principale, una zona che sfrutti le potenzialita della scroll bar. non ho mai avuto modo di utilizzarle per cui mi sto trovando un po in difficolta,qualcuno sa darmi una dritta?
    nello specifico sto lavorando su un frame nel quale ho un pulsante che quando viene premuto mi fa comparire una serie di textfield. il problema nasce nel momento in cui vado ad effettuarre un numero di inserimenti elevato per cui lo spazio del frame non mi basterebbe piu. il mio obiettivo è quindi riservare, all'interno del frame, un'area per quelle textfield su cui andare ad applicarci la scrollbar.spero di essermi spiegato.grazie ciao
    Alex

  2. #2
    Utente di HTML.it
    Registrato dal
    Dec 2009
    Messaggi
    1,123
    Prima di tutto devi inserire quei componenti in un JPanel, e poi applicare la JScrollPane.

    Comunque se non posti del codice è difficile esserti d'aiuto. ^^

  3. #3
    Utente di HTML.it
    Registrato dal
    Dec 2010
    Messaggi
    47
    allora ti faccio vedere
    codice:
    package Anagrafica;  import java.awt.GraphicsEnvironment; import java.awt.Rectangle;  import javax.swing.JInternalFrame; import javax.swing.JMenuItem; import javax.swing.JPanel; import java.awt.Dimension; import javax.swing.JLabel; import javax.swing.JComboBox; import javax.swing.JButton; import javax.swing.JTextField;  public class Frm_Fattura extends JInternalFrame { 	private static final long serialVersionUID = 1L; 	 	private JPanel jContentPane = null; 	private JMenuItem itemAssociato = null; 	private JLabel jLabelTitolo = null; 	private JLabel jLabelNomeCliente = null; 	private JComboBox jComboBoxNomeCliente = null; 	private JButton jButtonAggiungi = null; 	private JLabel jLabelArticolo = null; 	private JLabel jLabelQuant = null; 	private JLabel jLabelPrezzo = null; 	private JLabel jLabelIVA = null; 	private JTextField jTextFieldArticolo = null; 	private JTextField jTextFieldQuant = null; 	private JTextField jTextFieldPrezzo = null; 	private JComboBox jComboBoxIVA = null; 	private JTextField jTextFieldTotale = null; 	private JLabel jLabelTotale = null;  	private JPanel jPanelContenitore = null;  	public Frm_Fattura(JMenuItem item) { 		super(); 		this.itemAssociato = item; 		initialize(); 	}  	private void initialize() { 		 		GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 	    Rectangle maxSize = ge.getMaximumWindowBounds(); 		this.setBounds((int)(maxSize.width - 800) / 2, (int)(maxSize.height - 600) / 2, 750, 500); 		this.setTitle("Nuova Fattura"); 		this.setContentPane(getJContentPane()); 		this.setSize(new Dimension(662, 481)); 		this.setClosable(true); 		this.setResizable(true); 		this.setIconifiable(true); 		this.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() { 			public void internalFrameClosed(javax.swing.event.InternalFrameEvent e) { 				itemAssociato.setEnabled(true);			 			} 		}); 	}  	private JPanel getJContentPane() { 		if (jContentPane == null) { 			jLabelTotale = new JLabel(); 			jLabelTotale.setBounds(new Rectangle(535, 109, 52, 27)); 			jLabelTotale.setText("Totale"); 			jLabelIVA = new JLabel(); 			jLabelIVA.setBounds(new Rectangle(465, 109, 35, 25)); 			jLabelIVA.setText("IVA "); 			jLabelPrezzo = new JLabel(); 			jLabelPrezzo.setBounds(new Rectangle(396, 109, 48, 25)); 			jLabelPrezzo.setText("Prezzo"); 			jLabelQuant = new JLabel(); 			jLabelQuant.setBounds(new Rectangle(321, 109, 52, 25)); 			jLabelQuant.setText("Quantità"); 			jLabelArticolo = new JLabel(); 			jLabelArticolo.setBounds(new Rectangle(24, 109, 92, 25)); 			jLabelArticolo.setText("Nome Articolo"); 			jLabelNomeCliente = new JLabel(); 			jLabelNomeCliente.setBounds(new Rectangle(25, 55, 80, 25)); 			jLabelNomeCliente.setText("Nome Cliente"); 			jLabelTitolo = new JLabel(); 			jLabelTitolo.setBounds(new Rectangle(253, 12, 132, 29)); 			jLabelTitolo.setText("Inserisci Nuova Fattura"); 			jContentPane = new JPanel(); 			jContentPane.setLayout(null); 			jContentPane.add(jLabelTitolo, null); 			jContentPane.add(jLabelNomeCliente, null); 			jContentPane.add(getJComboBoxNomeCliente(), null); 			jContentPane.add(getJButtonAggiungi(), null); 			jContentPane.add(jLabelArticolo, null); 			jContentPane.add(jLabelQuant, null); 			jContentPane.add(jLabelPrezzo, null); 			jContentPane.add(jLabelIVA, null); 			jContentPane.add(jLabelTotale, null); 			jContentPane.add(getJPanelContenitore(), null); 		} 		return jContentPane; 	}  	private JComboBox getJComboBoxNomeCliente() { 		if (jComboBoxNomeCliente == null) { 			jComboBoxNomeCliente = new JComboBox(); 			jComboBoxNomeCliente.setBounds(new Rectangle(120, 55, 203, 25)); 		} 		return jComboBoxNomeCliente; 	}  	private JButton getJButtonAggiungi() { 		if (jButtonAggiungi == null) { 			jButtonAggiungi = new JButton(); 			jButtonAggiungi.setBounds(new Rectangle(423, 55, 171, 27)); 			jButtonAggiungi.setText("Aggiungi Articolo"); 		} 		return jButtonAggiungi; 	}  	private JTextField getJTextFieldArticolo() { 		if (jTextFieldArticolo == null) { 			jTextFieldArticolo = new JTextField(); 			jTextFieldArticolo.setBounds(new Rectangle(6, 157, 283, 25)); 		} 		return jTextFieldArticolo; 	}	 	 	private JTextField getJTextFieldQuant() { 		if (jTextFieldQuant == null) { 			jTextFieldQuant = new JTextField(); 			jTextFieldQuant.setBounds(new Rectangle(303, 157, 51, 25)); 		} 		return jTextFieldQuant; 	}  	private JTextField getJTextFieldPrezzo() { 		if (jTextFieldPrezzo == null) { 			jTextFieldPrezzo = new JTextField(); 			jTextFieldPrezzo.setBounds(new Rectangle(372, 157, 55, 25)); 		} 		return jTextFieldPrezzo; 	}  	private JComboBox getJComboBoxIVA() { 		if (jComboBoxIVA == null) { 			jComboBoxIVA = new JComboBox(); 			jComboBoxIVA.setBounds(new Rectangle(441, 157, 50, 24)); 		} 		return jComboBoxIVA; 	}  	private JTextField getJTextFieldTotale() { 		if (jTextFieldTotale == null) { 			jTextFieldTotale = new JTextField(); 			jTextFieldTotale.setBounds(new Rectangle(506, 157, 67, 25)); 		} 		return jTextFieldTotale; 	}  	private JPanel getJPanelContenitore() { 		if (jPanelContenitore == null) { 			jPanelContenitore = new JPanel(); 			jPanelContenitore.setLayout(null); 			jPanelContenitore.setBounds(new Rectangle(1, 140, 650, 197)); 			jPanelContenitore.add(getJTextFieldArticolo(), null); 			jPanelContenitore.add(getJTextFieldQuant(), null); 			jPanelContenitore.add(getJTextFieldPrezzo(), null); 			jPanelContenitore.add(getJComboBoxIVA(), null); 			jPanelContenitore.add(getJTextFieldTotale(), null); 		} 		return jPanelContenitore; 	} 	 }
    in pratica vorrei che jTextFieldArticolo, jTextFieldQuant, jTextFieldPrezzo jComboBoxIVA, jTextFieldTotale quando pigio sul bottone jButtonAggiungi, debbano esser duplicate in modo da poter effettuare un nuovo inserimento, il tutto racchiudendole all'interno di un'area su cui applicare lo scrolling...tutto qui.grazie ciao
    Alex

  4. #4
    Utente di HTML.it
    Registrato dal
    Dec 2010
    Messaggi
    47
    mamma che schifezza
    aspetta provo a rimandarti il codice
    codice:
    package Anagrafica;
    
    import java.awt.GraphicsEnvironment;
    import java.awt.Rectangle;
    
    import javax.swing.JInternalFrame;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import java.awt.Dimension;
    import javax.swing.JLabel;
    import javax.swing.JComboBox;
    import javax.swing.JButton;
    import javax.swing.JTextField;
    
    public class Frm_Fattura extends JInternalFrame {
    	private static final long serialVersionUID = 1L;
    	
    	private JPanel jContentPane = null;
    	private JMenuItem itemAssociato = null;
    	private JLabel jLabelTitolo = null;
    	private JLabel jLabelNomeCliente = null;
    	private JComboBox jComboBoxNomeCliente = null;
    	private JButton jButtonAggiungi = null;
    	private JLabel jLabelArticolo = null;
    	private JLabel jLabelQuant = null;
    	private JLabel jLabelPrezzo = null;
    	private JLabel jLabelIVA = null;
    	private JTextField jTextFieldArticolo = null;
    	private JTextField jTextFieldQuant = null;
    	private JTextField jTextFieldPrezzo = null;
    	private JComboBox jComboBoxIVA = null;
    	private JTextField jTextFieldTotale = null;
    	private JLabel jLabelTotale = null;
    
    	private JPanel jPanelContenitore = null;
    
    	public Frm_Fattura(JMenuItem item) {
    		super();
    		this.itemAssociato = item;
    		initialize();
    	}
    
    	private void initialize() {
    		
    		GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    	    Rectangle maxSize = ge.getMaximumWindowBounds();
    		this.setBounds((int)(maxSize.width - 800) / 2, (int)(maxSize.height - 600) / 2, 750, 500);
    		this.setTitle("Nuova Fattura");
    		this.setContentPane(getJContentPane());
    		this.setSize(new Dimension(662, 481));
    		this.setClosable(true);
    		this.setResizable(true);
    		this.setIconifiable(true);
    		this.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() {
    			public void internalFrameClosed(javax.swing.event.InternalFrameEvent e) {
    				itemAssociato.setEnabled(true);			
    			}
    		});
    	}
    
    	private JPanel getJContentPane() {
    		if (jContentPane == null) {
    			jLabelTotale = new JLabel();
    			jLabelTotale.setBounds(new Rectangle(535, 109, 52, 27));
    			jLabelTotale.setText("Totale");
    			jLabelIVA = new JLabel();
    			jLabelIVA.setBounds(new Rectangle(465, 109, 35, 25));
    			jLabelIVA.setText("IVA ");
    			jLabelPrezzo = new JLabel();
    			jLabelPrezzo.setBounds(new Rectangle(396, 109, 48, 25));
    			jLabelPrezzo.setText("Prezzo");
    			jLabelQuant = new JLabel();
    			jLabelQuant.setBounds(new Rectangle(321, 109, 52, 25));
    			jLabelQuant.setText("Quantità");
    			jLabelArticolo = new JLabel();
    			jLabelArticolo.setBounds(new Rectangle(24, 109, 92, 25));
    			jLabelArticolo.setText("Nome Articolo");
    			jLabelNomeCliente = new JLabel();
    			jLabelNomeCliente.setBounds(new Rectangle(25, 55, 80, 25));
    			jLabelNomeCliente.setText("Nome Cliente");
    			jLabelTitolo = new JLabel();
    			jLabelTitolo.setBounds(new Rectangle(253, 12, 132, 29));
    			jLabelTitolo.setText("Inserisci Nuova Fattura");
    			jContentPane = new JPanel();
    			jContentPane.setLayout(null);
    			jContentPane.add(jLabelTitolo, null);
    			jContentPane.add(jLabelNomeCliente, null);
    			jContentPane.add(getJComboBoxNomeCliente(), null);
    			jContentPane.add(getJButtonAggiungi(), null);
    			jContentPane.add(jLabelArticolo, null);
    			jContentPane.add(jLabelQuant, null);
    			jContentPane.add(jLabelPrezzo, null);
    			jContentPane.add(jLabelIVA, null);
    			jContentPane.add(jLabelTotale, null);
    			jContentPane.add(getJPanelContenitore(), null);
    		}
    		return jContentPane;
    	}
    
    	private JComboBox getJComboBoxNomeCliente() {
    		if (jComboBoxNomeCliente == null) {
    			jComboBoxNomeCliente = new JComboBox();
    			jComboBoxNomeCliente.setBounds(new Rectangle(120, 55, 203, 25));
    		}
    		return jComboBoxNomeCliente;
    	}
    
    	private JButton getJButtonAggiungi() {
    		if (jButtonAggiungi == null) {
    			jButtonAggiungi = new JButton();
    			jButtonAggiungi.setBounds(new Rectangle(423, 55, 171, 27));
    			jButtonAggiungi.setText("Aggiungi Articolo");
    		}
    		return jButtonAggiungi;
    	}
    
    	private JTextField getJTextFieldArticolo() {
    		if (jTextFieldArticolo == null) {
    			jTextFieldArticolo = new JTextField();
    			jTextFieldArticolo.setBounds(new Rectangle(6, 157, 283, 25));
    		}
    		return jTextFieldArticolo;
    	}	
    	
    	private JTextField getJTextFieldQuant() {
    		if (jTextFieldQuant == null) {
    			jTextFieldQuant = new JTextField();
    			jTextFieldQuant.setBounds(new Rectangle(303, 157, 51, 25));
    		}
    		return jTextFieldQuant;
    	}
    
    	private JTextField getJTextFieldPrezzo() {
    		if (jTextFieldPrezzo == null) {
    			jTextFieldPrezzo = new JTextField();
    			jTextFieldPrezzo.setBounds(new Rectangle(372, 157, 55, 25));
    		}
    		return jTextFieldPrezzo;
    	}
    
    	private JComboBox getJComboBoxIVA() {
    		if (jComboBoxIVA == null) {
    			jComboBoxIVA = new JComboBox();
    			jComboBoxIVA.setBounds(new Rectangle(441, 157, 50, 24));
    		}
    		return jComboBoxIVA;
    	}
    
    	private JTextField getJTextFieldTotale() {
    		if (jTextFieldTotale == null) {
    			jTextFieldTotale = new JTextField();
    			jTextFieldTotale.setBounds(new Rectangle(506, 157, 67, 25));
    		}
    		return jTextFieldTotale;
    	}
    
    	private JPanel getJPanelContenitore() {
    		if (jPanelContenitore == null) {
    			jPanelContenitore = new JPanel();
    			jPanelContenitore.setLayout(null);
    			jPanelContenitore.setBounds(new Rectangle(1, 140, 650, 197));
    			jPanelContenitore.add(getJTextFieldArticolo(), null);
    			jPanelContenitore.add(getJTextFieldQuant(), null);
    			jPanelContenitore.add(getJTextFieldPrezzo(), null);
    			jPanelContenitore.add(getJComboBoxIVA(), null);
    			jPanelContenitore.add(getJTextFieldTotale(), null);
    		}
    		return jPanelContenitore;
    	}
    	
    }
    Alex

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.