Help me with incrementation of i on jTextField...
my problem is, i have some text fields in a jframe form and i like to hide those text fields with a cicle for...
i used this code but didn't work.. can anyone help me... thanks in advance...
-
public ins_man(int b) {
initComponents();
int i,j;
for(i=1;i<b;i++)
{
jTextField[ i ].setVisible(false);
for(j=b+1;j<21;j++)
{
jTextField[ j ].setVisible(false);
}
}
}>
[462 byte] By [
Kangaa] at [2007-11-27 4:35:37]

I'm not sure what you're actually trying to accomplish. Your code does nothing but set the textfield's visibility to false, but it's looping over them multiple times. Are you trying to set the textfields from 0 to b to visible, and from b+1 to 21 to invisible? Or something like that? If you post code in the future, please wrap it in [code][/code] tags so it's more readable.
public ins_man(int b) {
initComponents();
int i,j;
for(i=1;i<b;i++)
{
jTextField[ i ].setVisible(false);
for(j=b+1;j<21;j++)
{
jTextField[ j ].setVisible(false);
}
}
}
>
When you have compiler errors, post the complete stack trace along with the code, and point out which line of the code the error occurs on. I don't see anything wrong with the code you posted.
give me this error...
D:\mdis\src\ins_man.java:23: cannot find symbol
symbol : variable jTextField
location: class ins_man
jTextField[i].setVisible(false);
1 error
BUILD FAILED (total time: 1 second)
i cant found the error pleasecan you help me thanks
import javax.swing.JPanel;
/*
* ins_man.java
*
* Created on 16 de Maio de 2007, 11:47
*/
/**
*
* @author i040274
*/
public class ins_man extends javax.swing.JFrame {
/**
* Creates new form ins_man
*/
public ins_man(int b) {
initComponents();
int i,j;
String temp2=("jTextField"+1),temp=(""+b+"");
for(i=1;i<b;i++)
{
TextField[ i ].setVisible(false);
for(j=b+1;j<21;j++)
{
jTextField[ j ].setVisible(false);
}
}
this.jTextField441.setText(temp);
}
public ins_man() {
initComponents();
}
//generated code
private void initComponents() {}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ins_man().setVisible(true);
}
});
}
// Variables declaration - do not modify
{..here goes the declaration of other variables...}
>