Eclipse - NullPointerException

 
Vista:
sin imagen de perfil
Val: 1
Ha disminuido su posición en 4 puestos en Eclipse (en relación al último mes)
Gráfica de Eclipse

NullPointerException

Publicado por Roberto (1 intervención) el 12/06/2019 07:08:12
Buenas noches amigos, es la primera vez que participo en un foro, estoy aprendiendo a programar y realmente estoy con un problema que me esta volviendo loco.
Ojalá alguien me pueda ayudar.

Estoy haciendo una pantalla con windowbuilder en la que pueda agregar a un jframe películas que tenga, junto con algunos detalles de la misma, no encuentro el error pero a la hora de ejecutar me salta un error que dice: java.lang.NullPointerException

muchas gracias!

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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Image;
import java.awt.SystemColor;
 
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import java.awt.Color;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
 
public class consult extends JFrame {
 
	DefaultTableModel model;
 
	private JTable table;
	private JPanel contentPane;
	private JTextField peliculaTF;
	private JTextField estatusTF;
	private JTextField directorTF;
	private JTextField AñoTF;
	private JTextField generoTF;
 
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					consult frame = new consult();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
 
	/**
	 * Create the frame.
	 */
	public consult() {
 
		model = (DefaultTableModel)table.getModel();
 
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 952, 489);
		contentPane = new JPanel();
		contentPane.setBackground(SystemColor.desktop);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
 
		ImageIcon icon = new ImageIcon("C:\\Users\\xdrob\\Pictures\\PF\\mono.png");
		JLabel lbltitlo = new JLabel("");
		lbltitlo.setIcon(new ImageIcon(icon.getImage().getScaledInstance(234,166, Image.SCALE_SMOOTH)));
 
		JLabel lblMovieManager = new JLabel("M O V I E     M A N A G E R ");
		lblMovieManager.setFont(new Font("Segoe UI Semilight", Font.PLAIN, 34));
		lblMovieManager.setForeground(SystemColor.text);
 
		getContentPane().setBackground(Color.BLACK);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 962, 641);
		getContentPane().setLayout(null);
 
		JScrollPane scrollPane = new JScrollPane();
 
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Película", "Estatus", "Director", "Año", "Género"
			}
		));
		scrollPane.setViewportView(table);
 
		JLabel lblPelicula = new JLabel("Película:");
		lblPelicula.setForeground(Color.WHITE);
		lblPelicula.setFont(new Font("Segoe UI Semilight", Font.PLAIN, 16));
 
		peliculaTF = new JTextField();
		peliculaTF.setColumns(10);
 
		JLabel lblEstatus = new JLabel("Estatus:");
		lblEstatus.setForeground(Color.WHITE);
		lblEstatus.setFont(new Font("Segoe UI Semilight", Font.PLAIN, 16));
 
		estatusTF = new JTextField();
		estatusTF.setColumns(10);
 
		JLabel lblDirector = new JLabel("Director:");
		lblDirector.setForeground(Color.WHITE);
		lblDirector.setFont(new Font("Segoe UI Semilight", Font.PLAIN, 16));
 
		directorTF = new JTextField();
		directorTF.setColumns(10);
 
		JLabel lblAño = new JLabel("Año:");
		lblAño.setForeground(Color.WHITE);
		lblAño.setFont(new Font("Segoe UI Semilight", Font.PLAIN, 16));
 
		AñoTF = new JTextField();
		AñoTF.setColumns(10);
 
		JLabel lblGénero = new JLabel("Género:");
		lblGénero.setForeground(Color.WHITE);
		lblGénero.setFont(new Font("Segoe UI Semilight", Font.PLAIN, 16));
 
		generoTF = new JTextField();
		generoTF.setColumns(10);
 
		JButton btnAgregar = new JButton("Agregar");
		btnAgregar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
 
				model.insertRow(model.getRowCount(), new Object[] {peliculaTF.getText(),estatusTF.getText(), directorTF.getText(), AñoTF.getText(), generoTF.getText()});
 
			}
		});
 
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addContainerGap()
					.addComponent(lbltitlo, GroupLayout.PREFERRED_SIZE, 214, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(lblMovieManager, GroupLayout.PREFERRED_SIZE, 421, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(287, Short.MAX_VALUE))
				.addGroup(gl_contentPane.createSequentialGroup()
					.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 879, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED))
						.addGroup(gl_contentPane.createSequentialGroup()
							.addComponent(lblPelicula, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
							.addGap(113)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addComponent(lblEstatus, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE)
								.addComponent(estatusTF, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addGap(84)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addComponent(lblDirector, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE)
								.addComponent(directorTF, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addGap(77)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addComponent(lblAño, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
								.addComponent(AñoTF, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addGap(84)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
								.addComponent(generoTF, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblGénero, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE))
							.addGap(73)))
					.addGap(60))
				.addGroup(gl_contentPane.createSequentialGroup()
					.addContainerGap()
					.addComponent(peliculaTF, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(843, Short.MAX_VALUE))
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGap(359)
					.addComponent(btnAgregar, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(401, Short.MAX_VALUE))
		);
		gl_contentPane.setVerticalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGap(49)
							.addComponent(lblMovieManager, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE))
						.addComponent(lbltitlo))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addComponent(lblPelicula)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(peliculaTF, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_contentPane.createSequentialGroup()
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblEstatus)
								.addComponent(lblDirector)
								.addComponent(lblAño)
								.addComponent(lblGénero))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
								.addComponent(estatusTF, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(directorTF, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(AñoTF, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(generoTF, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
					.addGap(18)
					.addComponent(btnAgregar)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 335, GroupLayout.PREFERRED_SIZE)
					.addContainerGap())
		);
		contentPane.setLayout(gl_contentPane);
 
	}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder