Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BorderLayout;
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import javax.swing.JTable;
- import javax.swing.JTextPane;
- import javax.swing.table.DefaultTableModel;
- import java.awt.Color;
- import java.awt.Font;
- import javax.swing.JButton;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import java.net.*;
- import java.io.*;
- import javax.swing.JOptionPane;
- public class Magazik extends JFrame {
- private JPanel contentPane;
- private JTable table;
- private JTable tableTovar;
- /**
- * Launch the application.
- */
- private String makeGet()
- {
- String rez ="?";
- for (int i=0;i<10;i++)
- {
- rez+=("Tov"+(i+1)+"=");
- int kol;
- try
- {
- String str=table.getValueAt(1, 3).toString().trim();
- kol=Integer.parseInt(str);
- }
- catch(Exception e)
- {
- kol=0;
- }
- rez+=""+kol+"&";
- }
- return rez;
- }
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Magazik frame = new Magazik();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the frame.
- */
- public Magazik() {
- setTitle("\u0422\u043E\u0432\u0430\u0440\u044B ");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 585, 330);
- contentPane = new JPanel();
- contentPane.setBackground(Color.BLUE);
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
- table = new JTable();
- table.setSurrendersFocusOnKeystroke(true);
- table.setColumnSelectionAllowed(true);
- table.setCellSelectionEnabled(true);
- table.setFont(new Font("Comic Sans MS", Font.PLAIN, 11));
- table.setBackground(Color.YELLOW);
- table.setModel(new DefaultTableModel(
- new Object[][] {
- {"1", "Sweet box \u043A\u043E\u0442\u0438\u043A\u0438", "", "1", "150"},
- {"2", "Sweet box \u043F\u0435\u0441\u0438\u043A\u0438", "", "245", "1203"},
- {"3", "Sweet box \u0441\u043C\u0435\u0448\u0430\u0440\u0438\u043A\u0438", "", "678", "455"},
- {"4", "Sweet box \u043F\u043E\u043D\u0438", "", "452", "212"},
- {"5", "Sweet box \u043A\u043E\u043D\u0438", "", "453", "228"},
- {"6", "Sweet box \u043C\u0430\u0448\u0438\u043D\u043A\u0438", "", "255", "154"},
- {"7", "Sweet box \u0442\u0430\u043D\u043A\u0438", "", "855345", "1337"},
- {"8", "Sweet box \u043A\u043E\u0440\u0430\u0431\u043B\u0438\u043A\u0438", "", "456", "3535"},
- {"9", "Sweet box \u043F\u0442\u0438\u0447\u043A\u0438", "", "54", "22"},
- {"10", "Sweet box \u043F\u0442\u0438\u0447\u043A\u0438 \u043D\u0430 \u043C\u0430\u0448\u0438\u043D\u043A\u0430\u0445", "", "5442", "120"},
- },
- new String[] {
- "\u041D\u043E\u043C\u0435\u0440", "\u041D\u0430\u0438\u043C\u0435\u043D\u043E\u0432\u0430\u043D\u0438\u0435", "\u041E\u0441\u0442\u0430\u0442\u043E\u043A \u043D\u0430 \u0441\u043A\u043B\u0430\u0434\u0435", "\u0426\u0435\u043D\u0430", "\u0426\u0435\u043D\u0430"
- }
- ) {
- boolean[] columnEditables = new boolean[] {
- false, false, false, false, false
- };
- public boolean isCellEditable(int row, int column) {
- return columnEditables[column];
- }
- });
- table.getColumnModel().getColumn(0).setResizable(false);
- table.getColumnModel().getColumn(0).setPreferredWidth(46);
- table.getColumnModel().getColumn(1).setResizable(false);
- table.getColumnModel().getColumn(1).setPreferredWidth(167);
- table.getColumnModel().getColumn(2).setResizable(false);
- table.getColumnModel().getColumn(2).setPreferredWidth(107);
- table.getColumnModel().getColumn(3).setResizable(false);
- table.getColumnModel().getColumn(3).setPreferredWidth(82);
- table.getColumnModel().getColumn(4).setResizable(false);
- table.setBounds(64, 133, 434, 173);
- contentPane.add(table);
- JTextPane textPane = new JTextPane();
- textPane.setFont(new Font("Comic Sans MS", Font.BOLD | Font.ITALIC, 13));
- textPane.setForeground(Color.BLACK);
- textPane.setBackground(Color.YELLOW);
- textPane.setText(" \u0422\u043E\u0432\u0430\u0440\u044B, \u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u0432\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u043A\u0443\u043F\u0438\u0442\u044C \u0443 \u043D\u0430\u0441");
- textPane.setBounds(82, 0, 393, 26);
- contentPane.add(textPane);
- JButton button = new JButton("\u0422\u044B\u043A");
- button.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- String str ="http://Magazik/tovar.php"+makeGet();
- boolean flag=false;
- try
- {
- URL url=new URL(str);
- HttpURLConnection conn=(HttpURLConnection)url.openConnection();
- conn.connect();
- BufferedReader in=new BufferedReader(new InputStreamReader(conn.getInputStream()));
- String Inputline=in.readLine().trim();
- if(Inputline.indexOf('~')>=0)
- {
- flag=true;
- String[] mas= Inputline.split("~");
- for (int i=0; i<mas.length;i++)
- {
- table.setValueAt(mas[i], i, 2);
- }
- }
- in.close();
- conn.disconnect();
- conn=null;
- }
- catch(Exception e){}
- if(flag==false);
- {JOptionPane.showMessageDialog(null,"Bозможно ты не оплатил интернет или что-то типа того.", "Проблемы с нашим сайтом, прости, друг.Подожди пару дней",0);
- }
- }
- });
- button.setBounds(203, 62, 134, 41);
- contentPane.add(button);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement