How do I copy a Swing component, while keeping its properties? I've tried this by using the clone() method, but it fails with an error:
clone()has protected access in java.lang.Object
How should I copy a Swing component using code?
This is my code currently:
 public void copy_component() throws CloneNotSupportedException {
    Component[] components = design_panel.getComponents();
    for (int i = 0; i < components.length; i++) {
        boolean enable = components[i].isEnabled();
        if (enable == true) {
            JButton button = components[i].clone();
            design_panel.add(button);
        }
    }
}
 
    