I'm trying to create a custom swing that contains a JTextField and a JButton.
I have a class that represents the UI(BasicJPopupUI.java), another class that represents the Model(DefaultJPopupModel.java) and a class for the main swing(JPopup.java).
The problem is that the text field and the button are frozen at run time. I can't write nothing in the text box and if I click the button nothing heapens even if I have a event connected to the button.
Thank you.
This is the code(partial):
1) main class
2) UI classCode:public class JPopup extends JComponent {
private static final String uiClassID = "JPopupUI";
public JPopup() {
this.updateUI();
}
public void updateUI() {
if (UIManager.get(getUIClassID()) != null) {
setUI((JPopupUI) UIManager.getUI(this));
} else {
setUI(new BasicJPopupUI());
}
}
@Override
public String getUIClassID() {
return uiClassID;
}
}
Code:public class BasicJPopupUI extends JPopupUI {
protected JTextField textfield;
protected JButton button;
public void installUI(JComponent c) {
this.jpopup = (JPopup) c;
.....
this.button.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
System.out.println("Executed");
}
});
}
}

