From 0fb5bc2ae7e64efca713d75e48b528b5d693195e Mon Sep 17 00:00:00 2001 From: Holt59 Date: Mon, 5 Mar 2018 22:01:58 +0100 Subject: [PATCH] Improve solution panel. --- src/main/org/insa/graphics/SolutionPanel.java | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main/org/insa/graphics/SolutionPanel.java b/src/main/org/insa/graphics/SolutionPanel.java index 5c81e47..7384e3c 100644 --- a/src/main/org/insa/graphics/SolutionPanel.java +++ b/src/main/org/insa/graphics/SolutionPanel.java @@ -16,8 +16,6 @@ import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.JTextArea; -import javax.swing.UIManager; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; @@ -105,12 +103,14 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap if (solution.isFeasible()) { Method[] methods = this.solution.getClass().getDeclaredMethods(); for (Method method: methods) { - if (method.getReturnType().equals(Path.class) && method.getParameterCount() == 0) { + if (method.getReturnType().equals(Path.class) + && method.getParameterCount() == 0) { try { Path path = (Path) method.invoke(this.solution); overlays.add(drawing.drawPath(path)); } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + catch (IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { // This has been check before, so should never happen... e.printStackTrace(); } @@ -137,8 +137,7 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap // Solution selector private final JComboBox solutionSelect; - // Map solution -> panel - private final JTextArea informationPanel; + private final JLabel informationPanel; // Current bundle private SolutionBundle currentBundle = null; @@ -154,16 +153,11 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap solutionSelect.setAlignmentX(Component.LEFT_ALIGNMENT); add(solutionSelect); - informationPanel = new JTextArea(); - informationPanel.setWrapStyleWord(true); - informationPanel.setLineWrap(true); + informationPanel = new JLabel(); informationPanel.setOpaque(true); informationPanel.setFocusable(false); - informationPanel.setEditable(false); - informationPanel.setBackground(UIManager.getColor("Label.background")); - informationPanel.setFont(UIManager.getFont("Label.font")); - informationPanel.setBorder(UIManager.getBorder("Label.border")); - informationPanel.setAlignmentX(JLabel.LEFT_ALIGNMENT); + // informationPanel.setAlignmentX(JLabel.LEFT_ALIGNMENT); + informationPanel.setHorizontalAlignment(JLabel.LEFT); add(Box.createVerticalStrut(8)); add(informationPanel); @@ -244,6 +238,8 @@ public class SolutionPanel extends JPanel implements DrawingChangeListener, Grap protected void updateInformationLabel(SolutionBundle bundle) { informationPanel.setText(bundle.getSolution().toString()); + revalidate(); + repaint(); } @Override