Imagen Icon
Publicado por marcelo (18 intervenciones) el 19/04/2019 14:43:42
Hola soy novato en java estoy siguiendo un curso de la web, tengo una carpeta creada "images" en el arbol de carpetas que crea netbeans y el codigo no me muestra error pero al ejecutar me salta en netbeans un error:
-------------------------------------------------------------------------------------------------------
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:217)
at bienvenida.Bienvenida.<init>(Bienvenida.java:23)
at bienvenida.Bienvenida.main(Bienvenida.java:72)
C:\Users\Marcelo\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)
-------------------------------------------------------------------------------------------------------
bloque de codigo:
-------------------------------------------------------------------------------------------------------
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:217)
at bienvenida.Bienvenida.<init>(Bienvenida.java:23)
at bienvenida.Bienvenida.main(Bienvenida.java:72)
C:\Users\Marcelo\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)
-------------------------------------------------------------------------------------------------------
bloque de codigo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package bienvenida;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Bienvenida extends JFrame implements ActionListener{
private JButton btnIngrear;
private JTextField caja1;
private JLabel etiqueta1, etiqueta2, etiqueta3, etiqueta4;
public Bienvenida(){
setLayout(null);
setTitle("Bienvenido");
getContentPane().setBackground(new Color(255,0,0));
setIconImage(new ImageIcon(getClass().getResource("images/icon.png")).getImage());
ImageIcon imagen=new ImageIcon("images/logo-coca.png");
etiqueta1=new JLabel(imagen);
etiqueta1=new JLabel("Coca-Cola");
etiqueta1.setBounds(25, 15, 300, 150);
add(etiqueta1);
Valora esta pregunta


0