For the last couple of days I’ve been trying to use a button to show/hide some of the components on the screen of my program node UI, and i cant figure out how to do it. a simplified version of my ProgramNodeView code is as follows:
private void buildUI(JPanel panel, provider)
{
panel.add(Component1())
panel.add(Component2())
panel.add(Button())
}
private JButton Button()
{
JButton button = new JButton("hide things");
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e)
{
some code;
}
});
return button;
}
my question is what can i add to the button’s code to hide the components that i add in the buildUI() method. I tried adding a bit of logic that set a boolean variable to be true when the hide button was pressed, then a couple of if statements in buildUI() to decide if the components needed to be added.
The problem is buildUI() is only called once, so I tried calling buildUI again in the buttons action listener, but I cant get the arguments correct.
Can anyone offer any advice?