I'm removing everything, but it's doubling?
Hello,
For some reason when I use the particualr block of code below it will work the first time, but when called again with RemComps as true, it will work almost the way I want it to, but instead of the one set of buttons it has 2 (or the number of times it is called).
public void renewFrame(config config, boolean RemComps){
if(RemComps){
this.removeAll();
}
config.bg = new Color(config.bgcolor[0],config.bgcolor[1],config.bgcolor[2]);
this.header.setFont(new Font("Serif",Font.BOLD,46));
this.header.setBorder(BorderFactory.createMatteBorder(0,5,0,0,config.bg));
add(this.header, BorderLayout.NORTH);
this.buttonPane.setBackground(config.bg);
this.buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.PAGE_AXIS));
this.buttonPane.setBorder(BorderFactory.createMatteBorder(0,5,0,5,config.bg));
add(this.buttonPane, BorderLayout.WEST);
for(int i=0;i<config.permissions.length;i++){
if(config.permissions[i]){
this.actionButton = new JButton(this.perms[i]);
this.actionButton.setMinimumSize(new Dimension(220,30));
this.actionButton.setMaximumSize(new Dimension(220,30));
this.actionButton.setName(this.perms[i]);
JLabel spacer = new JLabel(" ");
spacer.setMinimumSize(new Dimension(0,1));
spacer.setFont(new Font("Serif",Font.PLAIN,1));
this.buttonPane.add(spacer);
this.buttonPane.add(this.actionButton);
this.actionButton.addActionListener(this);
}
}
this.contentPane.setBackground(config.bg);
this.contentPane.setLayout(new BorderLayout());
add(this.contentPane, BorderLayout.CENTER);
this.contentShow.setText("<html><body style='background:rgb("+launcher.config.bgcolor[0]+","+launcher.config.bgcolor[1]+","+launcher.config.bgcolor[2]+")'><center><div style='height:90px;'> </div><h2>Welcome "+launcher.config.username+"!</h2><h3>Your login was successful!</h3></center></body></html>");
this.contentShow.setBorder(null);
this.contentPane.add(this.contentShow);
}
config is a class of variables
contentShow is a JLabel
contentPane and buttonPane are JPanels
header is a JLabel
permissions is a boolean array
perms is a String array of button names
Any help would be appreciated!
(What I want: (link) What happens after it is recalled: (link) )
turt2live
Junior Poster in Training
85 posts since Jan 2011
Reputation Points: 15
Solved Threads: 3
mKorbel
Veteran Poster
1,141 posts since Feb 2011
Reputation Points: 480
Solved Threads: 224
Sadly, still doing the same thing.
turt2live
Junior Poster in Training
85 posts since Jan 2011
Reputation Points: 15
Solved Threads: 3
be sure that works, its empty discusion because you didn't show any usage of
mKorbel
Veteran Poster
1,141 posts since Feb 2011
Reputation Points: 480
Solved Threads: 224
I managed to figure something out, more complicated than I was expecting, but it works.
My code essentially closes the frame and re-opens it, re-drawing everything. It doesn't 100% close it though, it just wipes everything off and restarts every time I need an update.
turt2live
Junior Poster in Training
85 posts since Jan 2011
Reputation Points: 15
Solved Threads: 3