Commit c43ae92c authored by Nils Vreman's avatar Nils Vreman
Browse files

Fixed problem with text disappearing when list option pressed

parent 91a440f6
......@@ -18,7 +18,7 @@ public class HelpMenuPane extends JFrame {
tabbedPane.addTab("Schedule", new ScheduleTab());
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
tabbedPane.setPreferredSize(new Dimension(400, 400));
tabbedPane.setPreferredSize(new Dimension(500, 400));
add(CENTER, tabbedPane);
......
......@@ -5,16 +5,17 @@ public class ScheduleTab extends TabPanel {
private static final String[] listOptions = new String[] {
"Schedule",
"Solution",
"Checking Solution",
"Clearing Cells",
"Clearing Strategy"};
"Check Solution",
"Clear Cells",
"Clear Strategy"};
private static final String[] helpTexts = new String[] {
"Schedule",
"Solution",
"Checking Solution",
"Clearing Cells",
"Clearing Strategy"};
"Check Solution",
"Clear Cells",
"Clear Strategy"};
public ScheduleTab() {
super(listOptions, helpTexts);
......
......@@ -3,20 +3,23 @@ package gui.menu.help;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Map;
import java.util.HashMap;
public abstract class TabPanel extends JPanel implements EventListener {
private final String[] listOptions;
private OptionList list;
private Map<String, JTextField> helpTexts = new HashMap<>();
public TabPanel(String[] listOptions, String[] fieldTexts) {
super(new BorderLayout());
this.listOptions = listOptions;
OptionList list = new OptionList(listOptions);
list = new OptionList(listOptions);
list.addListener(this);
list.setPreferredSize(new Dimension(120, 400));
for (int i = 0; i < listOptions.length; i++) {
JTextField htf = new HelpTextField(fieldTexts[i]);
......@@ -28,10 +31,14 @@ public abstract class TabPanel extends JPanel implements EventListener {
}
public void update(String tab) {
removeAll();
add(BorderLayout.WEST, list);
if (helpTexts.containsKey(tab)) {
add(BorderLayout.CENTER, helpTexts.get(tab));
revalidate();
repaint();
}
revalidate();
repaint();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment