ok perfettissimo posto il codice:
con questo codice io creo il pannello
con questo codice inserisco nel pannello i miei componenticodice:public static void createAndShowGUI() { //Create and set up the window. frame = new JDialog(); Dimensione d2 = new Dimensione(); d2.setSize(700, 500); frame.setPreferredSize(d2); frame.pack(); frame.setResizable(true); JComponent newContentPane = new PanelNoteCredito(); newContentPane.setOpaque(true); //content panes must be opaque frame.setContentPane(newContentPane); //Display the window. frame.pack(); }
In linea di massima questo è il codice che utilizzo per creare i miei pannellicodice:public class PanelNoteCredito extends JPanel{ public PanelNoteCredito() { super(new BorderLayout()); buttonSalva = new JButton(); buttonSalva.setIcon(new ImageIcon(getClass().getResource("/resources/SalvaR.png"))); buttonSalva.setText("Salva"); buttonModifica = new JButton(); buttonModifica.setIcon(new ImageIcon(getClass().getResource("/resources/Modifica.png"))); buttonModifica.setText("Modifica"); LabelFormat labelDescrizione = new LabelFormat("Descrizione Nota Credito: "); textDescrizione = new TextFieldFormat(); //Put the radio buttons in a column in a panel. JPanel radioPanel = new JPanel(); GridBagConstraints GBC5 = new GridBagConstraints(); Container CR5 = new Container(); GridBagLayout GBL5 = new GridBagLayout(); CR5.setComponentOrientation(ComponentOrientation.UNKNOWN); CR5.setLayout(GBL5); radioPanel.add(CR5); GBC5 = new GridBagConstraints(); CR5.add(scrollPane); GBC5.gridx=0; GBC5.gridy=0; GBC5.gridwidth=8; GBC5.gridheight=2; GBC5.insets.top=5; GBC5.fill=GridBagConstraints.HORIZONTAL; GBL5.setConstraints(scrollPane,GBC5); GBC5 = new GridBagConstraints(); CR5.add(labelDescrizione); GBC5.gridx=0; GBC5.gridy=3; GBC5.insets.top=10; GBC5.insets.left=7; GBC5.fill=GridBagConstraints.HORIZONTAL; GBL5.setConstraints(labelDescrizione,GBC5); GBC5 = new GridBagConstraints(); CR5.add(textDescrizione); GBC5.gridx=1; GBC5.gridy=3; GBC5.insets.top=10; GBC5.gridwidth=4; GBC5.insets.left=7; GBC5.fill=GridBagConstraints.HORIZONTAL; GBL5.setConstraints(textDescrizione,GBC5); GBC5 = new GridBagConstraints(); CR5.add(buttonSalva); GBC5.gridx=1; GBC5.gridy=4; GBC5.insets.top=10; GBC5.insets.left=7; GBC5.fill=GridBagConstraints.HORIZONTAL; GBL5.setConstraints(buttonSalva,GBC5); GBC5 = new GridBagConstraints(); CR5.add(buttonModifica); GBC5.gridx=2; GBC5.gridy=4; GBC5.insets.top=10; GBC5.insets.left=7; GBC5.fill=GridBagConstraints.HORIZONTAL; GBL5.setConstraints(buttonModifica,GBC5); GBC5 = new GridBagConstraints(); CR5.add(buttonCancella); GBC5.gridx=3; GBC5.gridy=4; GBC5.insets.top=10; GBC5.insets.left=7; GBC5.fill=GridBagConstraints.HORIZONTAL; GBL5.setConstraints(buttonCancella,GBC5); }}



Rispondi quotando