Wiecie jak zrobić, żeby po kliknięciu przycisku zmieniał się indeks w tablicy, bo chciałem zrobić przeładowywanie elementów z tablicy do jlabel i jcheckbox?
public class klasa extends javax.swing.JFrame
{
/**
* Creates new form klasa
*/
int n=0;
public klasa()
{
initComponents();
FileInputStream czytajplik = null;
try
{
czytajplik = new FileInputStream("pytania.txt");
}
catch (FileNotFoundException ex)
{
Logger.getLogger(klasa.class.getName()).log(Level.SEVERE, null, ex);
}
BufferedReader br = new BufferedReader(new InputStreamReader(czytajplik));
String[] tab = new String[100];
for (int i = 0; i < tab.length; i++)
{
try
{
tab[i] = br.readLine();
}
catch (IOException ex)
{
Logger.getLogger(klasa.class.getName()).log(Level.SEVERE, null, ex);
}
}
try
{
czytajplik.close();
}
catch (IOException ex)
{
Logger.getLogger(klasa.class.getName()).log(Level.SEVERE, null, ex);
}
for (int i = 0; i < tab.length; i++)
{
int n=0;
if ((tab[n]) != null)
jLabel1.setText(tab[n]);
jCheckBox1.setText(tab[n+1]);
jCheckBox2.setText(tab[n+2]);
jCheckBox3.setText(tab[n+3]);
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
n=n+3;
jLabel1.setText(n+"");
}
/**
* @param args the command line arguments
*/
public static void main(String args[])
{
/*
* Set the Nimbus look and feel
*/
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
new klasa().setVisible(true);
}
});
}