https://pastein.ru/t/QA

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


package lesson;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.awt.event.ActionEvent;

public class lll extends JFrame {

	private JPanel contentPane;
	private JTable table;
	
	private String makeGet() {
		String request = "?";
		for(int i = 0; i<10; i++) {
			request = request + "item";
			request = request + (i+1);
			request = request + "=";
			int kol;
			
			
			try {
				String str = table.getValueAt(i,3).toString().trim();
				kol = Integer.parseInt(str);
				
			}
			catch(Exception e) {
				kol = 0;
			}
			request = "" + kol + "&";
		}
		return request;
	}

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					lll frame = new lll();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public lll() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 573, 286);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(0, 0, 555, 197);
		contentPane.add(scrollPane);
		
		table = new JTable();
		scrollPane.setViewportView(table);
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{"1", "\u0418\u0433\u0440\u043E\u0432\u0430\u044F \u0424\u043E\u0440\u043C\u0430", null, null},
				{"2", "\u0411\u0443\u0442\u0441\u044B", null, null},
				{"3", "\u0418\u0433\u0440\u043E\u0432\u043E\u0439 \u043C\u044F\u0447", null, null},
				{"4", "\u0421\u043F\u043E\u0440\u0442\u0438\u0432\u043D\u044B\u0439 \u043A\u043E\u0441\u0442\u044E\u043C", null, null},
				{"5", "\u0421\u0443\u0432\u0435\u043D\u0438\u0440\u043D\u0430\u044F \u041A\u0440\u0443\u0436\u043A\u0430", null, null},
				{"6", "\u0427\u0435\u0445\u043B\u044B \u0434\u043B\u044F \u0422\u0435\u043B\u0435\u0444\u043E\u043D\u0430", null, null},
				{"7", "\u0421\u043F\u043E\u0440\u0442\u0438\u0432\u043D\u044B\u0439 \u041A\u043E\u0441\u0442\u044E\u043C", null, null},
				{"8", "\u0421\u0443\u0432\u0435\u043D\u0438\u0440\u043D\u044B\u0439 \u0428\u0430\u0440\u0444", null, null},
				{"9", "\u0421\u0443\u0432\u0435\u043D\u0438\u0440\u043D\u044B\u0439 \u041C\u0430\u0433\u043D\u0438\u0442", null, null},
				{"10", "\u0421\u0443\u0432\u0435\u043D\u0438\u0440\u043D\u044B\u0439 \u0411\u0440\u0435\u043B\u043E\u043A", null, null},
			},
			new String[] {
				"#", "\u041D\u0430\u0438\u043C\u0435\u043D\u043E\u0432\u0430\u043D\u0438\u0435 \u0442\u043E\u0432\u0430\u0440\u0430", "\u041E\u0441\u0442\u0430\u0442\u043E\u043A \u043D\u0430 \u0441\u043A\u043B\u0430\u0434\u0435", "\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043F\u043E\u0441\u0442\u0443\u043F\u043B\u0435\u043D\u0438\u0435"
			}
		));
		
		JButton btnNewButton = new JButton("\u0412\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u044C");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String str = "http://localhost/Lesson/list.php" + makeGet();
				boolean flag = false;
				try {
					URL link = new URL(str);
					HttpURLConnection connect = (HttpURLConnection)link.openConnection();
					connect.connect();
					BufferedReader in = new BufferedReader(new InputStreamReader(connect.getInputStream()));
					String inputLine = in.readLine().trim();
					if(inputLine.indexOf('~')>=0) {
						flag = true;
						String[] array = inputLine.split("~");
						for(int i = 0; i < array.length; i++) {
							table.setValueAt(array[i], i, 2);
						}
					}
					in.close();
					connect.disconnect();
					connect = null;
				}
				catch(Exception e) {
				if(flag == false) {
				JOptionPane.showMessageDialog(null,"Возможно интернет не подключен", "Ошибка отправки данных",1);
				}	
				}
			}
		});
		btnNewButton.setBounds(12, 207, 97, 25);
		contentPane.add(btnNewButton);
		table.getColumnModel().getColumn(0).setPreferredWidth(20);
		table.getColumnModel().getColumn(1).setPreferredWidth(157);
		table.getColumnModel().getColumn(2).setPreferredWidth(157);
		table.getColumnModel().getColumn(3).setPreferredWidth(157);
	}
}