faca o teste, descomenta as linhas 4 ou 5, no nimbus o icone fica no final, já no metal e windows fica no inicio…
publicstaticvoidmain(String[]args)throwsException{for(javax.swing.UIManager.LookAndFeelInfoinfo:javax.swing.UIManager.getInstalledLookAndFeels()){if(info.getName().toLowerCase().contains("windows")){// if (info.getName().toLowerCase().contains("metal")) {// if (info.getName().toLowerCase().contains("nimbus")) {javax.swing.UIManager.setLookAndFeel(info.getClassName());break;}}}catch(Exceptionex){ex.printStackTrace();}JFrameframe=newJFrame();frame.setSize(200,200);frame.getContentPane().setLayout(newBorderLayout());JTabbedPanetabbed=newJTabbedPane();tabbed.add("Teste",newJPanel());frame.getContentPane().add(tabbed,BorderLayout.CENTER);InputStreaminput=TesteTabbed.class.getClassLoader().getResourceAsStream("testeswing/iconeSistema.png");BufferedImageimage=ImageIO.read(input);tabbed.setIconAt(0,newImageIcon(image));frame.setVisible(true);}
Y
yfalbino
hmm… verdade, com o LookAndFeel do windows funcionou na frente…
mas nao tem uma forma de deixar a imagem no inicio usando o LookAndFeel do nimbus ?
L
lucasirc1 like
// Create tabbed pane and add tabs.JTabbedPanetabbedPane=...// Create bespoke component for rendering the tab.JLabellbl=newJLabel("Hello, World");Iconicon=newImageIcon(getClass().getResource("/foo/bar/hello.jpg"));lbl.setIcon(icon);// Add some spacing between text and icon, and position text to the RHS.lbl.setIconTextGap(5);lbl.setHorizontalTextPosition(SwingConstants.RIGHT);// Assign bespoke tab component for first tab.tabbedPane.setTabComponentAt(0,lbl);