Skip to content
Snippets Groups Projects
Commit c43ae92c authored by Nils Vreman's avatar Nils Vreman
Browse files

Fixed problem with text disappearing when list option pressed

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