https://pastein.ru/t/W-

  скопируйте уникальную ссылку для отправки


private final class AddDevice implements ActionListener{
	@Override
	public void actionPerformed(ActionEvent arg0) {
		String[] options = {"Добавить"};
		JPanel panel = new JPanel();
		panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
		JLabel lbl = new JLabel("Введите наименованиие техники: ");
		JTextField txt = new JTextField(20);
		panel.add(lbl);
		panel.add(txt);
		int selectedOption = JOptionPane.showOptionDialog(null, panel, "Добавление", JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);

		if(selectedOption == 0)
		{
		    String text = txt.getText();
		    Tabs t = new Tabs(text);
		    listTabs.add(t);
			tab.add(t.getPublicPanel());
			tab.revalidate();
			
		}	
	}	
}
private final class  Item2 implements ActionListener{

	@Override
	public void actionPerformed(ActionEvent e) {
		String nameTab = JOptionPane.showInputDialog("Введите наименование техники,\n которую надо удалить:");
		Component[] tabs=tab.getComponents();
		int count=0;
		for(int i=0;i<tabs.length;i++){
			String s=tabs[i].getName();
		if((s.toLowerCase()).contains(nameTab.toLowerCase())){
			System.out.println(tabs[i].getName());
			tab.remove(i-count);
			count++;
		}}
		
		}
	}
private final class DeleteTab implements ActionListener{
	@Override
	public void actionPerformed(ActionEvent e) {
		int index = tab.getSelectedIndex();
		Component[] arr = tab.getComponents();
		for (Tabs t:listTabs){
			if ((arr[index].getName()).equals(t.getPublicPanel().getName())){
				listTabs.remove(t);
			}
		}
		tab.remove(index);	
	}	
}

private final class CloseFrame extends WindowAdapter{
	public void windowClosing(WindowEvent event){
		File file = new File(fileName);
		try {
			FileOutputStream writer =new FileOutputStream(file);
			String s = "";
			writer.write(s.getBytes());
			writer.close();
		} catch (FileNotFoundException e1) {
			
			e1.printStackTrace();
		} catch (IOException e) {
			
			e.printStackTrace();
		}
		try {
			ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream(file,true));
			output.writeInt(listTabs.size());
			for (Tabs t:listTabs){
				output.writeObject(t);
			}
			output.close();
		} catch (IOException e) {}
		System.exit(0);	
	}
}
private final class ChangeSizeFrame extends ComponentAdapter{
	public void componentResized(ComponentEvent evt){
		int width = frame.getWidth();
		int height = frame.getHeight();
		for (Tabs tab:listTabs){
			JPanel panelBoxes = tab.getPanelBoxes();
			panelBoxes.setSize(width-217, height-138);
		}
	}
}	
}