/*
* AddMultipleRowColDialog.java
*
* Created on June 30, 2008, 9:54 AM
*/
package org.statcato.dialogs.edit;
import org.statcato.*;
/**
* A dialog that allows the user to add a number of rows and columns
* to the current Datasheet.
*
* @author Margaret Yau
* @version %I%, %G%
* @since 1.0
*/
public class AddMultipleRowColDialog extends StatcatoDialog {
/** Creates new form AddMultipleRowColDialog */
public AddMultipleRowColDialog(java.awt.Frame parent, boolean modal,
Statcato app) {
super(parent, modal);
this.app = app;
this.ParentSpreadsheet = app.getSpreadsheet();
initComponents();
getRootPane().setDefaultButton(OKButton);
setHelpFile("edit-menu");
name = "Add Multiple Rows and/or Columns";
description = "For adding multiple rows and/or columns to the current datasheet.";
helpStrings.add("Enter the number of rows and columns to be added.");
}
/** 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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
rowsTextField = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
colsTextField = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
OKButton = new javax.swing.JButton();
CancelButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Add Multiple Rows and/or Columns");
jLabel1.setText("Add...");
rowsTextField.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
rowsTextField.setText("0");
jLabel2.setText("rows");
colsTextField.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
colsTextField.setText("0");
jLabel3.setText("columns");
OKButton.setText("OK");
OKButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
OKButtonActionPerformed(evt);
}
});
CancelButton.setText("Cancel");
CancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CancelButtonActionPerformed(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()
.addGap(43, 43, 43)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(rowsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(colsTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(CancelButton)
.addComponent(jLabel3))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addContainerGap(210, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(32, Short.MAX_VALUE)
.addComponent(OKButton)
.addGap(135, 135, 135))
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {CancelButton, OKButton});
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {colsTextField, rowsTextField});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(rowsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(colsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(OKButton)
.addComponent(CancelButton))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// //GEN-END:initComponents
private void OKButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OKButtonActionPerformed
try {
int rows = Integer.parseInt(rowsTextField.getText());
int cols = Integer.parseInt(colsTextField.getText());
if (rows < 0 || cols < 0)
throw new NumberFormatException();
for (int i = 0; i < rows; ++i) {
ParentSpreadsheet.insertRow();
}
for (int i = 0; i < cols; ++i) {
ParentSpreadsheet.insertColumn();
}
}
catch (NumberFormatException e) {
app.showErrorDialog("Enter nonnegative integers for " +
"the number rows and columns.");
return;
}
dispose();
}//GEN-LAST:event_OKButtonActionPerformed
private void CancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelButtonActionPerformed
dispose();
}//GEN-LAST:event_CancelButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton CancelButton;
private javax.swing.JButton OKButton;
private javax.swing.JTextField colsTextField;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JTextField rowsTextField;
// End of variables declaration//GEN-END:variables
}
Ads help maintain this website.