Salve ho un problema:
ho un JTree con delle directory, e vorrei visualizzare il contenuto dei file. però ho un problema mi sovrappone le immagini come posso risolvere questo problema?
codice:public void cornice(String path, GridBagConstraints lim, GridBagLayout layout) throws IOException, URISyntaxException{ // Component c18 = new JLabel(new ImageIcon("ciao")); Component c18 = null; String strFolderPath = null; String strFileName = null; File imagePath=null; BufferedImage image=null ; if(path==null) { strFolderPath = "C:/prova"; strFileName = "vuota.jpg"; imagePath = new File(strFolderPath, strFileName); } else { ArrayList<String> ris = scomponipath(path); imagePath = new File(ris.get(1), ris.get(0)); } // Contiene il riferimento al file da aprire System.out.println(path); image = ImageIO.read(imagePath); ImageIcon I = new ImageIcon(image); c18 = new JLabel(I); c18.setBackground(Color.white); lim.gridx = 0; lim.gridy = 2; lim.gridwidth = 14; lim.gridheight = 2; lim.fill = GridBagConstraints.CENTER; layout.setConstraints(c18, lim); remove(c18); add(c18); }

Rispondi quotando