예제 #1
0
  /**
   * The action that happens when the Clear Button is pressed. All fields go to 0, empty of neutral
   * and re-enables things as needed.
   *
   * @param evt
   */
  private void clearButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_clearButtonActionPerformed
    weightValue.setValue(0);
    radiusValue.setValue(0);
    // heightValue.setValue(0);
    widthValue.setValue(0);
    Object_Group.clearSelection();
    Relationship_Group.clearSelection();

    // re-enable everything
    weightValue.setEnabled(true);
    radiusValue.setEnabled(true);
    // heightValue.setEnabled(true);
    widthValue.setEnabled(true);
  } // GEN-LAST:event_clearButtonActionPerformed
예제 #2
0
  /**
   * 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">//GEN-BEGIN:initComponents
  private void initComponents() {

    Object_Group = new javax.swing.ButtonGroup();
    Relationship_Group = new javax.swing.ButtonGroup();
    Object_Label = new javax.swing.JLabel();
    ballButton = new javax.swing.JRadioButton();
    boxButton = new javax.swing.JRadioButton();
    Weight_Label = new javax.swing.JLabel();
    Radius_Label = new javax.swing.JLabel();
    Width_Label = new javax.swing.JLabel();
    Relationship = new javax.swing.JLabel();
    insideRButton = new javax.swing.JRadioButton();
    insideUButton = new javax.swing.JRadioButton();
    topButton = new javax.swing.JRadioButton();
    behindButton = new javax.swing.JRadioButton();
    addButton = new javax.swing.JButton();
    clearButton = new javax.swing.JButton();
    cancelButton = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();
    weightValue = new javax.swing.JSlider();
    radiusValue = new javax.swing.JSlider();
    widthValue = new javax.swing.JSlider();
    weightLabelValue = new javax.swing.JLabel();
    radiusLabelValue = new javax.swing.JLabel();
    widthLabelValue = new javax.swing.JLabel();
    inFrontButton = new javax.swing.JRadioButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    Object_Label.setText("Object");

    Object_Group.add(ballButton);
    ballButton.setText("Ball");
    ballButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            ballButtonActionPerformed(evt);
          }
        });

    Object_Group.add(boxButton);
    boxButton.setText("Box");
    boxButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            boxButtonActionPerformed(evt);
          }
        });

    Weight_Label.setText("Weight");

    Radius_Label.setText("Radius");

    Width_Label.setText("Width");

    Relationship.setText("Relationship to Bus");

    Relationship_Group.add(insideRButton);
    insideRButton.setText("Inside (with a seatbelt)");
    insideRButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            insideRButtonActionPerformed(evt);
          }
        });

    Relationship_Group.add(insideUButton);
    insideUButton.setText("Inside (without a seatbelt)");

    Relationship_Group.add(topButton);
    topButton.setText("On Top");

    Relationship_Group.add(behindButton);
    behindButton.setText("Behind (Dragged)");

    addButton.setText("Add");
    addButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            addButtonActionPerformed(evt);
          }
        });

    clearButton.setText("Clear");
    clearButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            clearButtonActionPerformed(evt);
          }
        });

    cancelButton.setText("Cancel");
    cancelButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            cancelButtonActionPerformed(evt);
          }
        });

    jLabel2.setText("Object Attributes");

    weightValue.setMaximum(4);
    weightValue.setMinimum(1);
    weightValue.setSnapToTicks(true);
    weightValue.setValue(2);
    weightValue.addChangeListener(
        new javax.swing.event.ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent evt) {
            weightValueStateChanged(evt);
          }
        });

    radiusValue.setMaximum(4);
    radiusValue.setMinimum(1);
    radiusValue.setSnapToTicks(true);
    radiusValue.setValue(2);
    radiusValue.addChangeListener(
        new javax.swing.event.ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent evt) {
            radiusValueStateChanged(evt);
          }
        });

    widthValue.setMaximum(4);
    widthValue.setMinimum(1);
    widthValue.setSnapToTicks(true);
    widthValue.setValue(2);
    widthValue.addChangeListener(
        new javax.swing.event.ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent evt) {
            widthValueStateChanged(evt);
          }
        });

    weightLabelValue.setText("medium");

    radiusLabelValue.setText("medium");

    widthLabelValue.setText("medium");

    Relationship_Group.add(inFrontButton);
    inFrontButton.setText("In Front of");

    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)
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addComponent(Object_Label)
                                                    .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement
                                                            .RELATED))
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addGroup(
                                                        layout
                                                            .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment
                                                                    .LEADING)
                                                            .addComponent(ballButton)
                                                            .addComponent(boxButton))
                                                    .addGap(36, 36, 36)
                                                    .addGroup(
                                                        layout
                                                            .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment
                                                                    .LEADING)
                                                            .addGroup(
                                                                layout
                                                                    .createSequentialGroup()
                                                                    .addGroup(
                                                                        layout
                                                                            .createParallelGroup(
                                                                                javax.swing
                                                                                    .GroupLayout
                                                                                    .Alignment
                                                                                    .TRAILING)
                                                                            .addComponent(
                                                                                Weight_Label)
                                                                            .addComponent(
                                                                                Radius_Label)
                                                                            .addComponent(
                                                                                Width_Label))
                                                                    .addPreferredGap(
                                                                        javax.swing.LayoutStyle
                                                                            .ComponentPlacement
                                                                            .RELATED)
                                                                    .addGroup(
                                                                        layout
                                                                            .createParallelGroup(
                                                                                javax.swing
                                                                                    .GroupLayout
                                                                                    .Alignment
                                                                                    .LEADING)
                                                                            .addComponent(
                                                                                widthValue,
                                                                                0,
                                                                                0,
                                                                                Short.MAX_VALUE)
                                                                            .addGroup(
                                                                                layout
                                                                                    .createParallelGroup(
                                                                                        javax.swing
                                                                                            .GroupLayout
                                                                                            .Alignment
                                                                                            .LEADING,
                                                                                        false)
                                                                                    .addComponent(
                                                                                        radiusValue,
                                                                                        0,
                                                                                        0,
                                                                                        Short
                                                                                            .MAX_VALUE)
                                                                                    .addComponent(
                                                                                        weightValue,
                                                                                        javax.swing
                                                                                            .GroupLayout
                                                                                            .PREFERRED_SIZE,
                                                                                        142,
                                                                                        javax.swing
                                                                                            .GroupLayout
                                                                                            .PREFERRED_SIZE)))
                                                                    .addPreferredGap(
                                                                        javax.swing.LayoutStyle
                                                                            .ComponentPlacement
                                                                            .RELATED)
                                                                    .addGroup(
                                                                        layout
                                                                            .createParallelGroup(
                                                                                javax.swing
                                                                                    .GroupLayout
                                                                                    .Alignment
                                                                                    .LEADING)
                                                                            .addComponent(
                                                                                widthLabelValue)
                                                                            .addComponent(
                                                                                weightLabelValue)
                                                                            .addComponent(
                                                                                radiusLabelValue))
                                                                    .addPreferredGap(
                                                                        javax.swing.LayoutStyle
                                                                            .ComponentPlacement
                                                                            .RELATED))
                                                            .addComponent(jLabel2))))
                                    .addGap(62, 62, 62)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(Relationship)
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addGap(10, 10, 10)
                                                    .addGroup(
                                                        layout
                                                            .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment
                                                                    .LEADING)
                                                            .addComponent(behindButton)
                                                            .addComponent(inFrontButton)
                                                            .addComponent(insideUButton)
                                                            .addComponent(insideRButton)
                                                            .addComponent(topButton))))
                                    .addGap(90, 90, 90))
                            .addGroup(
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                layout
                                    .createSequentialGroup()
                                    .addComponent(addButton)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(clearButton)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(cancelButton)
                                    .addGap(193, 193, 193)))));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(Relationship)
                            .addComponent(Object_Label)
                            .addComponent(jLabel2))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(topButton)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(insideRButton)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(insideUButton)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(behindButton)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(inFrontButton))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addGap(6, 6, 6)
                                                    .addGroup(
                                                        layout
                                                            .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment
                                                                    .LEADING)
                                                            .addComponent(Weight_Label)
                                                            .addComponent(
                                                                weightValue,
                                                                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(Radius_Label)
                                                            .addComponent(
                                                                radiusValue,
                                                                javax.swing.GroupLayout
                                                                    .PREFERRED_SIZE,
                                                                javax.swing.GroupLayout
                                                                    .DEFAULT_SIZE,
                                                                javax.swing.GroupLayout
                                                                    .PREFERRED_SIZE)))
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addComponent(weightLabelValue)
                                                    .addGap(18, 18, 18)
                                                    .addComponent(radiusLabelValue)))
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(Width_Label)
                                            .addComponent(widthLabelValue)
                                            .addComponent(
                                                widthValue,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(ballButton)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(boxButton)))
                    .addGap(18, 18, 18)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(addButton)
                            .addComponent(clearButton)
                            .addComponent(cancelButton))
                    .addGap(21, 21, 21)));

    pack();
  } // </editor-fold>//GEN-END:initComponents