
Problema añadir elementos en un panel
Publicado por ss (3 intervenciones) el 06/11/2014 11:35:45
Hola tengo una duda con matlab estoy intentando hacer un panel con una imagen de fondo y cajetillas para poner usuario y contraseña. Lo hago de la siguiente forma. la cuestión es que si pongo una imagen de fondo luego no se me visualizan los otros elementos, parece que no puedo visualizarlos todos a la vez. Sabéis como puedo solucionarlo?
% Load the image
jImFile = java.io.File( imageFile );
try
obj.OriginalImage = javax.imageio.ImageIO.read( jImFile );
catch err
error('SplashScreen:BadFile', 'Image ''%s'' could not be loaded.', imageFile );
end
% Read it again into the copy we'll draw on
obj.BufferedImage = javax.imageio.ImageIO.read( jImFile );
% Create the icon
obj.Icon = ImageIcon( obj.BufferedImage );
% Create the frame and fill it with the image
obj.Frame = JFrame( title );
obj.Frame.setUndecorated( true );
obj.Label = JLabel( obj.Icon );
p = obj.Frame.getContentPane();
p.add(obj.Label);
% label1 = javax.swing.JLabel('Username:');
% label1.setBounds(300, 150, 100, 350);
% p.add(label1);
%
% nameField = javax.swing.JTextField();
% nameField.setBounds(100, 400, 150, 20);
% p.add(nameField);
%
% label2 = javax.swing.JLabel('Password:');
% label2.setBounds(15, 40, 300, 200);
% p.add(label2);
%
% fieldPass = javax.swing.JPasswordField();
% fieldPass.setBounds(100, 800, 150, 20);
% p.add(fieldPass);
% Load the image
jImFile = java.io.File( imageFile );
try
obj.OriginalImage = javax.imageio.ImageIO.read( jImFile );
catch err
error('SplashScreen:BadFile', 'Image ''%s'' could not be loaded.', imageFile );
end
% Read it again into the copy we'll draw on
obj.BufferedImage = javax.imageio.ImageIO.read( jImFile );
% Create the icon
obj.Icon = ImageIcon( obj.BufferedImage );
% Create the frame and fill it with the image
obj.Frame = JFrame( title );
obj.Frame.setUndecorated( true );
obj.Label = JLabel( obj.Icon );
p = obj.Frame.getContentPane();
p.add(obj.Label);
% label1 = javax.swing.JLabel('Username:');
% label1.setBounds(300, 150, 100, 350);
% p.add(label1);
%
% nameField = javax.swing.JTextField();
% nameField.setBounds(100, 400, 150, 20);
% p.add(nameField);
%
% label2 = javax.swing.JLabel('Password:');
% label2.setBounds(15, 40, 300, 200);
% p.add(label2);
%
% fieldPass = javax.swing.JPasswordField();
% fieldPass.setBounds(100, 800, 150, 20);
% p.add(fieldPass);
Valora esta pregunta


0