Advertisement
Guest User

vajno

a guest
Dec 11th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.53 KB | None | 0 0
  1. import java.awt.BorderLayout;
  2.  
  3. import java.awt.EventQueue;
  4.  
  5. import javax.swing.JFrame;
  6. import javax.swing.JPanel;
  7. import javax.swing.border.EmptyBorder;
  8. import javax.swing.JTable;
  9. import javax.swing.JTextPane;
  10. import javax.swing.table.DefaultTableModel;
  11.  
  12. import java.awt.Color;
  13. import java.awt.Font;
  14.  
  15. import javax.swing.JButton;
  16.  
  17. import java.awt.event.ActionListener;
  18. import java.awt.event.ActionEvent;
  19. import java.net.*;
  20. import java.io.*;
  21. import javax.swing.JOptionPane;
  22.  
  23. public class Magazik extends JFrame {
  24.  
  25.  
  26. private JPanel contentPane;
  27. private JTable table;
  28. private JTable tableTovar;
  29.  
  30. /**
  31. * Launch the application.
  32. */
  33. private String makeGet()
  34. {
  35. String rez ="?";
  36. for (int i=0;i<10;i++)
  37.  
  38. {
  39. rez+=("Tov"+(i+1)+"=");
  40. int kol;
  41. try
  42. {
  43. String str=table.getValueAt(1, 3).toString().trim();
  44. kol=Integer.parseInt(str);
  45. }
  46. catch(Exception e)
  47. {
  48. kol=0;
  49. }
  50. rez+=""+kol+"&";
  51. }
  52. return rez;
  53. }
  54. public static void main(String[] args) {
  55. EventQueue.invokeLater(new Runnable() {
  56. public void run() {
  57. try {
  58. Magazik frame = new Magazik();
  59. frame.setVisible(true);
  60. } catch (Exception e) {
  61. e.printStackTrace();
  62. }
  63. }
  64. });
  65. }
  66.  
  67. /**
  68. * Create the frame.
  69. */
  70. public Magazik() {
  71. setTitle("\u0422\u043E\u0432\u0430\u0440\u044B ");
  72. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  73. setBounds(100, 100, 585, 330);
  74. contentPane = new JPanel();
  75. contentPane.setBackground(Color.BLUE);
  76. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  77. setContentPane(contentPane);
  78. contentPane.setLayout(null);
  79.  
  80. table = new JTable();
  81. table.setSurrendersFocusOnKeystroke(true);
  82. table.setColumnSelectionAllowed(true);
  83. table.setCellSelectionEnabled(true);
  84. table.setFont(new Font("Comic Sans MS", Font.PLAIN, 11));
  85. table.setBackground(Color.YELLOW);
  86. table.setModel(new DefaultTableModel(
  87. new Object[][] {
  88. {"1", "Sweet box \u043A\u043E\u0442\u0438\u043A\u0438", "", "1", "150"},
  89. {"2", "Sweet box \u043F\u0435\u0441\u0438\u043A\u0438", "", "245", "1203"},
  90. {"3", "Sweet box \u0441\u043C\u0435\u0448\u0430\u0440\u0438\u043A\u0438", "", "678", "455"},
  91. {"4", "Sweet box \u043F\u043E\u043D\u0438", "", "452", "212"},
  92. {"5", "Sweet box \u043A\u043E\u043D\u0438", "", "453", "228"},
  93. {"6", "Sweet box \u043C\u0430\u0448\u0438\u043D\u043A\u0438", "", "255", "154"},
  94. {"7", "Sweet box \u0442\u0430\u043D\u043A\u0438", "", "855345", "1337"},
  95. {"8", "Sweet box \u043A\u043E\u0440\u0430\u0431\u043B\u0438\u043A\u0438", "", "456", "3535"},
  96. {"9", "Sweet box \u043F\u0442\u0438\u0447\u043A\u0438", "", "54", "22"},
  97. {"10", "Sweet box \u043F\u0442\u0438\u0447\u043A\u0438 \u043D\u0430 \u043C\u0430\u0448\u0438\u043D\u043A\u0430\u0445", "", "5442", "120"},
  98. },
  99. new String[] {
  100. "\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"
  101. }
  102. ) {
  103. boolean[] columnEditables = new boolean[] {
  104. false, false, false, false, false
  105. };
  106. public boolean isCellEditable(int row, int column) {
  107. return columnEditables[column];
  108. }
  109. });
  110. table.getColumnModel().getColumn(0).setResizable(false);
  111. table.getColumnModel().getColumn(0).setPreferredWidth(46);
  112. table.getColumnModel().getColumn(1).setResizable(false);
  113. table.getColumnModel().getColumn(1).setPreferredWidth(167);
  114. table.getColumnModel().getColumn(2).setResizable(false);
  115. table.getColumnModel().getColumn(2).setPreferredWidth(107);
  116. table.getColumnModel().getColumn(3).setResizable(false);
  117. table.getColumnModel().getColumn(3).setPreferredWidth(82);
  118. table.getColumnModel().getColumn(4).setResizable(false);
  119. table.setBounds(64, 133, 434, 173);
  120. contentPane.add(table);
  121.  
  122. JTextPane textPane = new JTextPane();
  123. textPane.setFont(new Font("Comic Sans MS", Font.BOLD | Font.ITALIC, 13));
  124. textPane.setForeground(Color.BLACK);
  125. textPane.setBackground(Color.YELLOW);
  126. 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");
  127. textPane.setBounds(82, 0, 393, 26);
  128. contentPane.add(textPane);
  129.  
  130. JButton button = new JButton("\u0422\u044B\u043A");
  131. button.addActionListener(new ActionListener() {
  132. public void actionPerformed(ActionEvent arg0) {
  133. String str ="http://Magazik/tovar.php"+makeGet();
  134.  
  135. boolean flag=false;
  136.  
  137. try
  138. {
  139. URL url=new URL(str);
  140. HttpURLConnection conn=(HttpURLConnection)url.openConnection();
  141. conn.connect();
  142. BufferedReader in=new BufferedReader(new InputStreamReader(conn.getInputStream()));
  143. String Inputline=in.readLine().trim();
  144. if(Inputline.indexOf('~')>=0)
  145. {
  146. flag=true;
  147. String[] mas= Inputline.split("~");
  148. for (int i=0; i<mas.length;i++)
  149. {
  150. table.setValueAt(mas[i], i, 2);
  151. }
  152. }
  153. in.close();
  154. conn.disconnect();
  155. conn=null;
  156. }
  157. catch(Exception e){}
  158. if(flag==false);
  159. {JOptionPane.showMessageDialog(null,"Bозможно ты не оплатил интернет или что-то типа того.", "Проблемы с нашим сайтом, прости, друг.Подожди пару дней",0);
  160. }
  161. }
  162. });
  163. button.setBounds(203, 62, 134, 41);
  164. contentPane.add(button);
  165.  
  166. }
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement