java.lang.NullPointer al intentar agregar imagenes
Publicado por Shiegfried568 (4 intervenciones) el 26/08/2019 23:24:27
Estaba intentando hacer una practica para un curso y al iniciar el programa me salta el error de la siguiente forma:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknow Source)
at Inicio.<init>(Inicio.java:16)
at Inicio.main(Inicio.java:65)
El código es este:
Perdón por el diseño pero apenas estoy aprendiendo y quería saber como arreglar el problema
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknow Source)
at Inicio.<init>(Inicio.java:16)
at Inicio.main(Inicio.java:65)
El código es este:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class Inicio extends JFrame implements ActionListener{
private JLabel label1, label2, label3;
private JTextField field1;
private JButton boton1;
public Inicio(){
setLayout(null);
label1 = new JLabel("Sistema de Control Vacacional");
label1.setBounds(50,300,300,50);
add(label1);
label2 = new JLabel("Ingrese su nombre:");
label2.setBounds(50,400,150,30);
add(label2);
label3 = new JLabel("°2017 The Coca-Cola Company");
label3.setBOunds(100,600,150,30);
add(label3);
field1 = new JTextField();
field1.setBounds(50,430,300,40);
add(field1);
boton1 = JButton("Ingresar");
boton1.setBOunds(150,500,120,40);
boton1.addActionListener(this);
add(boton1);
setTitle("Bienvenido");
setBackground(new Color(255,0,0));
}
public void actionPerformed(ActionListener e){
if(e.getSource == boton1){
System.exit(0);
}
}
public static void main(String args[]){
Inicio interfaz = new Inicio();
interfaz.setBounds(0,0,400,700);
interfaz.setVisible(true);
interfaz.setResizable(false);
interfaz.setLocationRelativeTo(null);
}
}
Perdón por el diseño pero apenas estoy aprendiendo y quería saber como arreglar el problema
Valora esta pregunta


0