Hello. Recently I started programming and I need to make a jTabbedPane transparent. I´ve overwritten a jPanel so can contain a image. When I add the jTabbedPane still see the image as background. But when I started add jPanel in the jTabbedPane this loses transparency. I use setOpaque(false), but nothing. I also try to overwritte the jTabbedPane, but the components and title of the tab weren´t display. If anyone can help me i will be really greatfull. Here I post a little version of my code.
package GUI;
import javax.swing.JPanel;
import java.awt.Frame;
import java.awt.BorderLayout;
import javax.swing.JDialog;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import java.awt.GridBagLayout;
public class a extends JDialog {
private static final long serialVersionUID = 1L;
private JEImagePanel jContentPane = null;
private JTabbedPane jTabbedPane = null;
private JTabbedPane jTabbedPane1 = null;
private JPanel jPanel = null;
/**
* This method initializes jTabbedPane
*
* @return javax.swing.JTabbedPane
*/
private JTabbedPane getJTabbedPane() {
if (jTabbedPane == null) {
jTabbedPane = new JTabbedPane();
jTabbedPane.setLayout(new BorderLayout());
}
return jTabbedPane;
}
/**
* This method initializes jTabbedPane1
*
* @return javax.swing.JTabbedPane
*/
private JTabbedPane getJTabbedPane1() {
if (jTabbedPane1 == null) {
jTabbedPane1 = new JTabbedPane();
jTabbedPane1.addTab("Hola", null, getJPanel(), null);
}
return jTabbedPane1;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jPanel = new JPanel();
jPanel.setLayout(new GridBagLayout());
jPanel.setOpaque(false);
}
return jPanel;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
/**
* @param owner
*/
public a(Frame owner) {
super(owner);
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(300, 200);
this.setContentPane(getJContentPane());
}
/**
* This method initializes jContentPane
* JEImagePanel
* @return javax.swing.JPanel
*/
private JEImagePanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JEImagePanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.setIcon(new ImageIcon(getClass().getResource("/imagen/angels.jpg")));
jContentPane.add(getJTabbedPane1(), BorderLayout.CENTER);
}
return jContentPane;
}
}