lunes, 23 de abril de 2007

uso "for"

/*
* UsoFor.java
*
* Created on 17 de abril de 2007, 07:25 PM
*/

/**
*
* @author ALUMNO
*/
public class UsoFor extends javax.swing.JFrame {

/** Creates new form UsoFor */
public UsoFor() {
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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane2 = new javax.swing.JTextPane();
jLabel2 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
jTextPane3 = new javax.swing.JTextPane();
jScrollPane4 = new javax.swing.JScrollPane();
jTextPane4 = new javax.swing.JTextPane();
jLabel3 = new javax.swing.JLabel();


setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Inicio");

jButton1.setText("Evalua");
jButton1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
jButton1ActionPerformed(evt);
}
});

jScrollPane1.setViewportView(jTextPane1);

jScrollPane2.setViewportView(jTextPane2);

jLabel2.setText("Paso");

jScrollPane3.setViewportView(jTextPane3);

jScrollPane4.setViewportView(jTextPane4);

jLabel3.setText("Nro Iteraciones");

org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(33, 33, 33)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel1)
.add(jLabel2))
.add(27, 27, 27)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(58, 58, 58)
.add(jButton1))
.add(layout.createSequentialGroup()

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING,
false)

..add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane2)

..add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE))
.add(36, 36, 36)
.add(jLabel3)
.add(15, 15, 15)
.add(jScrollPane4,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 72,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.add(layout.createSequentialGroup()
.add(154, 154, 154)
.add(jScrollPane3,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 145,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(31, Short.MAX_VALUE))
);
layout.setVerticalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(20, 20, 20)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jLabel1)
.add(jScrollPane1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jScrollPane4,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel3))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

..add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jScrollPane2,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel2))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jScrollPane3,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
.add(18, 18, 18)
.add(jButton1)
.add(38, 38, 38))
);
pack();
}//
//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent
evt)
{//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
int i, v, vi, paso, ni;
String str;
vi = Integer.parseInt(jTextPane1.getText());
paso = Integer.parseInt(jTextPane2.getText());
ni = Integer.parseInt(jTextPane4.getText());

str="";
for(i=1, v=vi; i <= ni; i++){
str = str + String.valueOf(v)+"\n";
v = v + paso;
}
jTextPane3.setText(str);

}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new UsoFor().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JTextPane jTextPane1;
private javax.swing.JTextPane jTextPane2;
private javax.swing.JTextPane jTextPane3;
private javax.swing.JTextPane jTextPane4;
// End of variables declaration//GEN-END:variables

}

No hay comentarios: