settings

Download Settings

If you can't read please download the document

Upload: yito24

Post on 31-Jul-2015

33 views

Category:

Engineering


6 download

TRANSCRIPT

1. /* * 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. */ //package LaberintoGrafico; /* * 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. */ //package LaberintoGrafico; /** * * @author Yito */ public class Settings extends javax.swing.JFrame { /** * Creates new form MazeSettings */ public Settings() { 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") // //GEN- BEGIN:initComponents private void initComponents() { buttonGroup1 = new javax.swing.ButtonGroup(); jSeparator1 = new javax.swing.JSeparator(); Rows = new javax.swing.JRadioButton(); Sliderrows = new javax.swing.JSlider(); Rowstxt = new javax.swing.JTextField(); jRadioButton1 = new javax.swing.JRadioButton(); Slidercolumns = new javax.swing.JSlider(); Columnstxt = new javax.swing.JTextField(); Oksettings = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Settings"); setBackground(new java.awt.Color(102, 102, 102)); buttonGroup1.add(Rows); Rows.setText("Rows"); Rows.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { RowsMouseClicked(evt); } }); Sliderrows.setMajorTickSpacing(2); Sliderrows.setMaximum(99); Sliderrows.setMinimum(11); 2. Sliderrows.setMinorTickSpacing(2); Sliderrows.setValue(0); Sliderrows.setEnabled(false); Sliderrows.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { SliderrowsStateChanged(evt); } }); Rowstxt.setText("11"); Rowstxt.setEnabled(false); buttonGroup1.add(jRadioButton1); jRadioButton1.setText("Columns"); jRadioButton1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jRadioButton1MouseClicked(evt); } }); Slidercolumns.setMajorTickSpacing(2); Slidercolumns.setMaximum(99); Slidercolumns.setMinimum(11); Slidercolumns.setMinorTickSpacing(2); Slidercolumns.setValue(0); Slidercolumns.setEnabled(false); Slidercolumns.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { SlidercolumnsStateChanged(evt); } }); Columnstxt.setText("11"); Columnstxt.setEnabled(false); Oksettings.setText("Ok"); Oksettings.setToolTipText(""); Oksettings.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { OksettingsActionPerformed(evt); } }); jLabel1.setText("Settings"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSeparator1) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addComponent(Rows) .addGap(18, 18, 18) .addComponent(Sliderrows, 3. javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jRadioButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(Slidercolumns, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(Rowstxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Columnstxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addGap(102, 102, 102) .addComponent(jLabel1))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(Oksettings) .addGap(96, 96, 96)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(8, 8, 8) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(3, 3, 3) .addComponent(Rows)) .addComponent(Rowstxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Sliderrows, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jRadioButton1) .addComponent(Slidercolumns, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Columnstxt, 4. javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(Oksettings) .addContainerGap(16, Short.MAX_VALUE)) ); pack(); }// //GEN-END:initComponents private void OksettingsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OksettingsActionPerformed // TODO add your handling code here: Maze Open = new Maze(); Open.setVisible(true); Maze.Rowssize.setText(Rowstxt.getText()); Maze.Columnssize.setText(Columnstxt.getText()); this.setVisible(false); }//GEN-LAST:event_OksettingsActionPerformed private void SliderrowsStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_SliderrowsStateChanged // TODO add your handling code here: int x = Sliderrows.getValue(); if (x % 2 == 0) { x ++; } Sliderrows.setValue(x); Rowstxt.setText(Integer.toString(x)); }//GEN-LAST:event_SliderrowsStateChanged private void SlidercolumnsStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_SlidercolumnsStateChanged // TODO add your handling code here: int x = Slidercolumns.getValue(); if (x % 2 == 0) { x ++; } Slidercolumns.setValue(x); Columnstxt.setText(Integer.toString(x)); }//GEN-LAST:event_SlidercolumnsStateChanged private void RowsMouseClicked(java.awt.event.MouseEvent evt) {//GEN- FIRST:event_RowsMouseClicked // TODO add your handling code here: Sliderrows.setEnabled(true); Slidercolumns.setEnabled(false); }//GEN-LAST:event_RowsMouseClicked private void jRadioButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton1MouseClicked // TODO add your handling code here: Slidercolumns.setEnabled(true); Sliderrows.setEnabled(false); }//GEN-LAST:event_jRadioButton1MouseClicked /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ // 5. /* 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(Settings.class.getName()).log(java.util.loggi ng.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Settings.class.getName()).log(java.util.loggi ng.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Settings.class.getName()).log(java.util.loggi ng.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Settings.class.getName()).log(java.util.loggi ng.Level.SEVERE, null, ex); } // // /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Settings().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField Columnstxt; private javax.swing.JButton Oksettings; private javax.swing.JRadioButton Rows; private javax.swing.JTextField Rowstxt; private javax.swing.JSlider Slidercolumns; private javax.swing.JSlider Sliderrows; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JLabel jLabel1; private javax.swing.JRadioButton jRadioButton1; private javax.swing.JSeparator jSeparator1; // End of variables declaration//GEN-END:variables } } 6. /* 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(Settings.class.getName()).log(java.util.loggi ng.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Settings.class.getName()).log(java.util.loggi ng.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Settings.class.getName()).log(java.util.loggi ng.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Settings.class.getName()).log(java.util.loggi ng.Level.SEVERE, null, ex); } // // /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Settings().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField Columnstxt; private javax.swing.JButton Oksettings; private javax.swing.JRadioButton Rows; private javax.swing.JTextField Rowstxt; private javax.swing.JSlider Slidercolumns; private javax.swing.JSlider Sliderrows; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JLabel jLabel1; private javax.swing.JRadioButton jRadioButton1; private javax.swing.JSeparator jSeparator1; // End of variables declaration//GEN-END:variables } }