Following the comment. If cant find a good source location for it, would like a properties panel list that can support STRING, NUMBER, FLOAT, BOOLEAN, DATE and PICLIST. It would require a JTable and two columns, the second column is editable to update the value for that particular type
Abe
Hi,
I've implemented once a simple property table. Maybe you find it useful (it's open source):
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JPropertyTable.html
Homepage:
http://www.softsmithy.org
Download:
http://sourceforge.net/project/showfiles.php?group_id=64833
Source:
http://sourceforge.net/svn/?group_id=64833
http://softsmithy.svn.sourceforge.net/viewvc/softsmithy/trunk/lib/src/org/softsmithy/lib/
API:
http://softsmithy.sourceforge.net/lib/docs/api/index.html
If you have questions just ask me!
-Puce
Have a look at the following sample:
/*
* MyBean.java
*
*/
package propertytabletest;
import java.awt.Color;
import java.awt.Font;
import java.util.Locale;
import org.softsmithy.lib.swing.FontCellEditor;
public class MyBean {
/** Creates a new instance of MyBean */
public MyBean() {
}
/**
* Holds value of property myStringProperty.
*/
private String myStringProperty = "test";
/**
* Getter for property myStringProperty.
* @return Value of property myStringProperty.
*/
public String getMyStringProperty() {
return this.myStringProperty;
}
/**
* Setter for property myStringProperty.
* @param myStringProperty New value of property myStringProperty.
*/
public void setMyStringProperty(String myStringProperty) {
this.myStringProperty = myStringProperty;
}
/**
* Holds value of property myIntProperty.
*/
private int myIntProperty = 5;
/**
* Getter for property myIntProperty.
* @return Value of property myIntProperty.
*/
public int getMyIntProperty() {
return this.myIntProperty;
}
/**
* Setter for property myIntProperty.
* @param myIntProperty New value of property myIntProperty.
*/
public void setMyIntProperty(int myIntProperty) {
this.myIntProperty = myIntProperty;
}
/**
* Holds value of property myDoubleProperty.
*/
private double myDoubleProperty = 1.1;
/**
* Getter for property myDoubleProperty.
* @return Value of property myDoubleProperty.
*/
public double getMyDoubleProperty() {
return this.myDoubleProperty;
}
/**
* Setter for property myDoubleProperty.
* @param myDoubleProperty New value of property myDoubleProperty.
*/
public void setMyDoubleProperty(double myDoubleProperty) {
this.myDoubleProperty = myDoubleProperty;
}
/**
* Holds value of property myFontProperty.
*/
private Font myFontProperty = new Font("Arial", Font.PLAIN, 10);
/**
* Getter for property myFontProperty.
* @return Value of property myFontProperty.
*/
public Font getMyFontProperty() {
return this.myFontProperty;
}
/**
* Setter for property myFontProperty.
* @param myFontProperty New value of property myFontProperty.
*/
public void setMyFontProperty(Font myFontProperty) {
this.myFontProperty = myFontProperty;
}
/**
* Holds value of property myColorProperty.
*/
private Color myColorProperty = Color.RED;
/**
* Getter for property myColorProperty.
* @return Value of property myColorProperty.
*/
public Color getMyColorProperty() {
return this.myColorProperty;
}
/**
* Setter for property myColorProperty.
* @param myColorProperty New value of property myColorProperty.
*/
public void setMyColorProperty(Color myColorProperty) {
this.myColorProperty = myColorProperty;
}
@Override
public String toString() {;
return getMyStringProperty();
}
}
/*
* PropertyTableTestFrame.java
*
*/
package propertytabletest;
import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import javax.crypto.NullCipher;
import javax.swing.DefaultComboBoxModel;
import org.softsmithy.lib.swing.table.PropertyTableModel;
public class PropertyTableTestFrame extends javax.swing.JFrame {
private final MyBean[] myBeans = new MyBean[5];
private PropertyTableModel propertyTableModel;
/** Creates new form PropertyTableTestFrame */
public PropertyTableTestFrame() throws IntrospectionException {
initComponents();
for (int i=0; i<myBeans.length; i++){
myBeans[i] = new MyBean();
myBeans[i].setMyStringProperty("MyBean " + (i + 1));
}
myBeanComboBox.setModel(new DefaultComboBoxModel(myBeans));
propertyTableModel = new PropertyTableModel(myBeans[0], null, Locale.US);
jPropertyTable.setPropertyTableModel(propertyTableModel);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// ><editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
myBeanComboBox = new javax.swing.JComboBox();
jScrollPane1 = new javax.swing.JScrollPane();
jPropertyTable = new org.softsmithy.lib.swing.JPropertyTable();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
myBeanComboBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
myBeanComboBoxItemStateChanged(evt);
}
});
getContentPane().add(myBeanComboBox, java.awt.BorderLayout.NORTH);
jScrollPane1.setViewportView(jPropertyTable);
getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
pack();
}// </editor-fold>
private void myBeanComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {
propertyTableModel.stopListening();
try {
propertyTableModel = new PropertyTableModel(evt.getItem(), null, Locale.US);
jPropertyTable.setPropertyTableModel(propertyTableModel);
} catch (IntrospectionException ex) {
ex.printStackTrace();
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
new PropertyTableTestFrame().setVisible(true);
} catch (IntrospectionException ex) {
ex.printStackTrace();
}
}
});
}
// Variables declaration - do not modify
private org.softsmithy.lib.swing.JPropertyTable jPropertyTable;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JComboBox myBeanComboBox;
// End of variables declaration
}
To exclude properties (eg. the read-only 'class' property) either specify the property as hidden in a resource bundle or provide the list of properties, which should be displayed to the constructor of the PropertyTableModel.
-Puce