Change border color of PathPanel.

This commit is contained in:
Holt59 2018-03-05 22:04:02 +01:00
parent 0fb5bc2ae7
commit 426867a302

View File

@ -107,7 +107,8 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
public PathPanel(Path path) { public PathPanel(Path path) {
super(); super();
setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.GRAY), setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY),
new EmptyBorder(5, 0, 5, 0))); new EmptyBorder(5, 0, 5, 0)));
this.path = path; this.path = path;
this.overlay = drawing.drawPath(this.path); this.overlay = drawing.drawPath(this.path);
@ -183,13 +184,14 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
} }
}); });
JColorChooser.createDialog(getTopLevelAncestor(), "Pick a new color", true, chooser, JColorChooser.createDialog(getTopLevelAncestor(), "Pick a new color", true,
new ActionListener() { chooser, new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
icon.setColor(chooser.getSelectionModel().getSelectedColor()); icon.setColor(chooser.getSelectionModel().getSelectedColor());
colorButton.repaint(); colorButton.repaint();
overlay.setColor(chooser.getSelectionModel().getSelectedColor()); overlay.setColor(
chooser.getSelectionModel().getSelectedColor());
overlay.redraw(); overlay.redraw();
} }
}, new ActionListener() { }, new ActionListener() {
@ -225,11 +227,12 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
fileChooser.setApproveButtonText("Save"); fileChooser.setApproveButtonText("Save");
fileChooser.setToolTipText("Save"); fileChooser.setToolTipText("Save");
if (fileChooser.showSaveDialog(getTopLevelAncestor()) == JFileChooser.APPROVE_OPTION) { if (fileChooser
.showSaveDialog(getTopLevelAncestor()) == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile(); File file = fileChooser.getSelectedFile();
try { try {
BinaryPathWriter writer = new BinaryPathWriter( BinaryPathWriter writer = new BinaryPathWriter(new DataOutputStream(
new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)))); new BufferedOutputStream(new FileOutputStream(file))));
writer.writePath(path); writer.writePath(path);
} }
catch (IOException e1) { catch (IOException e1) {
@ -288,7 +291,8 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
public String toString() { public String toString() {
return "Path from #" + path.getOrigin().getId() + " to #" + path.getDestination().getId(); return "Path from #" + path.getOrigin().getId() + " to #"
+ path.getDestination().getId();
} }
} }