I have a question about implementing a Swing control which uses a custom class as one of its properties. My goal is to use this control within the netbeans IDE and configure it in design-time like any other component. I already implemented a custom property editor for my ConnectionInfo object which works fine.
However - when I configure my IntLEDs ConnectionInfo property in Netbeans and save it, I can see, in the generated code by Netbeans, that it had troubles to init my ConnectionInfo class.
This is actually what the Netbeans IDE generated:
intLED1.setConnection(???);
So I guess that Netbeans doesn't know how to instantiate my ConnectionInfo class.
But how to tell Netbeans how to do it? :)
This code is basicly a stripped version of my component
public class IntLED extends JPanel {
private ConnectionInfo connection = new ConnectionInfo("", 11159, "", "", Variable.VARIABLE_TYPE.INT);
public IntLED() {
initComponents();
PropertyEditorManager.registerEditor(ConnectionInfo.class, PviCpuPropertyEditor.class);
}
public ConnectionInfo getConnection() {
return connection;
}
public void setConnection(ConnectionInfo connection) {
this.connection = connection;
}
}
Here the ConnectionInfo code. Just some members and Getters/Setters.
public class ConnectionInfo {
private String pviHost = "";
private int pviPort = 11159;
private String pviTask = "";
private String pviVarname = "";
private Variable.VARIABLE_TYPE pviType;
public ConnectionInfo() {
}
public ConnectionInfo(String pviHost, int pviPort, String pviTask, String pviVarname, Variable.VARIABLE_TYPE type) {
this.pviHost = pviHost;
this.pviPort = pviPort;
this.pviTask = pviTask;
this.pviVarname = pviVarname;
this.pviType = type;
}
public String getPviHost() {
return pviHost;
}
public void setPviHost(String pviHost) {
this.pviHost = pviHost;
}
public int getPviPort() {
return pviPort;
}
public void setPviPort(int pviPort) {
this.pviPort = pviPort;
}
public String getPviTask() {
return pviTask;
}
public void setPviTask(String pviTask) {
this.pviTask = pviTask;
}
public String getPviVarname() {
return pviVarname;
}
public void setPviVarname(String pviVarname) {
this.pviVarname = pviVarname;
}
public Variable.VARIABLE_TYPE getPviType() {
return pviType;
}
public void setPviVarname(Variable.VARIABLE_TYPE pviType) {
this.pviType = pviType;
}
}
I also tried to put the members of the ConnectionInfo-Class directly into my IntLED-Class which works fine! But I really need to let the user configure those Members directly in one editor since the editor also provides a tester to test those settings et cetera.
I hope someone can point me to the right direction :)
Thank you very much in advance!