Salve a tutti,

in pratica io ho una tabella, con 4 attributi
1 - PLUGIN
2 - AUTORE
3 - DIPENDENZE
4 - INFO

nella quarta cella di ogni riga (INFO) ci dovrebbe essere un JButton il quale cliccato mi ritorna un semplice messaggio di informazione sulla versione e la descriozne del plugin realizzato. Il problema è quindi quello di inserire, per ogni plugin (plugins che si trovano nella cartella plugins della HOME, come di seguito nel codice riportato), un bottone che mi ritorna le info presenti nel nel file plugin.properties presente all'interno del jar della cartella plugins.

Questo è il mio codice:

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Properties;
import java.util.ResourceBundle;


import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;

/**
* Window management plugins
* @author Alessandro Sdelci
*/
@SuppressWarnings("serial")
public class PluginManager implements ActionListener
{
JarSelected jarClass;
JFrame f;
//JFrame warning = new JFrame();
Object cols[];

DefaultTableModel model;

public File[] jarList;

JTable table;

ResourceBundle labels;

public int jarIndexSelected;

public File jarSelected;

public void createGUI() throws IOException
{
f = new JFrame();
model = new DefaultTableModel(){ public boolean isCellEditable(int row, int col) { return false; } };

table = new JTable(model);

table.setSelectionMode(ListSelectionModel.SINGLE_S ELECTION);


if (true) { // true by default
ListSelectionModel rowSM = table.getSelectionModel();
rowSM.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
/**
* Ignore extra messages.
*/
if (e.getValueIsAdjusting()) return;

ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
System.out.println("No rows are selected.");
} else {
int selectedRow = lsm.getMinSelectionIndex();
jarIndexSelected = selectedRow;
System.out.println("Row " + selectedRow
+ " is now selected.");
}
}
});
}

File directoryPlugins=new java.io.File(System.getProperty("user.home"), "plugins");
File fs[]=directoryPlugins.listFiles();

f.setTitle("PLUGIN MANAGER");
Container content = f.getContentPane();
JTabbedPane tpane = new JTabbedPane();
f.add(tpane);
content.add(tpane, BorderLayout.CENTER);

model.addColumn("Name");
model.addColumn("Author");
model.addColumn("Dependencies");
model.addColumn("Read more...");


table.getColumnModel().getColumn(0).setPreferredWi dth(100);
table.getColumnModel().getColumn(1).setPreferredWi dth(100);
table.getColumnModel().getColumn(2).setPreferredWi dth(500);
table.getColumnModel().getColumn(3).setPreferredWi dth(150);


