Exception in thread "main" java.lang.NullPointerException
Publicado por Seba (3 intervenciones) el 24/11/2020 03:32:23
Hola, el problema que tengo es que compila de lo mas bien pero cuando quiero ejecutar la clase en el CMD me muestra esto:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at Bienvenida.<init>(Bienvenida.java:16)
at Bienvenida.main(Bienvenida.java:69)
No se que error tengo, revise el codigo tres veces y hasta modifiqué la ruta de la linea 16 ya que ahí supuestamente está un error.
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at Bienvenida.<init>(Bienvenida.java:16)
at Bienvenida.main(Bienvenida.java:69)
No se que error tengo, revise el codigo tres veces y hasta modifiqué la ruta de la linea 16 ya que ahí supuestamente está un error.
Las imagenes en cuanto a nombre, extencion(png), y ruta estan bien, tambien el tamaño, para el icono es de 180*180px y la otra de JLabel label1 es de 300*150px como el objeto.
Por favor ayudaaaaaaaaaaaaaaaaaaa!!!!!!!!
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Bienvenida extends JFrame implements ActionListener{
private JLabel label1, label2, label3, label4;
private JTextField textf1;
private JButton boton1;
public Bienvenida(){
setLayout(null);
setTitle("Bienvenido");
getContentPane().setBackground(new Color(255,0,0));
setIconImage(new ImageIcon(getClass().getResource("C:/Users/Loflad Sandra/Desktop/Proyecto/image/Logo.png")).getImage());
ImageIcon imagen = new ImageIcon("images/coca.png");
label1 = new JLabel(imagen);
label1.setBounds(25,15,300,150);
add(label1);
label2 = new JLabel("Sistema de control Vacacional");
label2.setBounds(35,135,300,30);
label2.setFont(new Font("Andale Mono", 3, 18));
label2.setForeground(new Color(255,255,255));
add(label2);
label3 = new JLabel("Ingrese su nombre");
label3.setBounds(45,212,200,30);
label3.setFont(new Font("Andale Mono", 1, 12));
label3.setForeground(new Color(255,255,255));
add(label3);
label4 = new JLabel("©2017 The Coca-Cola Company");
label4.setBounds(85,375,300,30);
label4.setFont(new Font("Andale Mono", 1, 12));
label4.setForeground(new Color(255,255,255));
add(label4);
textf1 = new JTextField();
textf1.setBounds(45,240,255,25);
textf1.setBackground(new Color(224,224,224));
textf1.setFont(new Font("Andale Mono", 1, 14));
textf1.setForeground(new Color(255,0,0));
add(textf1);
boton1 = new JButton("Ingresar");
boton1.setBounds(125,280,100,30);
boton1.setBackground(new Color(255,255,255));
boton1.setFont(new Font("Andale Mono", 1, 14));
boton1.setForeground(new Color(255,0,0));
boton1.addActionListener(this);
add(boton1);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == boton1){
}
}
public static void main(String args[]){
Bienvenida ventanabienvenida = new Bienvenida();
ventanabienvenida.setBounds(0,0,350,450);
ventanabienvenida.setVisible(true);
ventanabienvenida.setResizable(false);
ventanabienvenida.setLocationRelativeTo(null);
}
}
Valora esta pregunta


0