Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.LinkedList;
- import javax.swing.JRadioButton;
- import javax.swing.JTextArea;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author sused
- */
- public class ExkurziA extends javax.swing.JFrame {
- LinkedList ch = new LinkedList();
- LinkedList d = new LinkedList();
- /**
- * Creates new form ExkurziA
- */
- public ExkurziA() {
- initComponents();
- }
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- buttonGroup1 = new javax.swing.ButtonGroup();
- jButton1 = new javax.swing.JButton();
- jTextField1 = new javax.swing.JTextField();
- jLabel1 = new javax.swing.JLabel();
- jRadioButton1 = new javax.swing.JRadioButton();
- jRadioButton2 = new javax.swing.JRadioButton();
- jScrollPane1 = new javax.swing.JScrollPane();
- jTextArea1 = new javax.swing.JTextArea();
- jButton2 = new javax.swing.JButton();
- jButton3 = new javax.swing.JButton();
- jLabel2 = new javax.swing.JLabel();
- jButton4 = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jButton1.setText("Pridaj študenta");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jLabel1.setText("Meno študenta:");
- buttonGroup1.add(jRadioButton1);
- jRadioButton1.setSelected(true);
- jRadioButton1.setText("Žena");
- buttonGroup1.add(jRadioButton2);
- jRadioButton2.setText("Muž");
- jTextArea1.setColumns(20);
- jTextArea1.setRows(5);
- jScrollPane1.setViewportView(jTextArea1);
- jButton2.setText("Odober študenta");
- jButton2.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
- }
- });
- jButton3.setText("Vytvor páry");
- jButton3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton3ActionPerformed(evt);
- }
- });
- jLabel2.setText("Páry:");
- jButton4.setText("Zmaz Zoznam");
- jButton4.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton4ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel1)
- .addComponent(jRadioButton1)
- .addComponent(jRadioButton2)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jButton1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jButton2))
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(160, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
- .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGap(0, 0, Short.MAX_VALUE))))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(29, 29, 29)
- .addComponent(jLabel1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jRadioButton1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jRadioButton2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton1)
- .addComponent(jButton2))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton3)
- .addComponent(jButton4))
- .addGap(54, 54, 54)
- .addComponent(jLabel2)
- .addContainerGap())
- );
- pack();
- }// </editor-fold>
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- if (jRadioButton1.isSelected()) {
- ch.add(jTextField1.getText());
- jTextArea1.append(jTextField1.getText()+"\n");
- } else if (jRadioButton2.isSelected()) {
- d.add(jTextField1.getText());
- jTextArea1.append(jTextField1.getText()+"\n");
- }
- }
- private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
- if (ch.size() == d.size()) {
- jLabel2.setText("Dajú sa vytvoriť páry. ");
- } else {
- jLabel2.setText("Nedaju sa vytvoriť páry. ");
- }
- }
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
- jTextArea1.replaceSelection("");
- }
- private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
- jTextArea1.setText("");
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(ExkurziA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(ExkurziA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(ExkurziA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(ExkurziA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new ExkurziA().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.ButtonGroup buttonGroup1;
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JButton jButton4;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JRadioButton jRadioButton1;
- private javax.swing.JRadioButton jRadioButton2;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JTextArea jTextArea1;
- private javax.swing.JTextField jTextField1;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement