powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / Exception in thread "main" java.lang.IllegalArgumentException: adding container's parent t
3 сообщений из 3, страница 1 из 1
Exception in thread "main" java.lang.IllegalArgumentException: adding container's parent t
    #38356455
antonm1
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
сначала запускал new ReadingDemo(); Потом глянул решил переделать на run(). Могли ли это повлиять как-то что теперь вообще никак не работает. И ответа нигде нет. Куда смотреть?
Код: java
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.
public class ReadingDemo {

	private JFrame jfrm;
	private JLabel label;
	private JLabel adress;
	private JFileChooser fileopen;
	private JPanel panel;
	private JButton button;
	private JTextField field;

	ReadingDemo() {
		jfrm = new JFrame("2 строка");
		jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jfrm.setSize(400, 200);
		//задаем панель размещения
		panel = new JPanel();
		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

		label = new JLabel("Выберите файл");
		label.add(label);
		//какая-то хрень
		panel.add(Box.createRigidArea(new Dimension(0, 5)));
		
		button = new JButton("Обзор");
		field = new JTextField("");
		panel.add(field);
		adress = new JLabel("          ");
		button.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				fileopen = new JFileChooser(".");
				int ret = fileopen.showDialog(null, "Открыть файл");
				if (ret == JFileChooser.APPROVE_OPTION) {
					File file = fileopen.getSelectedFile();
					try {
						//передаем путь
						OpenFile of = new OpenFile(file.getAbsolutePath());
						field.setText(of.get_file());
						adress.setText(file.getAbsolutePath());
					} catch (SecurityException e1) {
						label.setText(e1.toString());
					}
				}
			}

		});

		JPanel panel2 = new JPanel();
		panel2.setLayout(new FlowLayout());
		panel2.add(button);
		panel2.add(adress);
		panel.add(panel2);
		jfrm.add(panel);

		// чтобы окно по центру
		jfrm.setLocationRelativeTo(null);

		jfrm.setVisible(true);

	}

	public static void main(String[] args) {
		//new ReadingDemo();
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JFrame.setDefaultLookAndFeelDecorated(true);
                JDialog.setDefaultLookAndFeelDecorated(true);
                new ReadingDemo();
            }
        });
	}

}
...
Рейтинг: 0 / 0
Exception in thread "main" java.lang.IllegalArgumentException: adding container's parent t
    #38357646
antonm1
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
antonm1,
Неужели никто не может подсказать????
...
Рейтинг: 0 / 0
Exception in thread "main" java.lang.IllegalArgumentException: adding container's parent t
    #38357717
antonm1
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
решено- ошибка label.add(label);
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / Exception in thread "main" java.lang.IllegalArgumentException: adding container's parent t
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]