public class UserInterface {
OpenFile of = new OpenFile();
JFrame jf = new JFrame("File Manager");
JButton jb1 = new JButton("Open File");
JLabel jl1 = new JLabel("Recommendations appear here");
JLabel jl2 = new JLabel();
JList<String> list;
public void build() {
DefaultListModel<String> str = new DefaultListModel<String>();
for (int i = 0; i < of.f.length; i++) {
str.addElement(of.f[i].getAbsolutePath());
}
list = new JList<String>(str);
Border b = BorderFactory.createLineBorder(Color.black, 2);
Font f = new Font("Arial", Font.BOLD, 20);
jb1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
of.OpenFileMethod(list.getSelectedValue());
}
});
jl1.setFont(f);
jl1.setBorder(b);
list.setFont(f);
jf.add(jl1).setBounds(30, 100, 300, 200);
jf.add(list).setBounds(400, 100, 300, 300);
jf.add(jb1).setBounds(250, 300, 100, 50);
jf.setLayout(null);
jf.setSize(800, 800);
jf.setVisible(true);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
for (int i = 0; i < 100; i++) {
jl1.setText("Loading.");
jl1.setText("Loading...");
}
}
}
Problem in the for loop, only setting last "loading..." text to JLabel I want it to get in the loop and print it 100 times. May be the loop gets over before the launch of the swing application. any solution for this?