What I’m having problems with is that I have a list of 10 files in a JList. On a JButton, I have “attached file(s) 0.” What I’m trying to achieve is when a user clicks on a file in the JList, the variable fileCount (represents the ‘0’) will increment. Here is the code:
@Override
public void mouseClicked(MouseEvent arg0) {
int idx = list_fileListing.getSelectedIndex();
String eFiles[] = ig.getListOfFiles();
if(idx == list_fileListing.getSelectedIndex()){
fileCount++;
}
}
Basically, if a file is selected, increment fileCount. Any suggestions as to how to accomplish this?
The
JButtonclass has asetText()method like many of the other Swing component classes. You can use this method to overwrite the text that is currently on theJButton.ex:
hope this helps.