if(fs.length==0)
{
/**
* System.out.println("Non vi è nessun JAR");
* JLabel label = new JLabel("Non vi è nessun JAR");
* content.add(label, BorderLayout.CENTER);
*/
JOptionPane.showMessageDialog(null, "Nella directory selezionata non è presente nessun plugin");
return;
}else
{
int i = 0;
jarList = new File[fs.length];
cols = new Object[4];
for(File file:fs)
{
jarList[i] = file;
i++;
try
{
/**
* Uniform Resource Locator (URl). A resource can be something
* as simple as a file or a directory
*/
URL jarFileUrl=new URL("jar", "", file.toURI().toURL().toString()+"!/");
/**
* This class loader (URLClassLoader) is used to load
* classes and resources from a search path of URLs referring
* to both JAR files and directories. Any URL that ends
* with a '/' is assumed to refer to a directory.
* Otherwise, the URL is assumed to refer to a JAR file
* which will be opened as needed
*/
URLClassLoader ucl=new URLClassLoader(new URL[] {jarFileUrl});

/**
* getResourceAsStream(String)
* Returns an input stream for reading the specified resource
*/
InputStream is=ucl.getResourceAsStream("plugin.properties");

/**
* Then implemented the plugin .jar must include file plugin.properties,
* within which must be valued attribute-class name
*/
if(is==null)
{
JOptionPane.showMessageDialog(null, "Il plugin "+file.getName()+" non ha il file plugin.properties /n quindi non puo' essere caricato!!!");
//System.out.println("Il plugin "+f+" non ha il file plugin.properties /n quindi non puo' essere caricato!!!");
continue;
}

final Properties p=new Properties();
p.load(is);
is.close();

if(!p.containsKey("class-name"))
{
JOptionPane.showMessageDialog(null, "Il plugin "+file.getName()+" non ha valorizzato l'attributo class-name");
//System.out.println("Il plugin "+file.getName()+" non ha l'attributo class-name");
continue;
}

if(!p.containsKey("Plugin") && p.getProperty("Plugin")==null)
{

cols[0] = "Attributo non presente o non valorizzato";
}else
{
cols[0] = p.getProperty("Plugin");
}

if(!p.containsKey("Autore") && p.getProperty("Autore")==null)
{

cols[1] = "Attributo non presente o non valorizzato";
}else
{
cols[1] = p.getProperty("Autore");
}

if(!p.containsKey("Dependencies") && p.getProperty("Dependencies")==null)
{

cols[2] = "Attributo non presente o non valorizzato";
}else
{
cols[2] = p.getProperty("Dependencies");
}


if(!p.containsKey("Info") && p.getProperty("Info")==null)
{

cols[3] = "Attributo non presente o non valorizzato";
}else
{
/**JButton info = new JButton("Info");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
JOptionPane.showMessageDialog(null, p.getProperty("Descrizione"),
"Description of the plugin", JOptionPane.INFORMATION_MESSAGE);
}
});*/

cols[3] = p.getProperty("Status");
}

model.addRow(cols);
} catch(Exception ex)
{
ex.printStackTrace();
}

}
}

/**JList list =null;
DefaultListModel listModel = null;
for (File file_plugin:fs)
{
listModel.addElement(file_plugin.getName());
}*/

//table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setColumnSelectionAllowed(true);
//table.createDefaultColumnsFromModel();
//table.setTableHeader(null);

//list = new JList(listModel);
JScrollPane sp = new JScrollPane(table);
//JScrollPane sp1 = new JScrollPane(list);
//table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
tpane.addTab("Configuration", null, sp, null);
//tpane.addTab("Active Plugins", null, sp1, null);

/**
* Enter buttons
*/
JPanel panel = new JPanel();
panel.setAlignmentX(BoxLayout.Y_AXIS);
JButton active = new JButton("Select");
active.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
PluginManager.this.jarSelected = PluginManager.this.jarList[PluginManager.this.jarIndexSelected];
PluginManager.this.jarClass.setJarSelected(PluginM anager.this.jarSelected);
}
});

JButton disable = new JButton("Uncheck");
disable.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
PluginManager.this.jarSelected = null;
PluginManager.this.jarClass.setJarSelected(PluginM anager.this.jarSelected);
}
});

JButton ok = new JButton("Confirm");
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
f.dispose();
}
});

panel.add(ok);
panel.add(active);
panel.add(disable);
content.add(panel, BorderLayout.SOUTH);

f.pack();
f.setSize(850, 350);
f.setLocation(130, 130);
f.setVisible(true);

/*for(int j=0; j<this.jarList.length;j++)
{
System.out.println("JAR "+this.jarList[j]);
}*/
}

@Override
public void actionPerformed(ActionEvent arg0)
{
try
{
this.createGUI();
} catch (IOException e) {

e.printStackTrace();
}
}

public void setJarSelectedClass(JarSelected jar)
{
this.jarClass = jar;
}


}

Il problema è in questa parte, quando provo ad inserire, per ogni riga, il bottone:

if(!p.containsKey("Info") && p.getProperty("Info")==null)
{

cols[3] = "Attributo non presente o non valorizzato";
}else
{
/**JButton info = new JButton("Info");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
JOptionPane.showMessageDialog(null, p.getProperty("Descrizione"),
"Description of the plugin", JOptionPane.INFORMATION_MESSAGE);
}
});*/

cols[3] = p.getProperty("Status");
}

GRAZIE IN ANTICIPO PER I SUGGERIMENTI!!!!!