diff options
-rw-r--r-- | src/about.txt | 12 | ||||
-rw-r--r-- | src/org/unitConverter/converterGUI/UnitConverterGUI.java | 46 |
2 files changed, 54 insertions, 4 deletions
diff --git a/src/about.txt b/src/about.txt new file mode 100644 index 0000000..1bad9e8 --- /dev/null +++ b/src/about.txt @@ -0,0 +1,12 @@ +About Unit Converter v0.2.0 + +Copyright Notice: + +Unit Converter Copyright (C) 2018-2021 Adrien Hopkins +This program comes with ABSOLUTELY NO WARRANTY; +for details read the LICENSE file, section 15 + +This is free software, and you are welcome to redistribute +it under certain conditions; for details go to +<https://www.gnu.org/licenses/quick-guide-gplv3.html> +or read the LICENSE file.
\ No newline at end of file diff --git a/src/org/unitConverter/converterGUI/UnitConverterGUI.java b/src/org/unitConverter/converterGUI/UnitConverterGUI.java index b8b8894..69f188b 100644 --- a/src/org/unitConverter/converterGUI/UnitConverterGUI.java +++ b/src/org/unitConverter/converterGUI/UnitConverterGUI.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2018 Adrien Hopkins + * Copyright (C) 2018-2021 Adrien Hopkins * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -41,6 +41,7 @@ import java.util.List; import java.util.NoSuchElementException; import java.util.Set; import java.util.function.Predicate; +import java.util.stream.Collectors; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -59,6 +60,8 @@ import javax.swing.JSlider; import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.JTextField; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; import javax.swing.WindowConstants; import javax.swing.border.TitledBorder; @@ -85,7 +88,7 @@ final class UnitConverterGUI { * A tab in the View. */ private enum Pane { - UNIT_CONVERTER, EXPRESSION_CONVERTER, UNIT_VIEWER, PREFIX_VIEWER, + UNIT_CONVERTER, EXPRESSION_CONVERTER, UNIT_VIEWER, PREFIX_VIEWER, ABOUT, SETTINGS; } @@ -766,9 +769,19 @@ final class UnitConverterGUI { this.presenter = new Presenter(this); this.frame = new JFrame("Unit Converter"); this.frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - this.masterPane = new JTabbedPane(); + + // enable system look and feel + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException | UnsupportedLookAndFeelException e) { + // oh well, just use default theme + System.err.println("Failed to enable system look-and-feel."); + e.printStackTrace(); + } // create the components + this.masterPane = new JTabbedPane(); this.unitNameList = new SearchBoxList(this.presenter.unitNameSet()); this.prefixNameList = new SearchBoxList(this.presenter.prefixNameSet(), this.presenter.getPrefixNameComparator(), true); @@ -803,6 +816,8 @@ final class UnitConverterGUI { case 3: return Pane.PREFIX_VIEWER; case 4: + return Pane.ABOUT; + case 5: return Pane.SETTINGS; default: throw new AssertionError("No selected pane, or invalid pane."); @@ -1114,10 +1129,33 @@ final class UnitConverterGUI { } } + { // Info panel + final JPanel infoPanel = new JPanel(); + this.masterPane.addTab("\uD83D\uDEC8", // info (i) character + new JScrollPane(infoPanel)); + + final JTextArea infoTextArea = new JTextArea(); + infoTextArea.setEditable(false); + infoTextArea.setOpaque(false); + infoPanel.add(infoTextArea); + + // get info text + final String infoText; + try { + final Path aboutFile = Path.of("src", "about.txt"); + infoText = Files.readAllLines(aboutFile).stream() + .filter(s -> !s.trim().startsWith("#")) + .collect(Collectors.joining("\n")); + } catch (final IOException e) { + throw new AssertionError("I/O exception loading about.txt"); + } + infoTextArea.setText(infoText); + } + { // Settings panel final JPanel settingsPanel = new JPanel(); this.masterPane.addTab("\u2699", new JScrollPane(settingsPanel)); - this.masterPane.setMnemonicAt(4, KeyEvent.VK_S); + this.masterPane.setMnemonicAt(5, KeyEvent.VK_S); settingsPanel.setLayout( new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS)); |