Compare commits
44 Commits
Author | SHA1 | Date |
---|---|---|
Marcel Kapfer | 76e17e164a | |
Marcel Kapfer (mmk2410) | 3682719efa | |
Marcel Kapfer (mmk2410) | 62338503bd | |
Marcel Kapfer (mmk2410) | 9e395af263 | |
Marcel Kapfer (mmk2410) | 78e5ff74f2 | |
Marcel Kapfer (mmk2410) | 8e45e62cd0 | |
Marcel Kapfer (mmk2410) | 85261470cc | |
Marcel Kapfer (mmk2410) | 280f195755 | |
mmk2410 | 95cb753508 | |
mmk2410 | b549c99096 | |
mmk2410 | 5854c86ca3 | |
mmk2410 | f8121441eb | |
mmk2410 | 7ee89a50d7 | |
Marcel Michael Kapfer | ea2b9efaae | |
mmk2410 | fab340487c | |
mmk2410 | cf65377930 | |
mmk2410 | 17e2599c19 | |
Marcel Kapfer | cbfc4f3f33 | |
mmk2410 | fb49b73b7e | |
mmk2410 | 2aeadf10ee | |
mmk2410 | ec2ff6afd1 | |
mmk2410 | e2a90823b7 | |
mmk2410 | 0cd8b05940 | |
Marcel Kapfer | 3d25da5e61 | |
Marcel Kapfer | 29ab9f18b1 | |
Marcel Kapfer | eb8504837e | |
mmk2410 | 16e34b316d | |
mmk2410 | d80d0e8c36 | |
mmk2410 | 7620a56520 | |
mmk2410 | ad74229132 | |
Marcel Kapfer | 24e5077e57 | |
mmk2410 | 769b0edc4e | |
mmk2410 | 8a2d23ae64 | |
mmk2410 | 39c83a7a38 | |
Marcel Kapfer | 4810f03ddd | |
mmk2410 | 60b56a5b25 | |
mmk2410 | c99d23eafd | |
mmk2410 | 7f13ad0ce6 | |
mmk2410 | 21a83e4eaa | |
mmk2410 | d82ba783ae | |
mmk2410 | 36ca7f81d3 | |
mmk2410 | f147ec1d72 | |
mmk2410 | ee6b497301 | |
mmk2410 | 7d066c0d7e |
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -1,12 +1,2 @@
|
|||
*.class
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
out/
|
||||
/res/
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
de.marcelkapfer.c.morseconverter
|
|
@ -0,0 +1,8 @@
|
|||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="de.marcelkapfer.c.morseconverter:jar">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/de_marcelkapfer_c_morseconverter_jar</output-path>
|
||||
<root id="archive" name="de.marcelkapfer.c.morseconverter.jar">
|
||||
<element id="module-output" name="de.marcelkapfer.c.morseconverter" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,3 @@
|
|||
<component name="CopyrightManager">
|
||||
<settings default="" />
|
||||
</component>
|
|
@ -0,0 +1,8 @@
|
|||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="mmk">
|
||||
<words>
|
||||
<w>kapfer</w>
|
||||
<w>morseconverter</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
|
@ -0,0 +1,86 @@
|
|||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="mmk2410">
|
||||
<words>
|
||||
<w>abteilung</w>
|
||||
<w>affero</w>
|
||||
<w>aktivieren</w>
|
||||
<w>aktuelle</w>
|
||||
<w>aktuellste</w>
|
||||
<w>anleitung</w>
|
||||
<w>aufmerksam</w>
|
||||
<w>ausführliche</w>
|
||||
<w>beim</w>
|
||||
<w>bereinigen</w>
|
||||
<w>bist</w>
|
||||
<w>bitte</w>
|
||||
<w>dann</w>
|
||||
<w>diese</w>
|
||||
<w>eine</w>
|
||||
<w>einen</w>
|
||||
<w>einfügen</w>
|
||||
<w>entwickler</w>
|
||||
<w>erfolgreich</w>
|
||||
<w>fadb</w>
|
||||
<w>fehlenden</w>
|
||||
<w>fehlender</w>
|
||||
<w>fehler</w>
|
||||
<w>finden</w>
|
||||
<w>fullname</w>
|
||||
<w>geben</w>
|
||||
<w>gefunden</w>
|
||||
<w>geworden</w>
|
||||
<w>herunterladen</w>
|
||||
<w>hgap</w>
|
||||
<w>hsize</w>
|
||||
<w>hspacer</w>
|
||||
<w>installieren</w>
|
||||
<w>kannst</w>
|
||||
<w>kontakt</w>
|
||||
<w>kopieren</w>
|
||||
<w>letterspace</w>
|
||||
<w>lgpl</w>
|
||||
<w>licensors</w>
|
||||
<w>lizenz</w>
|
||||
<w>marcelkapfer</w>
|
||||
<w>mehr</w>
|
||||
<w>möglich</w>
|
||||
<w>neues</w>
|
||||
<w>nich</w>
|
||||
<w>nicht</w>
|
||||
<w>nochmal</w>
|
||||
<w>noncommercially</w>
|
||||
<w>normales</w>
|
||||
<w>recognization</w>
|
||||
<w>relicensing</w>
|
||||
<w>schließen</w>
|
||||
<w>schreibe</w>
|
||||
<w>scrollpane</w>
|
||||
<w>später</w>
|
||||
<w>starten</w>
|
||||
<w>sublicenses</w>
|
||||
<w>sublicensing</w>
|
||||
<w>sudo</w>
|
||||
<w>suppressions</w>
|
||||
<w>tabbedpane</w>
|
||||
<w>trat</w>
|
||||
<w>trello</w>
|
||||
<w>umwandler</w>
|
||||
<w>verbindung</w>
|
||||
<w>verfügbar</w>
|
||||
<w>verfügbarr</w>
|
||||
<w>versuch</w>
|
||||
<w>versuchen</w>
|
||||
<w>verwendest</w>
|
||||
<w>verzeichniss</w>
|
||||
<w>vgap</w>
|
||||
<w>vsize</w>
|
||||
<w>wenn</w>
|
||||
<w>willst</w>
|
||||
<w>wipo</w>
|
||||
<w>writtenmorse</w>
|
||||
<w>änderungen</w>
|
||||
<w>über</w>
|
||||
<w>überprüfen</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="JavadocGenerationManager">
|
||||
<option name="OUTPUT_DIRECTORY" value="$USER_HOME$/tmp" />
|
||||
<option name="OPTION_SCOPE" value="protected" />
|
||||
<option name="OPTION_HIERARCHY" value="true" />
|
||||
<option name="OPTION_NAVIGATOR" value="true" />
|
||||
<option name="OPTION_INDEX" value="true" />
|
||||
<option name="OPTION_SEPARATE_INDEX" value="true" />
|
||||
<option name="OPTION_DOCUMENT_TAG_USE" value="false" />
|
||||
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" />
|
||||
<option name="OPTION_DOCUMENT_TAG_VERSION" value="false" />
|
||||
<option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
|
||||
<option name="OPTION_DEPRECATED_LIST" value="true" />
|
||||
<option name="OTHER_OPTIONS" />
|
||||
<option name="HEAP_SIZE" />
|
||||
<option name="LOCALE" />
|
||||
<option name="OPEN_IN_BROWSER" value="true" />
|
||||
<option name="OPTION_INCLUDE_LIBS" value="false" />
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
<OptionsSetting value="true" id="Checkout" />
|
||||
<OptionsSetting value="true" id="Update" />
|
||||
<OptionsSetting value="true" id="Status" />
|
||||
<OptionsSetting value="true" id="Edit" />
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/de.marcelkapfer.c.morseconverter.iml" filepath="$PROJECT_DIR$/de.marcelkapfer.c.morseconverter.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
File diff suppressed because it is too large
Load Diff
12896
.metadata/.bak_0.log
12896
.metadata/.bak_0.log
File diff suppressed because it is too large
Load Diff
5815
.metadata/.log
5815
.metadata/.log
File diff suppressed because it is too large
Load Diff
|
@ -1,34 +0,0 @@
|
|||
*** SESSION Aug 07, 2014 18:11:21.36 -------------------------------------------
|
||||
*** SESSION Aug 13, 2014 11:18:13.02 -------------------------------------------
|
||||
*** SESSION Aug 13, 2014 19:29:14.47 -------------------------------------------
|
||||
*** SESSION Aug 14, 2014 08:45:09.10 -------------------------------------------
|
||||
*** SESSION Aug 17, 2014 20:30:07.62 -------------------------------------------
|
||||
*** SESSION Aug 17, 2014 21:35:21.75 -------------------------------------------
|
||||
*** SESSION Aug 18, 2014 00:51:01.05 -------------------------------------------
|
||||
*** SESSION Aug 18, 2014 00:55:09.85 -------------------------------------------
|
||||
*** SESSION Aug 18, 2014 09:03:46.13 -------------------------------------------
|
||||
*** SESSION Sep 18, 2014 19:36:18.58 -------------------------------------------
|
||||
*** SESSION Sep 19, 2014 18:58:07.74 -------------------------------------------
|
||||
*** SESSION Sep 20, 2014 21:09:29.74 -------------------------------------------
|
||||
*** SESSION Sep 20, 2014 21:24:26.14 -------------------------------------------
|
||||
*** SESSION Sep 21, 2014 10:30:07.78 -------------------------------------------
|
||||
*** SESSION Sep 21, 2014 17:40:36.61 -------------------------------------------
|
||||
*** SESSION Sep 26, 2014 18:21:47.72 -------------------------------------------
|
||||
*** SESSION Sep 26, 2014 19:35:25.66 -------------------------------------------
|
||||
*** SESSION Sep 27, 2014 07:11:51.76 -------------------------------------------
|
||||
*** SESSION Sep 27, 2014 09:42:06.29 -------------------------------------------
|
||||
*** SESSION Sep 27, 2014 22:34:25.43 -------------------------------------------
|
||||
*** SESSION Sep 28, 2014 16:41:17.63 -------------------------------------------
|
||||
*** SESSION Oct 05, 2014 22:39:42.34 -------------------------------------------
|
||||
*** SESSION Oct 26, 2014 10:54:24.50 -------------------------------------------
|
||||
*** SESSION Nov 06, 2014 19:18:45.66 -------------------------------------------
|
||||
*** SESSION Nov 06, 2014 22:12:25.33 -------------------------------------------
|
||||
*** SESSION Nov 07, 2014 06:18:43.84 -------------------------------------------
|
||||
*** SESSION Nov 08, 2014 19:18:44.84 -------------------------------------------
|
||||
*** SESSION Nov 08, 2014 21:02:49.62 -------------------------------------------
|
||||
*** SESSION Nov 09, 2014 21:59:35.54 -------------------------------------------
|
||||
*** SESSION Nov 10, 2014 22:19:20.77 -------------------------------------------
|
||||
*** SESSION Nov 16, 2014 21:30:46.27 -------------------------------------------
|
||||
*** SESSION Nov 21, 2014 23:15:41.46 -------------------------------------------
|
||||
*** SESSION Nov 30, 2014 12:26:18.20 -------------------------------------------
|
||||
*** SESSION Dec 11, 2014 19:28:31.76 -------------------------------------------
|
|
@ -1 +0,0 @@
|
|||
|
|
@ -1 +0,0 @@
|
|||
|
|
@ -1,478 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
//TODO add right click popup menu
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.deleteCharAt(output.length() - 1)
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 223);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "About", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 148);
|
||||
contentPanel.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Marcel Kapfer");
|
||||
lblDeveloper.setBounds(124, 17, 307, 15);
|
||||
panel.add(lblDeveloper);
|
||||
|
||||
JLabel lblDev = new JLabel("Developer");
|
||||
lblDev.setBounds(12, 17, 100, 15);
|
||||
panel.add(lblDev);
|
||||
|
||||
JLabel lblWeb = new JLabel("Website");
|
||||
lblWeb.setBounds(12, 44, 100, 15);
|
||||
panel.add(lblWeb);
|
||||
|
||||
JLabel lblCont = new JLabel("New label");
|
||||
lblCont.setBounds(12, 71, 100, 15);
|
||||
panel.add(lblCont);
|
||||
|
||||
JLabel lblLic = new JLabel("New label");
|
||||
lblLic.setBounds(12, 98, 100, 15);
|
||||
panel.add(lblLic);
|
||||
|
||||
JLabel lblVer = new JLabel("New label");
|
||||
lblVer.setBounds(12, 125, 100, 15);
|
||||
panel.add(lblVer);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,555 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
mntmOpClipboardCopy.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
mntmOpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfOutput.requestFocus();
|
||||
tfOutput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
if(output.toString().endsWith("#") && (output.toString().equals("#") == false)){
|
||||
output.delete(output.length() - 1, output.length());
|
||||
}
|
||||
tfOutput.setText(output.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
private void onCopy(JTextArea tf){
|
||||
StringSelection selection = new StringSelection(tf.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 223);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "About", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 148);
|
||||
contentPanel.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Marcel Kapfer");
|
||||
lblDeveloper.setBounds(124, 17, 307, 15);
|
||||
panel.add(lblDeveloper);
|
||||
|
||||
JLabel lblDev = new JLabel("Developer");
|
||||
lblDev.setBounds(12, 17, 100, 15);
|
||||
panel.add(lblDev);
|
||||
|
||||
JLabel lblWeb = new JLabel("Website");
|
||||
lblWeb.setBounds(12, 44, 100, 15);
|
||||
panel.add(lblWeb);
|
||||
|
||||
JLabel lblCont = new JLabel("Contact");
|
||||
lblCont.setBounds(12, 71, 100, 15);
|
||||
panel.add(lblCont);
|
||||
|
||||
JLabel lblVer = new JLabel("Version");
|
||||
lblVer.setBounds(12, 98, 100, 15);
|
||||
panel.add(lblVer);
|
||||
|
||||
JLabel lblLic = new JLabel("License");
|
||||
lblLic.setBounds(12, 125, 100, 15);
|
||||
panel.add(lblLic);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("marcel-kapfer.de/projects/morse");
|
||||
lblNewLabel.setBounds(124, 44, 307, 15);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("marcelmichaelkapfer@yahoo.co.nz");
|
||||
lblNewLabel_1.setBounds(124, 71, 307, 15);
|
||||
panel.add(lblNewLabel_1);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("0.99");
|
||||
lblNewLabel_2.setBounds(124, 98, 307, 15);
|
||||
panel.add(lblNewLabel_2);
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("GNU v3.0");
|
||||
lblNewLabel_3.setBounds(124, 125, 307, 15);
|
||||
panel.add(lblNewLabel_3);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,540 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
//TODO add right click popup menu
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.deleteCharAt(output.length() - 1)
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
}
|
|
@ -1,545 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
//TODO add right click popup menu
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.delete(output.length() - 1, output.length())
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
}
|
|
@ -1,558 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
mntmOpClipboardCopy.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.delete(output.length() - 1, output.length())
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
private void onCopy(JTextArea tf){
|
||||
StringSelection selection = new StringSelection(tf.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 300);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "Developer", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 37);
|
||||
contentPanel.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Developer: Marcel Kapfer");
|
||||
lblDeveloper.setBounds(5, 17, 426, 15);
|
||||
panel.add(lblDeveloper);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,560 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
mntmOpClipboardCopy.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
mntmOpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfOutput.requestFocus();
|
||||
tfOutput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
if(output.toString().endsWith("#") && (output.toString().equals("#") == false)){
|
||||
output.delete(output.length() - 1, output.length());
|
||||
}
|
||||
tfOutput.setText(output.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
private void onCopy(JTextArea tf){
|
||||
StringSelection selection = new StringSelection(tf.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.net.URI;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 223);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "About", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 148);
|
||||
contentPanel.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Marcel Kapfer");
|
||||
lblDeveloper.setBounds(124, 17, 307, 15);
|
||||
panel.add(lblDeveloper);
|
||||
|
||||
JLabel lblDev = new JLabel("Developer");
|
||||
lblDev.setBounds(12, 17, 100, 15);
|
||||
panel.add(lblDev);
|
||||
|
||||
JLabel lblWeb = new JLabel("Website");
|
||||
lblWeb.setBounds(12, 44, 100, 15);
|
||||
panel.add(lblWeb);
|
||||
|
||||
JLabel lblCont = new JLabel("Contact");
|
||||
lblCont.setBounds(12, 71, 100, 15);
|
||||
panel.add(lblCont);
|
||||
|
||||
JLabel lblVer = new JLabel("Version");
|
||||
lblVer.setBounds(12, 98, 100, 15);
|
||||
panel.add(lblVer);
|
||||
|
||||
JLabel lblLic = new JLabel("License");
|
||||
lblLic.setBounds(12, 125, 100, 15);
|
||||
panel.add(lblLic);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("marcel-kapfer.de/projects/morse");
|
||||
lblNewLabel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
|
||||
if(Desktop.isDesktopSupported())
|
||||
{
|
||||
Desktop.getDesktop().browse(new URI("http://www.example.com"));
|
||||
}
|
||||
}
|
||||
});
|
||||
lblNewLabel.setBounds(124, 44, 307, 15);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("marcelmichaelkapfer@yahoo.co.nz");
|
||||
lblNewLabel_1.setBounds(124, 71, 307, 15);
|
||||
panel.add(lblNewLabel_1);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("0.99");
|
||||
lblNewLabel_2.setBounds(124, 98, 307, 15);
|
||||
panel.add(lblNewLabel_2);
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("GNU v3.0");
|
||||
lblNewLabel_3.setBounds(124, 125, 307, 15);
|
||||
panel.add(lblNewLabel_3);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,555 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
mntmOpClipboardCopy.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.delete(output.length() - 1, output.length())
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
private void onCopy(JTextArea tf){
|
||||
StringSelection selection = new StringSelection(tf.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
|
@ -1,535 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
//TODO add right click popup menu
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.deleteCharAt(output.length() - 1)
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 300);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "About", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 236);
|
||||
contentPanel.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Marcel Kapfer");
|
||||
lblDeveloper.setBounds(124, 17, 307, 15);
|
||||
panel.add(lblDeveloper);
|
||||
|
||||
JLabel lblDev = new JLabel("Developer");
|
||||
lblDev.setBounds(12, 17, 100, 15);
|
||||
panel.add(lblDev);
|
||||
|
||||
JLabel lblWeb = new JLabel("Website");
|
||||
lblWeb.setBounds(12, 44, 100, 15);
|
||||
panel.add(lblWeb);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 223);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "About", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 148);
|
||||
contentPanel.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Marcel Kapfer");
|
||||
lblDeveloper.setBounds(124, 17, 307, 15);
|
||||
panel.add(lblDeveloper);
|
||||
|
||||
JLabel lblDev = new JLabel("Developer");
|
||||
lblDev.setBounds(12, 17, 100, 15);
|
||||
panel.add(lblDev);
|
||||
|
||||
JLabel lblWeb = new JLabel("Website");
|
||||
lblWeb.setBounds(12, 44, 100, 15);
|
||||
panel.add(lblWeb);
|
||||
|
||||
JLabel lblCont = new JLabel("Contact");
|
||||
lblCont.setBounds(12, 71, 100, 15);
|
||||
panel.add(lblCont);
|
||||
|
||||
JLabel lblLic = new JLabel("Version");
|
||||
lblLic.setBounds(12, 98, 100, 15);
|
||||
panel.add(lblLic);
|
||||
|
||||
JLabel lblVer = new JLabel("License");
|
||||
lblVer.setBounds(12, 125, 100, 15);
|
||||
panel.add(lblVer);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,545 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.replaceSelection(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
//TODO add right click popup menu
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.deleteCharAt(output.length() - 1)
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 300);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "Developer", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 37);
|
||||
contentPanel.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Marcel Kapfer");
|
||||
lblDeveloper.setBounds(5, 17, 426, 15);
|
||||
panel.add(lblDeveloper);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 223);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "About", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 148);
|
||||
contentPanel.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Marcel Kapfer");
|
||||
lblDeveloper.setBounds(124, 17, 307, 15);
|
||||
panel.add(lblDeveloper);
|
||||
|
||||
JLabel lblDev = new JLabel("Developer");
|
||||
lblDev.setBounds(12, 17, 100, 15);
|
||||
panel.add(lblDev);
|
||||
|
||||
JLabel lblWeb = new JLabel("Website");
|
||||
lblWeb.setBounds(12, 44, 100, 15);
|
||||
panel.add(lblWeb);
|
||||
|
||||
JLabel lblCont = new JLabel("Contact");
|
||||
lblCont.setBounds(12, 71, 100, 15);
|
||||
panel.add(lblCont);
|
||||
|
||||
JLabel lblVer = new JLabel("Version");
|
||||
lblVer.setBounds(12, 98, 100, 15);
|
||||
panel.add(lblVer);
|
||||
|
||||
JLabel lblLic = new JLabel("License");
|
||||
lblLic.setBounds(12, 125, 100, 15);
|
||||
panel.add(lblLic);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("New label");
|
||||
lblNewLabel.setBounds(124, 44, 307, 15);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("New label");
|
||||
lblNewLabel_1.setBounds(124, 71, 307, 15);
|
||||
panel.add(lblNewLabel_1);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("New label");
|
||||
lblNewLabel_2.setBounds(124, 98, 307, 15);
|
||||
panel.add(lblNewLabel_2);
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("New label");
|
||||
lblNewLabel_3.setBounds(124, 125, 307, 15);
|
||||
panel.add(lblNewLabel_3);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,561 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
mntmOpClipboardCopy.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
mntmOpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfOutput.requestFocus();
|
||||
tfOutput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
if(output.toString().endsWith("#")){
|
||||
output.delete(output.length() - 1, output.length());
|
||||
}
|
||||
tfOutput.setText(output.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
private void onCopy(JTextArea tf){
|
||||
StringSelection selection = new StringSelection(tf.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
|
@ -1,557 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
mntmOpClipboardCopy.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
mntmOpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfOutput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.delete(output.length() - 1, output.length())
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
private void onCopy(JTextArea tf){
|
||||
StringSelection selection = new StringSelection(tf.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
|
@ -1,526 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
tfInput.setText(clipboard.toString());
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
//TODO add right click popup menu
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.deleteCharAt(output.length() - 1)
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,545 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.removeAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
//TODO add right click popup menu
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.deleteCharAt(output.length() - 1)
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 223);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "About", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 148);
|
||||
contentPanel.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Marcel Kapfer");
|
||||
lblDeveloper.setBounds(124, 17, 307, 15);
|
||||
panel.add(lblDeveloper);
|
||||
|
||||
JLabel lblDev = new JLabel("Developer");
|
||||
lblDev.setBounds(12, 17, 100, 15);
|
||||
panel.add(lblDev);
|
||||
|
||||
JLabel lblWeb = new JLabel("Website");
|
||||
lblWeb.setBounds(12, 44, 100, 15);
|
||||
panel.add(lblWeb);
|
||||
|
||||
JLabel lblCont = new JLabel("Contact");
|
||||
lblCont.setBounds(12, 71, 100, 15);
|
||||
panel.add(lblCont);
|
||||
|
||||
JLabel lblVer = new JLabel("Version");
|
||||
lblVer.setBounds(12, 98, 100, 15);
|
||||
panel.add(lblVer);
|
||||
|
||||
JLabel lblLic = new JLabel("License");
|
||||
lblLic.setBounds(12, 125, 100, 15);
|
||||
panel.add(lblLic);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("marcel-kapfer.de");
|
||||
lblNewLabel.setBounds(124, 44, 307, 15);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("marcelmichaelkapfer@gmail.com");
|
||||
lblNewLabel_1.setBounds(124, 71, 307, 15);
|
||||
panel.add(lblNewLabel_1);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("0.99");
|
||||
lblNewLabel_2.setBounds(124, 98, 307, 15);
|
||||
panel.add(lblNewLabel_2);
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("GNU v3.0");
|
||||
lblNewLabel_3.setBounds(124, 125, 307, 15);
|
||||
panel.add(lblNewLabel_3);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,545 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
//TODO add right click popup menu
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.deleteCharAt(output.length() - 2)
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 223);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "About", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 148);
|
||||
contentPanel.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Marcel Kapfer");
|
||||
lblDeveloper.setBounds(124, 17, 307, 15);
|
||||
panel.add(lblDeveloper);
|
||||
|
||||
JLabel lblDev = new JLabel("Developer");
|
||||
lblDev.setBounds(12, 17, 100, 15);
|
||||
panel.add(lblDev);
|
||||
|
||||
JLabel lblWeb = new JLabel("Website");
|
||||
lblWeb.setBounds(12, 44, 100, 15);
|
||||
panel.add(lblWeb);
|
||||
|
||||
JLabel lblCont = new JLabel("Contact");
|
||||
lblCont.setBounds(12, 71, 100, 15);
|
||||
panel.add(lblCont);
|
||||
|
||||
JLabel lblVer = new JLabel("Version");
|
||||
lblVer.setBounds(12, 98, 100, 15);
|
||||
panel.add(lblVer);
|
||||
|
||||
JLabel lblLic = new JLabel("License");
|
||||
lblLic.setBounds(12, 125, 100, 15);
|
||||
panel.add(lblLic);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("New label");
|
||||
lblNewLabel.setBounds(124, 44, 70, 15);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("New label");
|
||||
lblNewLabel_1.setBounds(124, 71, 70, 15);
|
||||
panel.add(lblNewLabel_1);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("New label");
|
||||
lblNewLabel_2.setBounds(124, 98, 70, 15);
|
||||
panel.add(lblNewLabel_2);
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("New label");
|
||||
lblNewLabel_3.setBounds(124, 125, 70, 15);
|
||||
panel.add(lblNewLabel_3);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,544 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.delete(output.length() - 1, output.length())
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 300);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setLayout(new FlowLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,560 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
mntmOpClipboardCopy.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
mntmOpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfOutput.requestFocus();
|
||||
tfOutput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
if(output.toString().endsWith("#")){
|
||||
output.delete(output.length() - 1, output.length());
|
||||
}
|
||||
tfOutput.setText(output.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
private void onCopy(JTextArea tf){
|
||||
StringSelection selection = new StringSelection(tf.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
|
@ -1,559 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
mntmOpClipboardCopy.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
mntmOpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfOutput.requestFocus();
|
||||
tfOutput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.delete(output.length() - 1, output.length())
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
private void onCopy(JTextArea tf){
|
||||
StringSelection selection = new StringSelection(tf.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 223);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "About", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 148);
|
||||
contentPanel.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Marcel Kapfer");
|
||||
lblDeveloper.setBounds(124, 17, 307, 15);
|
||||
panel.add(lblDeveloper);
|
||||
|
||||
JLabel lblDev = new JLabel("Developer");
|
||||
lblDev.setBounds(12, 17, 100, 15);
|
||||
panel.add(lblDev);
|
||||
|
||||
JLabel lblWeb = new JLabel("Website");
|
||||
lblWeb.setBounds(12, 44, 100, 15);
|
||||
panel.add(lblWeb);
|
||||
|
||||
JLabel lblCont = new JLabel("Contact");
|
||||
lblCont.setBounds(12, 71, 100, 15);
|
||||
panel.add(lblCont);
|
||||
|
||||
JLabel lblVer = new JLabel("Version");
|
||||
lblVer.setBounds(12, 98, 100, 15);
|
||||
panel.add(lblVer);
|
||||
|
||||
JLabel lblLic = new JLabel("License");
|
||||
lblLic.setBounds(12, 125, 100, 15);
|
||||
panel.add(lblLic);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("marcel-kapfer.de/projects/morse");
|
||||
lblNewLabel.setBounds(124, 44, 307, 15);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("marcelmichaelkapfer@yahoo.co.nz");
|
||||
lblNewLabel_1.setBounds(124, 71, 307, 15);
|
||||
panel.add(lblNewLabel_1);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("0.99");
|
||||
lblNewLabel_2.setBounds(124, 98, 307, 15);
|
||||
panel.add(lblNewLabel_2);
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("GNU v3.0");
|
||||
lblNewLabel_3.setBounds(124, 125, 307, 15);
|
||||
panel.add(lblNewLabel_3);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,545 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
//TODO add right click popup menu
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.deleteCharAt(output.length() - 1)
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 300);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "About", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 37);
|
||||
contentPanel.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Marcel Kapfer");
|
||||
lblDeveloper.setBounds(5, 17, 426, 15);
|
||||
panel.add(lblDeveloper);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,561 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
mntmOpClipboardCopy.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
mntmOpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfOutput.requestFocus();
|
||||
tfOutput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
return;
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
if(output.toString().endsWith("#") && (output.toString().equals("#") == false)){
|
||||
output.delete(output.length() - 1, output.length());
|
||||
}
|
||||
tfOutput.setText(output.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
private void onCopy(JTextArea tf){
|
||||
StringSelection selection = new StringSelection(tf.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
|
@ -1,519 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPase = new JMenuItem("Pase from Clipboard");
|
||||
popupMenuIp.add(mntmIpPase);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
//TODO add right click popup menu
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.deleteCharAt(output.length() - 1)
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JApplet;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class MorseApplet extends JApplet {
|
||||
|
||||
/**
|
||||
* Create the applet.
|
||||
*/
|
||||
public MorseApplet() {
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "About", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 148);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Marcel Kapfer");
|
||||
lblDeveloper.setBounds(124, 17, 307, 15);
|
||||
panel.add(lblDeveloper);
|
||||
|
||||
JLabel lblDev = new JLabel("Developer");
|
||||
lblDev.setBounds(12, 17, 100, 15);
|
||||
panel.add(lblDev);
|
||||
|
||||
JLabel lblWeb = new JLabel("Website");
|
||||
lblWeb.setBounds(12, 44, 100, 15);
|
||||
panel.add(lblWeb);
|
||||
|
||||
JLabel lblCont = new JLabel("Contact");
|
||||
lblCont.setBounds(12, 71, 100, 15);
|
||||
panel.add(lblCont);
|
||||
|
||||
JLabel lblVer = new JLabel("Version");
|
||||
lblVer.setBounds(12, 98, 100, 15);
|
||||
panel.add(lblVer);
|
||||
|
||||
JLabel lblLic = new JLabel("License");
|
||||
lblLic.setBounds(12, 125, 100, 15);
|
||||
panel.add(lblLic);
|
||||
|
||||
JLabel lblWebsite = new JLabel("marcel-kapfer.de/projects/morse");
|
||||
lblWebsite.setBounds(124, 44, 307, 15);
|
||||
panel.add(lblWebsite);
|
||||
|
||||
JLabel lblContact = new JLabel("marcelmichaelkapfer@yahoo.co.nz");
|
||||
lblContact.setBounds(124, 71, 307, 15);
|
||||
panel.add(lblContact);
|
||||
|
||||
JLabel lblVersion = new JLabel("0.99-08112014 beta");
|
||||
lblVersion.setBounds(124, 98, 307, 15);
|
||||
panel.add(lblVersion);
|
||||
|
||||
JLabel lblLicense = new JLabel("GNU v3.0");
|
||||
lblLicense.setBounds(124, 125, 307, 15);
|
||||
panel.add(lblLicense);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,566 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
mntmOpClipboardCopy.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
mntmOpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfOutput.requestFocus();
|
||||
tfOutput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
if(output.toString().endsWith("#") && (output.toString().equals("#") == false)){
|
||||
output.delete(output.length() - 1, output.length());
|
||||
}
|
||||
tfOutput.setText(output.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* popup menu
|
||||
*/
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Past function
|
||||
*/
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
|
||||
/*
|
||||
* Copy function
|
||||
*/
|
||||
private void onCopy(JTextArea tf){
|
||||
StringSelection selection = new StringSelection(tf.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class About extends JDialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final JPanel contentPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
About dialog = new About();
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
*/
|
||||
public About() {
|
||||
setUndecorated(true);
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 450, 223);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||
contentPanel.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(new TitledBorder(null, "About", TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
||||
panel.setBounds(5, 17, 436, 148);
|
||||
contentPanel.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel lblDeveloper = new JLabel("Marcel Kapfer");
|
||||
lblDeveloper.setBounds(124, 17, 307, 15);
|
||||
panel.add(lblDeveloper);
|
||||
|
||||
JLabel lblDev = new JLabel("Developer");
|
||||
lblDev.setBounds(12, 17, 100, 15);
|
||||
panel.add(lblDev);
|
||||
|
||||
JLabel lblWeb = new JLabel("Website");
|
||||
lblWeb.setBounds(12, 44, 100, 15);
|
||||
panel.add(lblWeb);
|
||||
|
||||
JLabel lblCont = new JLabel("Contact");
|
||||
lblCont.setBounds(12, 71, 100, 15);
|
||||
panel.add(lblCont);
|
||||
|
||||
JLabel lblVer = new JLabel("Version");
|
||||
lblVer.setBounds(12, 98, 100, 15);
|
||||
panel.add(lblVer);
|
||||
|
||||
JLabel lblLic = new JLabel("License");
|
||||
lblLic.setBounds(12, 125, 100, 15);
|
||||
panel.add(lblLic);
|
||||
|
||||
JLabel lblNewLabel = new JLabel("marcel-kapfer.de/projects/morse");
|
||||
lblNewLabel.setBounds(124, 44, 307, 15);
|
||||
panel.add(lblNewLabel);
|
||||
|
||||
JLabel lblNewLabel_1 = new JLabel("marcelmichaelkapfer@yahoo.co.nz");
|
||||
lblNewLabel_1.setBounds(124, 71, 307, 15);
|
||||
panel.add(lblNewLabel_1);
|
||||
|
||||
JLabel lblNewLabel_2 = new JLabel("0.99");
|
||||
lblNewLabel_2.setBounds(124, 98, 307, 15);
|
||||
panel.add(lblNewLabel_2);
|
||||
|
||||
JLabel lblNewLabel_3 = new JLabel("GNU v3.0");
|
||||
lblNewLabel_3.setBounds(124, 125, 307, 15);
|
||||
panel.add(lblNewLabel_3);
|
||||
{
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
||||
{
|
||||
JButton cancelButton = new JButton("Close");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
cancelButton.setActionCommand("Cancel");
|
||||
buttonPane.add(cancelButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,552 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
mntmOpClipboardCopy.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
StringSelection selection = new StringSelection(tfOutput.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.delete(output.length() - 1, output.length())
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
}
|
|
@ -1,552 +0,0 @@
|
|||
/*
|
||||
* This is a programm to translate latin letters to morse or written morse or backwards.
|
||||
*
|
||||
* Marcel Michael Kapfer
|
||||
*
|
||||
* GPL v3.0
|
||||
*
|
||||
* 2014
|
||||
*
|
||||
* Version: 0.99 beta
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package morse;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Morse extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4342211364299252760L;
|
||||
private JPanel contentPane;
|
||||
private JTextArea tfOutput;
|
||||
private JTextArea tfInput;
|
||||
private JRadioButton rdbtnwmll;
|
||||
private JRadioButton rdbtnllwm;
|
||||
private JRadioButton rdbtnmll;
|
||||
private JRadioButton rdbtnllm;
|
||||
private JButton btnConvert;
|
||||
private JButton btnSelectInput;
|
||||
private final ButtonGroup buttonGroup = new ButtonGroup();
|
||||
private JCheckBoxMenuItem chckbxmntmClipboardAutomatic;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Morse frame = new Morse();
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Morse() {
|
||||
setResizable(false);
|
||||
setTitle("Morse Converter");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 792, 420);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.setBorderPainted(false);
|
||||
menuBar.setBounds(0, 0, 820, 21);
|
||||
contentPane.add(menuBar);
|
||||
|
||||
JMenu mnMain = new JMenu("Main Menu");
|
||||
menuBar.add(mnMain);
|
||||
|
||||
JMenuItem mntmAbout = new JMenuItem("About");
|
||||
mntmAbout.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
About.main(null);
|
||||
}
|
||||
});
|
||||
mnMain.add(mntmAbout);
|
||||
|
||||
JMenuItem mntmBug = new JMenuItem("Bug");
|
||||
mnMain.add(mntmBug);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmHowTo = new JMenuItem("How to");
|
||||
mnMain.add(mntmHowTo);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
|
||||
mnMain.add(mntmMissingCode);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenu mnClipboard = new JMenu("Clipboard");
|
||||
menuBar.add(mnClipboard);
|
||||
|
||||
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
|
||||
mnClipboard.add(mntnPaste);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
|
||||
mnClipboard.add(mntmCopy);
|
||||
//TODO add jDialog and event listner
|
||||
|
||||
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
|
||||
"Copy automatically into Clipboard");
|
||||
mnClipboard.add(chckbxmntmClipboardAutomatic);
|
||||
|
||||
JScrollPane scrollPaneInput = new JScrollPane();
|
||||
scrollPaneInput.setBounds(12, 60, 758, 140);
|
||||
contentPane.add(scrollPaneInput);
|
||||
|
||||
tfInput = new JTextArea();
|
||||
scrollPaneInput.setViewportView(tfInput);
|
||||
tfInput.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
ChooseProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
});
|
||||
tfInput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuIp = new JPopupMenu();
|
||||
addPopup(tfInput, popupMenuIp);
|
||||
|
||||
JMenuItem mntmIpPaste = new JMenuItem("Paste from Clipboard");
|
||||
mntmIpPaste.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onPaste(tfInput);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpPaste);
|
||||
|
||||
JMenuItem mntnIpSelect = new JMenuItem("Select text");
|
||||
mntnIpSelect.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.selectAll();
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntnIpSelect);
|
||||
|
||||
JMenuItem mntmIpDelete = new JMenuItem("Delete text");
|
||||
mntmIpDelete.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.setText(null);
|
||||
}
|
||||
});
|
||||
popupMenuIp.add(mntmIpDelete);
|
||||
|
||||
JLabel lblEnterYourText = new JLabel("Enter your text:");
|
||||
lblEnterYourText.setBounds(10, 33, 111, 15);
|
||||
contentPane.add(lblEnterYourText);
|
||||
|
||||
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
|
||||
buttonGroup.add(rdbtnwmll);
|
||||
rdbtnwmll.setBounds(12, 208, 250, 23);
|
||||
contentPane.add(rdbtnwmll);
|
||||
|
||||
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
|
||||
buttonGroup.add(rdbtnllwm);
|
||||
rdbtnllwm.setBounds(266, 208, 250, 23);
|
||||
contentPane.add(rdbtnllwm);
|
||||
|
||||
rdbtnmll = new JRadioButton("Morse to Latin Letters");
|
||||
buttonGroup.add(rdbtnmll);
|
||||
rdbtnmll.setBounds(12, 235, 250, 23);
|
||||
contentPane.add(rdbtnmll);
|
||||
|
||||
rdbtnllm = new JRadioButton("Latin Letters to Morse");
|
||||
buttonGroup.add(rdbtnllm);
|
||||
rdbtnllm.setBounds(266, 235, 250, 23);
|
||||
contentPane.add(rdbtnllm);
|
||||
|
||||
btnConvert = new JButton("Convert");
|
||||
btnConvert.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ChooseProcess();
|
||||
}
|
||||
});
|
||||
btnConvert.setBounds(612, 218, 160, 25);
|
||||
contentPane.add(btnConvert);
|
||||
|
||||
JScrollPane scrollPaneOutput = new JScrollPane();
|
||||
scrollPaneOutput.setBounds(12, 266, 758, 140);
|
||||
contentPane.add(scrollPaneOutput);
|
||||
|
||||
tfOutput = new JTextArea();
|
||||
scrollPaneOutput.setViewportView(tfOutput);
|
||||
tfOutput.setEditable(false);
|
||||
tfOutput.setLineWrap(true);
|
||||
|
||||
JPopupMenu popupMenuOp = new JPopupMenu();
|
||||
addPopup(tfOutput, popupMenuOp);
|
||||
|
||||
JMenuItem mntmOpClipboardCopy = new JMenuItem("Copy into Clipboard");
|
||||
mntmOpClipboardCopy.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
});
|
||||
popupMenuOp.add(mntmOpClipboardCopy);
|
||||
|
||||
JMenuItem mntmOpSelect = new JMenuItem("Select Text");
|
||||
popupMenuOp.add(mntmOpSelect);
|
||||
//TODO add right click popup menu
|
||||
|
||||
btnSelectInput = new JButton("Select Input Text");
|
||||
btnSelectInput.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfInput.requestFocus();
|
||||
tfInput.selectAll();
|
||||
btnSelectInput.setVisible(false);
|
||||
}
|
||||
});
|
||||
btnSelectInput.setBounds(612, 28, 158, 25);
|
||||
btnSelectInput.setVisible(false);
|
||||
contentPane.add(btnSelectInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* Choose the convert process
|
||||
*/
|
||||
private void ChooseProcess() {
|
||||
if (rdbtnwmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllwm.isSelected()) {
|
||||
LlWm();
|
||||
} else if (rdbtnmll.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else if (rdbtnllm.isSelected()) {
|
||||
tfOutput.setText("Process not available");
|
||||
// TODO Add function
|
||||
} else {
|
||||
tfOutput.setText("Please select a convert process");
|
||||
rdbtnwmll.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tasks to do after the converting process
|
||||
*/
|
||||
private void After() {
|
||||
tfOutput.selectAll();
|
||||
btnSelectInput.setVisible(true);
|
||||
if (chckbxmntmClipboardAutomatic.isSelected()) {
|
||||
onCopy(tfOutput);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code for converting latin letters into written morse
|
||||
*/
|
||||
private void LlWm() {
|
||||
// Variables
|
||||
StringBuffer input = new StringBuffer();
|
||||
input = input.replace(0, input.length(), tfInput.getText()
|
||||
.toUpperCase());
|
||||
StringBuffer output = new StringBuffer();
|
||||
if (input.toString().equals("")) {
|
||||
tfOutput.setText("Please enter at least one character");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTERSPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("END OF WORK")) {
|
||||
tfOutput.setText("000101");
|
||||
After();
|
||||
} else if (input.toString().equals("ERROR")) {
|
||||
tfOutput.setText("00000000");
|
||||
After();
|
||||
} else if (input.toString().equals("STARTING SIGNAL")) {
|
||||
tfOutput.setText("10101");
|
||||
After();
|
||||
} else if (input.toString().equals("ENDING SIGNAL")) {
|
||||
tfOutput.setText("01010");
|
||||
After();
|
||||
} else if (input.toString().equals("UNDERSTOOD")) {
|
||||
tfOutput.setText("00010");
|
||||
After();
|
||||
} else if (input.toString().equals("WAIT")) {
|
||||
tfOutput.setText("01000");
|
||||
After();
|
||||
} else if (input.toString().equals("SOS")) {
|
||||
tfOutput.setText("000111000");
|
||||
After();
|
||||
} else if (input.toString().equals("LETTER SPACE")) {
|
||||
tfOutput.setText("#");
|
||||
After();
|
||||
} else if (input.toString().equals("WORD SPACE")) {
|
||||
tfOutput.setText("+");
|
||||
After();
|
||||
} else {
|
||||
for (int c = input.length(); c > 0; c--) {
|
||||
if (input.toString().startsWith(" ")) {
|
||||
if (output.toString().endsWith("#")) {
|
||||
output.delete((output.length() - 1), output.length());
|
||||
}
|
||||
output.append("+");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("\n")) {
|
||||
output.append("\n");
|
||||
} else if (input.toString().startsWith("A")) {
|
||||
output.append("01#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("B")) {
|
||||
output.append("1000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("C")) {
|
||||
output.append("1010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("D")) {
|
||||
output.append("100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("E")) {
|
||||
output.append("0#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("F")) {
|
||||
output.append("0010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("G")) {
|
||||
output.append("110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("H")) {
|
||||
output.append("0000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("I")) {
|
||||
output.append("00#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("J")) {
|
||||
output.append("0111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("K")) {
|
||||
output.append("101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("L")) {
|
||||
output.append("0100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("M")) {
|
||||
output.append("11#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("N")) {
|
||||
output.append("10#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("O")) {
|
||||
output.append("111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("P")) {
|
||||
output.append("0110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Q")) {
|
||||
output.append("1101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("R")) {
|
||||
output.append("010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("S")) {
|
||||
output.append("000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("T")) {
|
||||
output.append("1#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("U")) {
|
||||
output.append("001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("V")) {
|
||||
output.append("0001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("W")) {
|
||||
output.append("011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("X")) {
|
||||
output.append("1001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Y")) {
|
||||
output.append("1011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Z")) {
|
||||
output.append("1100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("0")) {
|
||||
output.append("11111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("1")) {
|
||||
output.append("01111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("2")) {
|
||||
output.append("00111#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("3")) {
|
||||
output.append("00011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("4")) {
|
||||
output.append("00001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("5")) {
|
||||
output.append("00000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("6")) {
|
||||
output.append("10000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("7")) {
|
||||
output.append("11000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("8")) {
|
||||
output.append("11100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("9")) {
|
||||
output.append("11110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ä")) {
|
||||
output.append("0101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ö")) {
|
||||
output.append("1110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("Ü")) {
|
||||
output.append("0011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("ß")) {
|
||||
output.append("00011000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(".")) {
|
||||
output.append("010101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(",")) {
|
||||
output.append("110011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(":")) {
|
||||
output.append("111000#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(";")) {
|
||||
output.append("101010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("?")) {
|
||||
output.append("001100#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("!")) {
|
||||
output.append("101011#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("-")) {
|
||||
output.append("100001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("_")) {
|
||||
output.append("001101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("(")) {
|
||||
output.append("10110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith(")")) {
|
||||
output.append("101101#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("=")) {
|
||||
output.append("10001#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("+")) {
|
||||
output.append("01010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("/")) {
|
||||
output.append("10010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("@")) {
|
||||
output.append("011010#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("'")) {
|
||||
output.append("011110#");
|
||||
input.delete(0, 1);
|
||||
} else if (input.toString().startsWith("$")) {
|
||||
output.append("0001001#");
|
||||
input.delete(0, 1);
|
||||
} else {
|
||||
tfOutput.setText("Code not listed or wrong.");
|
||||
}
|
||||
}
|
||||
tfOutput.setText(output.delete(output.length() - 1, output.length())
|
||||
.toString());
|
||||
After();
|
||||
}
|
||||
}
|
||||
private static void addPopup(Component component, final JPopupMenu popup) {
|
||||
component.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
showMenu(e);
|
||||
}
|
||||
}
|
||||
private void showMenu(MouseEvent e) {
|
||||
popup.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void onPaste(JTextArea tf){
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable t = c.getContents(this);
|
||||
if (t == null)
|
||||
return;
|
||||
try {
|
||||
tf.setText((String) t.getTransferData(DataFlavor.stringFlavor));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}//try
|
||||
}//onPaste
|
||||
private void onCopy(JTextArea tf){
|
||||
StringSelection selection = new StringSelection(tf.getText());
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package morse;
|
||||
|
||||
import javax.swing.JApplet;
|
||||
|
||||
public class MorseApplet extends JApplet {
|
||||
|
||||
/**
|
||||
* Create the applet.
|
||||
*/
|
||||
public MorseApplet() {
|
||||
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +0,0 @@
|
|||
|
Binary file not shown.
|
@ -1 +0,0 @@
|
|||
|
Binary file not shown.
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
com.android.ide.eclipse.adt.fixLegacyEditors=1
|
||||
com.android.ide.eclipse.adt.sdk=/home/mmk/android-sdks
|
||||
eclipse.preferences.version=1
|
|
@ -1,8 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
logcat.view.colsize.Application=147
|
||||
logcat.view.colsize.Level=22
|
||||
logcat.view.colsize.PID=50
|
||||
logcat.view.colsize.TID=50
|
||||
logcat.view.colsize.Tag=112
|
||||
logcat.view.colsize.Text=581
|
||||
logcat.view.colsize.Time=139
|
|
@ -1,2 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.cdt.debug.core.cDebug.default_source_containers=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\n<sourceLookupDirector>\n<sourceContainers duplicates\="false">\n<container memento\="AbsolutePath" typeId\="org.eclipse.cdt.debug.core.containerType.absolutePath"/>\n<container memento\="programRelativePath" typeId\="org.eclipse.cdt.debug.core.containerType.programRelativePath"/>\n<container memento\="<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>&\#10;<project referencedProjects\="true"/>&\#10;" typeId\="org.eclipse.cdt.debug.core.containerType.project"/>\n</sourceContainers>\n</sourceLookupDirector>\n
|
|
@ -1,7 +0,0 @@
|
|||
columnOrderKeyEXE=0,1,2,3,4,5
|
||||
columnOrderKeySF=0,1,2,3,4,5
|
||||
columnSortDirectionKeyEXE=128
|
||||
columnSortDirectionKeySF=128
|
||||
eclipse.preferences.version=1
|
||||
visibleColumnsKeyEXE=1,1,1,0,0,0
|
||||
visibleColumnsKeySF=1,1,0,0,0,0
|
|
@ -1,4 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
spelling_locale_initialized=true
|
||||
useAnnotationsPrefPage=true
|
||||
useQuickDiffPrefPage=true
|
|
@ -1,2 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
version=1
|
|
@ -1,6 +0,0 @@
|
|||
//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.applicationLaunchType=org.eclipse.cdt.dsf.gdb.launch.localCLaunch,debug,;org.eclipse.cdt.cdi.launch.localCLaunch,run,;
|
||||
//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.attachLaunchType=org.eclipse.cdt.dsf.gdb.launch.attachCLaunch,debug,;
|
||||
//org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.postmortemLaunchType=org.eclipse.cdt.dsf.gdb.launch.coreCLaunch,debug,;
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.debug.core.PREF_BREAKPOINT_MANAGER_ENABLED_STATE=true
|
||||
org.eclipse.debug.core.USE_STEP_FILTERS=true
|
|
@ -1,7 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\n<launchPerspectives/>\n
|
||||
pref_state_memento.org.eclipse.debug.ui.BreakpointView=<?xml version\="1.0" encoding\="UTF-8"?>\n<VariablesViewMemento org.eclipse.debug.ui.SASH_DETAILS_PART\="315" org.eclipse.debug.ui.SASH_VIEW_PART\="684">\n<PRESENTATION_CONTEXT_PROPERTIES IMemento.internal.id\="org.eclipse.debug.ui.BreakpointView">\n<BOOLEAN BOOLEAN\="true" IMemento.internal.id\="org.eclipse.debug.ui.check"/>\n</PRESENTATION_CONTEXT_PROPERTIES>\n</VariablesViewMemento>
|
||||
pref_state_memento.org.eclipse.debug.ui.DebugVieworg.eclipse.debug.ui.DebugView=<?xml version\="1.0" encoding\="UTF-8"?>\n<DebugViewMemento org.eclipse.debug.ui.BREADCRUMB_DROPDOWN_AUTO_EXPAND\="false"/>
|
||||
pref_state_memento.org.eclipse.debug.ui.VariableView=<?xml version\="1.0" encoding\="UTF-8"?>\n<VariablesViewMemento org.eclipse.debug.ui.SASH_DETAILS_PART\="312" org.eclipse.debug.ui.SASH_VIEW_PART\="670">\n<COLUMN_SIZES IMemento.internal.id\="org.eclipse.debug.ui.VARIALBE_COLUMN_PRESENTATION.COL_VAR_VALUE" SIZE\="359"/>\n<COLUMN_SIZES IMemento.internal.id\="org.eclipse.debug.ui.VARIALBE_COLUMN_PRESENTATION.COL_VAR_NAME" SIZE\="313"/>\n<PRESENTATION_CONTEXT_PROPERTIES IMemento.internal.id\="org.eclipse.debug.ui.VariableView"/>\n</VariablesViewMemento>
|
||||
preferredDetailPanes=DefaultDetailPane\:DefaultDetailPane|
|
||||
preferredTargets=default\:default|
|
|
@ -1,2 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
themeid=org.eclipse.e4.ui.css.theme.e4_dark
|
|
@ -1,8 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
|
@ -1,2 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.launching.PREF_VM_XML=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\n<vmSettings defaultVM\="57,org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType13,1411061758344" defaultVMConnector\="">\n<vmType id\="org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType">\n<vm id\="1411061758344" name\="java-8-jdk" path\="/usr/lib/jvm/java-8-jdk"/>\n</vmType>\n</vmSettings>\n
|
|
@ -1,29 +0,0 @@
|
|||
content_assist_lru_history=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><history maxLHS\="100" maxRHS\="10"/>
|
||||
content_assist_number_of_computers=13
|
||||
content_assist_proposals_background=249,249,249
|
||||
content_assist_proposals_foreground=51,51,51
|
||||
eclipse.preferences.version=1
|
||||
fontPropagated=true
|
||||
org.eclipse.jdt.ui.editor.tab.width=
|
||||
org.eclipse.jdt.ui.formatterprofiles.version=12
|
||||
org.eclipse.jdt.ui.javadoclocations.migrated=true
|
||||
org.eclipse.jdt.ui.text.code_templates_migrated=true
|
||||
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
|
||||
org.eclipse.jdt.ui.text.custom_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
|
||||
org.eclipse.jdt.ui.text.templates_migrated=true
|
||||
org.eclipse.jface.textfont=1|Monospace|10.0|0|GTK|1|;
|
||||
proposalOrderMigrated=true
|
||||
spelling_ignore_ampersand_in_properties=true
|
||||
spelling_ignore_digits=true
|
||||
spelling_ignore_java_strings=true
|
||||
spelling_ignore_mixed=true
|
||||
spelling_ignore_non_letters=true
|
||||
spelling_ignore_sentence=true
|
||||
spelling_ignore_single_letters=true
|
||||
spelling_ignore_upper=true
|
||||
spelling_ignore_urls=true
|
||||
spelling_locale_initialized=true
|
||||
spelling_user_dictionary_encoding=
|
||||
tabWidthPropagated=true
|
||||
useAnnotationsPrefPage=true
|
||||
useQuickDiffPrefPage=true
|
|
@ -1,2 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
knownEEFragments=
|
|
@ -1,2 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
workspace_target_handle=local\:1411288348674.target
|
|
@ -1,2 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.team.ui.first_time=false
|
|
@ -1,3 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
overviewRuler_migration=migrated_3.1
|
||||
spellingEngine=org.eclipse.jdt.internal.ui.text.spelling.DefaultSpellingEngine
|
|
@ -1,6 +0,0 @@
|
|||
PROBLEMS_FILTERS_MIGRATE=true
|
||||
TASKS_FILTERS_MIGRATE=true
|
||||
eclipse.preferences.version=1
|
||||
platformState=1412541408722
|
||||
quickStart=false
|
||||
tipsAndTricks=true
|
|
@ -1,2 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
showIntro=false
|
|
@ -1,2 +0,0 @@
|
|||
ENABLED_DECORATORS=com.android.ide.eclipse.adt.project.FolderDecorator\:true,org.eclipse.cdt.ui.indexedFiles\:false,org.eclipse.cdt.managedbuilder.ui.excludedFile\:true,org.eclipse.cdt.managedbuilder.ui.includeFolder\:true,org.eclipse.cdt.internal.ui.CustomBuildSettingsDecorator\:true,org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator\:true,org.eclipse.jdt.ui.override.decorator\:true,org.eclipse.jdt.ui.interface.decorator\:false,org.eclipse.jdt.ui.buildpath.decorator\:true,org.eclipse.pde.ui.binaryProjectDecorator\:false,org.eclipse.team.cvs.ui.decorator\:false,org.eclipse.ui.LinkedResourceDecorator\:true,org.eclipse.ui.SymlinkDecorator\:true,org.eclipse.ui.VirtualResourceDecorator\:true,org.eclipse.ui.ContentTypeDecorator\:true,org.eclipse.ui.ResourceFilterDecorator\:false,
|
||||
eclipse.preferences.version=1
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/Morse/src/morse/About.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="morse.About"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Morse"/>
|
||||
</launchConfiguration>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/Morse/src/morse/Bug.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="morse.Bug"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Morse"/>
|
||||
</launchConfiguration>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/Morse/src/morse/DecodeWrittenMorse.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="morse.DecodeWrittenMorse"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Morse"/>
|
||||
</launchConfiguration>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/Morse/src/morse/EncodeWrittenMorse.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="morse.EncodeWrittenMorse"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Morse"/>
|
||||
</launchConfiguration>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/Morse/src/morse/HowTo.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="morse.HowTo"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Morse"/>
|
||||
</launchConfiguration>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/Morse/src/morse/MissingCode.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="morse.MissingCode"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Morse"/>
|
||||
</launchConfiguration>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/Morse/src/morse/Morse.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="morse.Morse"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Morse"/>
|
||||
</launchConfiguration>
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.javaApplet">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/Morse/src/morseapplet/MorseApplet.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<intAttribute key="org.eclipse.jdt.launching.APPLET_HEIGHT" value="200"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.APPLET_NAME" value=""/>
|
||||
<intAttribute key="org.eclipse.jdt.launching.APPLET_WIDTH" value="200"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="morseapplet.MorseApplet"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Morse"/>
|
||||
</launchConfiguration>
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<section name="Workbench">
|
||||
<section name="org.eclipse.debug.ui.SCOPED_SAVE_SELECTION_DIALOG">
|
||||
<item value="279" key="DIALOG_WIDTH"/>
|
||||
<item value="1|Roboto|10.0|0|GTK|1|" key="DIALOG_FONT_NAME"/>
|
||||
<item value="328" key="DIALOG_HEIGHT"/>
|
||||
</section>
|
||||
<section name="org.eclipse.debug.ui.LAUNCH_CONFIGURATIONS_DIALOG_SECTION">
|
||||
<item value="800" key="DIALOG_WIDTH"/>
|
||||
<item value="1|Roboto|10.0|0|GTK|1|" key="DIALOG_FONT_NAME"/>
|
||||
<item value=", " key="org.eclipse.debug.ui.EXPANDED_NODES"/>
|
||||
<item value="762" key="org.eclipse.debug.ui.DIALOG_SASH_WEIGHTS_2"/>
|
||||
<item value="616" key="DIALOG_HEIGHT"/>
|
||||
<item value="237" key="org.eclipse.debug.ui.DIALOG_SASH_WEIGHTS_1"/>
|
||||
</section>
|
||||
</section>
|
|
@ -1,37 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchHistory>
|
||||
<launchGroup id="org.eclipse.debug.ui.launchGroup.debug">
|
||||
<mruHistory>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="Morse"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="MorseApplet"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="About"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="Bug"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="HowTo"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="MissingCode"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="DecodeWrittenMorse"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="EncodeWrittenMorse"/> "/>
|
||||
</mruHistory>
|
||||
<favorites/>
|
||||
</launchGroup>
|
||||
<launchGroup id="org.eclipse.debug.ui.launchGroup.profile">
|
||||
<mruHistory/>
|
||||
<favorites/>
|
||||
</launchGroup>
|
||||
<launchGroup id="org.eclipse.ui.externaltools.launchGroup">
|
||||
<mruHistory/>
|
||||
<favorites/>
|
||||
</launchGroup>
|
||||
<launchGroup id="org.eclipse.debug.ui.launchGroup.run">
|
||||
<mruHistory>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="Morse"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="MorseApplet"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="About"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="Bug"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="HowTo"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="MissingCode"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="DecodeWrittenMorse"/> "/>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="EncodeWrittenMorse"/> "/>
|
||||
</mruHistory>
|
||||
<favorites/>
|
||||
</launchGroup>
|
||||
</launchHistory>
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue