Advertisement
ljukk

exx

May 27th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.58 KB | None | 0 0
  1. import java.util.LinkedList;
  2. import javax.swing.JRadioButton;
  3. import javax.swing.JTextArea;
  4.  
  5. /*
  6. * To change this license header, choose License Headers in Project Properties.
  7. * To change this template file, choose Tools | Templates
  8. * and open the template in the editor.
  9. */
  10.  
  11. /**
  12. *
  13. * @author sused
  14. */
  15. public class ExkurziA extends javax.swing.JFrame {
  16.  
  17. LinkedList ch = new LinkedList();
  18. LinkedList d = new LinkedList();
  19.  
  20.  
  21. /**
  22. * Creates new form ExkurziA
  23. */
  24. public ExkurziA() {
  25. initComponents();
  26. }
  27.  
  28. /**
  29. * This method is called from within the constructor to initialize the form.
  30. * WARNING: Do NOT modify this code. The content of this method is always
  31. * regenerated by the Form Editor.
  32. */
  33. @SuppressWarnings("unchecked")
  34. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  35. private void initComponents() {
  36.  
  37. buttonGroup1 = new javax.swing.ButtonGroup();
  38. jButton1 = new javax.swing.JButton();
  39. jTextField1 = new javax.swing.JTextField();
  40. jLabel1 = new javax.swing.JLabel();
  41. jRadioButton1 = new javax.swing.JRadioButton();
  42. jRadioButton2 = new javax.swing.JRadioButton();
  43. jScrollPane1 = new javax.swing.JScrollPane();
  44. jTextArea1 = new javax.swing.JTextArea();
  45. jButton2 = new javax.swing.JButton();
  46. jButton3 = new javax.swing.JButton();
  47. jLabel2 = new javax.swing.JLabel();
  48. jButton4 = new javax.swing.JButton();
  49.  
  50. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  51.  
  52. jButton1.setText("Pridaj študenta");
  53. jButton1.addActionListener(new java.awt.event.ActionListener() {
  54. public void actionPerformed(java.awt.event.ActionEvent evt) {
  55. jButton1ActionPerformed(evt);
  56. }
  57. });
  58.  
  59. jLabel1.setText("Meno študenta:");
  60.  
  61. buttonGroup1.add(jRadioButton1);
  62. jRadioButton1.setSelected(true);
  63. jRadioButton1.setText("Žena");
  64.  
  65. buttonGroup1.add(jRadioButton2);
  66. jRadioButton2.setText("Muž");
  67.  
  68. jTextArea1.setColumns(20);
  69. jTextArea1.setRows(5);
  70. jScrollPane1.setViewportView(jTextArea1);
  71.  
  72. jButton2.setText("Odober študenta");
  73. jButton2.addActionListener(new java.awt.event.ActionListener() {
  74. public void actionPerformed(java.awt.event.ActionEvent evt) {
  75. jButton2ActionPerformed(evt);
  76. }
  77. });
  78.  
  79. jButton3.setText("Vytvor páry");
  80. jButton3.addActionListener(new java.awt.event.ActionListener() {
  81. public void actionPerformed(java.awt.event.ActionEvent evt) {
  82. jButton3ActionPerformed(evt);
  83. }
  84. });
  85.  
  86. jLabel2.setText("Páry:");
  87.  
  88. jButton4.setText("Zmaz Zoznam");
  89. jButton4.addActionListener(new java.awt.event.ActionListener() {
  90. public void actionPerformed(java.awt.event.ActionEvent evt) {
  91. jButton4ActionPerformed(evt);
  92. }
  93. });
  94.  
  95. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  96. getContentPane().setLayout(layout);
  97. layout.setHorizontalGroup(
  98. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  99. .addGroup(layout.createSequentialGroup()
  100. .addContainerGap()
  101. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  102. .addGroup(layout.createSequentialGroup()
  103. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  104. .addComponent(jLabel1)
  105. .addComponent(jRadioButton1)
  106. .addComponent(jRadioButton2)
  107. .addGroup(layout.createSequentialGroup()
  108. .addComponent(jButton1)
  109. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  110. .addComponent(jButton2))
  111. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
  112. .addContainerGap(160, Short.MAX_VALUE))
  113. .addGroup(layout.createSequentialGroup()
  114. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  115. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  116. .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
  117. .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  118. .addGroup(layout.createSequentialGroup()
  119. .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
  120. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  121. .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)))
  122. .addGap(0, 0, Short.MAX_VALUE))))
  123. );
  124. layout.setVerticalGroup(
  125. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  126. .addGroup(layout.createSequentialGroup()
  127. .addGap(29, 29, 29)
  128. .addComponent(jLabel1)
  129. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  130. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  131. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  132. .addComponent(jRadioButton1)
  133. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  134. .addComponent(jRadioButton2)
  135. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  136. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  137. .addComponent(jButton1)
  138. .addComponent(jButton2))
  139. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  140. .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
  141. .addGap(18, 18, 18)
  142. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  143. .addComponent(jButton3)
  144. .addComponent(jButton4))
  145. .addGap(54, 54, 54)
  146. .addComponent(jLabel2)
  147. .addContainerGap())
  148. );
  149.  
  150. pack();
  151. }// </editor-fold>
  152.  
  153. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  154. if (jRadioButton1.isSelected()) {
  155. ch.add(jTextField1.getText());
  156. jTextArea1.append(jTextField1.getText()+"\n");
  157. } else if (jRadioButton2.isSelected()) {
  158. d.add(jTextField1.getText());
  159. jTextArea1.append(jTextField1.getText()+"\n");
  160. }
  161. }
  162.  
  163.  
  164. private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
  165. if (ch.size() == d.size()) {
  166. jLabel2.setText("Dajú sa vytvoriť páry. ");
  167. } else {
  168. jLabel2.setText("Nedaju sa vytvoriť páry. ");
  169. }
  170. }
  171.  
  172. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
  173. jTextArea1.replaceSelection("");
  174.  
  175. }
  176.  
  177. private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
  178. jTextArea1.setText("");
  179. }
  180.  
  181. /**
  182. * @param args the command line arguments
  183. */
  184. public static void main(String args[]) {
  185. /* Set the Nimbus look and feel */
  186. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  187. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  188. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  189. */
  190. try {
  191. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  192. if ("Nimbus".equals(info.getName())) {
  193. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  194. break;
  195. }
  196. }
  197. } catch (ClassNotFoundException ex) {
  198. java.util.logging.Logger.getLogger(ExkurziA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  199. } catch (InstantiationException ex) {
  200. java.util.logging.Logger.getLogger(ExkurziA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  201. } catch (IllegalAccessException ex) {
  202. java.util.logging.Logger.getLogger(ExkurziA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  203. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  204. java.util.logging.Logger.getLogger(ExkurziA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  205. }
  206. //</editor-fold>
  207.  
  208. /* Create and display the form */
  209. java.awt.EventQueue.invokeLater(new Runnable() {
  210. public void run() {
  211. new ExkurziA().setVisible(true);
  212. }
  213. });
  214. }
  215.  
  216. // Variables declaration - do not modify
  217. private javax.swing.ButtonGroup buttonGroup1;
  218. private javax.swing.JButton jButton1;
  219. private javax.swing.JButton jButton2;
  220. private javax.swing.JButton jButton3;
  221. private javax.swing.JButton jButton4;
  222. private javax.swing.JLabel jLabel1;
  223. private javax.swing.JLabel jLabel2;
  224. private javax.swing.JRadioButton jRadioButton1;
  225. private javax.swing.JRadioButton jRadioButton2;
  226. private javax.swing.JScrollPane jScrollPane1;
  227. private javax.swing.JTextArea jTextArea1;
  228. private javax.swing.JTextField jTextField1;
  229. // End of variables declaration
  230. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement