Foros del Web » Programación para mayores de 30 ;) » Java »

Tengo problema con un JTabbePane

Estas en el tema de Tengo problema con un JTabbePane en el foro de Java en Foros del Web. Hola, tengo un problema con un jTabbePane. Estoy haciendo un programa y le quiero agregar una imagen de fondo. Ya he modificado el jPanel que ...
  #1 (permalink)  
Antiguo 03/12/2009, 06:05
 
Fecha de Ingreso: marzo-2008
Mensajes: 99
Antigüedad: 16 años, 1 mes
Puntos: 1
Tengo problema con un JTabbePane

Hola, tengo un problema con un jTabbePane. Estoy haciendo un programa y le quiero agregar una imagen de fondo. Ya he modificado el jPanel que contiene todos los componentes para ponerle una imagen. El problema surge cuando quiero hacer el jTabbePane transparente para que se vea la imagen de fondo. Lo pongo transparente con setOpaque(false) pero no pasa nada, en el resto de los componentes que tengo se ve la imagen, pero en el jTabbePane no se ve. Solamente se ve el color azul-celeston por ponerlo transparente. Alguno sabe que es lo que puedo estar olvidandome???? Si hace falta les publico un codigo reducido del componente con el que estoy trabajando.


Bueno. Les agrego el codigo asi pueden ver mejor lo que estoy haciendo. Son 2 clases, una es el panel modificado que actua como contenedor de los componentes. La otra es el prototipo de ventana que estoy armando.

Clase Panel
Cita:
package GUI;

import java.awt.Graphics;

import java.awt.Graphics2D;

import java.awt.Image;

import javax.swing.Icon;

import javax.swing.ImageIcon;

import javax.swing.JPanel;/**

*

* @author Edisoncor

*/

public class JEImagePanel extends JPanel{

private Image image=null;

private Icon icon;

/** Creates a new instance of JEImagePanel */

public JEImagePanel() {

}

protected void paintComponent(Graphics g) {

Graphics2D g2 =(Graphics2D) g;

if(getImage()!=null)

g2.drawImage(getImage(), 0, 0, getWidth(), getHeight(), null);

}

public Image getImage() {

return image;

}

public void setImage(Image image) {

this.image = image;

}

public Icon getIcon() {

return icon;

}

public void setIcon(Icon icon){

this.icon=icon;

setImage(((ImageIcon)icon).getImage());

}

}
Prototipo de Ventana (el jtabbedpane)
Cita:
package GUI;

import java.awt.Dimension;
import java.awt.BorderLayout;
import javax.swing.JTabbedPane;
import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import java.awt.Insets;
import javax.swing.JButton;
import java.awt.FlowLayout;

public class TabbedPane extends JEImagePanel {

private JTabbedPane jTabbedPane = null;
private JPanel jPanel = null;
private JLabel Nombre = null;
private JTextField nombre = null;
private JLabel Apellido = null;
private JTextField apellido = null;
private JLabel Estado = null;
private JComboBox estado = null;
private JPanel jPanel1 = null;
private JButton Aceptar = null;
private JButton Cancelar = null;

/**
* This method initializes
*
*/
public TabbedPane() {
super();
initialize();
}

/**
* This method initializes this
*
*/
private void initialize() {
this.setLayout(new BorderLayout());
this.setSize(new Dimension(405, 231));
this.add(getJPanel1(), BorderLayout.SOUTH);
this.add(getJTabbedPane(), BorderLayout.CENTER);

}

/**
* This method initializes jTabbedPane
*
* @return javax.swing.JTabbedPane
*/
private JTabbedPane getJTabbedPane() {
if (jTabbedPane == null) {
jTabbedPane = new JTabbedPane();
jTabbedPane.addTab("Ingreso", null, getJPanel(), null);
}
return jTabbedPane;
}

/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
gridBagConstraints5.fill = GridBagConstraints.NONE;
gridBagConstraints5.gridy = 2;
gridBagConstraints5.weightx = 1.0;
gridBagConstraints5.anchor = GridBagConstraints.WEST;
gridBagConstraints5.insets = new Insets(5, 10, 5, 0);
gridBagConstraints5.gridx = 1;
GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
gridBagConstraints4.gridx = 0;
gridBagConstraints4.anchor = GridBagConstraints.WEST;
gridBagConstraints4.insets = new Insets(5, 10, 5, 0);
gridBagConstraints4.fill = GridBagConstraints.NONE;
gridBagConstraints4.gridy = 2;
Estado = new JLabel();
Estado.setText("Estado");
GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
gridBagConstraints3.fill = GridBagConstraints.NONE;
gridBagConstraints3.gridy = 1;
gridBagConstraints3.weightx = 1.0;
gridBagConstraints3.anchor = GridBagConstraints.WEST;
gridBagConstraints3.insets = new Insets(5, 10, 5, 0);
gridBagConstraints3.gridx = 1;
GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
gridBagConstraints2.gridx = 0;
gridBagConstraints2.anchor = GridBagConstraints.WEST;
gridBagConstraints2.insets = new Insets(5, 10, 5, 0);
gridBagConstraints2.fill = GridBagConstraints.NONE;
gridBagConstraints2.gridy = 1;
Apellido = new JLabel();
Apellido.setText("Apellido");
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
gridBagConstraints1.fill = GridBagConstraints.NONE;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.anchor = GridBagConstraints.WEST;
gridBagConstraints1.insets = new Insets(5, 10, 5, 0);
gridBagConstraints1.gridx = 1;
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.anchor = GridBagConstraints.WEST;
gridBagConstraints.insets = new Insets(5, 10, 5, 0);
gridBagConstraints.fill = GridBagConstraints.NONE;
gridBagConstraints.gridy = 0;
Nombre = new JLabel();
Nombre.setText("Nombre");
jPanel = new JPanel();
jPanel.setLayout(new GridBagLayout());
jPanel.add(Nombre, gridBagConstraints);
jPanel.add(getNombre(), gridBagConstraints1);
jPanel.add(Apellido, gridBagConstraints2);
jPanel.add(getApellido(), gridBagConstraints3);
jPanel.add(Estado, gridBagConstraints4);
jPanel.add(getEstado(), gridBagConstraints5);
}
return jPanel;
}

/**
* This method initializes nombre
*
* @return javax.swing.JTextField
*/
private JTextField getNombre() {
if (nombre == null) {
nombre = new JTextField();
nombre.setColumns(20);
}
return nombre;
}

/**
* This method initializes apellido
*
* @return javax.swing.JTextField
*/
private JTextField getApellido() {
if (apellido == null) {
apellido = new JTextField();
apellido.setColumns(20);
}
return apellido;
}

/**
* This method initializes estado
*
* @return javax.swing.JComboBox
*/
private JComboBox getEstado() {
if (estado == null) {
estado = new JComboBox(new String[]{"Casado","Soletero"});
}
return estado;
}

/**
* This method initializes jPanel1
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel1() {
if (jPanel1 == null) {
jPanel1 = new JPanel();
jPanel1.setLayout(new FlowLayout());
jPanel1.setOpaque(false);
jPanel1.add(getAceptar(), null);
jPanel1.add(getCancelar(), null);
}
return jPanel1;
}

/**
* This method initializes Aceptar
*
* @return javax.swing.JButton
*/
private JButton getAceptar() {
if (Aceptar == null) {
Aceptar = new JButton();
Aceptar.setText("Aceptar");
}
return Aceptar;
}

/**
* This method initializes Cancelar
*
* @return javax.swing.JButton
*/
private JButton getCancelar() {
if (Cancelar == null) {
Cancelar = new JButton();
Cancelar.setText("Cancelar");
}
return Cancelar;
}

} // @jve:decl-index=0:visual-constraint="10,10"

Última edición por lordphoenixs; 03/12/2009 a las 08:03
  #2 (permalink)  
Antiguo 05/12/2009, 09:14
 
Fecha de Ingreso: marzo-2008
Mensajes: 99
Antigüedad: 16 años, 1 mes
Puntos: 1
Respuesta: Tengo problema con un JTabbePane

BUeno ya resolvi el problema
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:37.