diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 00cab75..ead862e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -9,13 +9,9 @@ - - - - - + + - @@ -45,29 +41,46 @@ - - - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + - - + + - + @@ -81,7 +94,17 @@ - + + + + + + + + + + + @@ -136,16 +159,6 @@ - - - - - - - - - - @@ -183,12 +196,12 @@ @@ -207,8 +220,9 @@ - @@ -233,7 +247,7 @@ - + @@ -283,30 +297,8 @@ - - - - - - - - - - - - @@ -328,18 +320,36 @@ + - - + @@ -352,6 +362,8 @@ + + @@ -579,36 +591,42 @@ - - + + + + - + + + - - - - @@ -630,7 +648,10 @@ - @@ -708,17 +729,6 @@ - - - - - - - - - - - @@ -737,7 +747,27 @@ - + + + + + + + + + + + + + + + + + + + + + @@ -799,7 +829,27 @@ - + + + + + + + + + + + + + + + + + + + + + @@ -864,7 +914,27 @@ - + + + + + + + + + + + + + + + + + + + + + @@ -926,7 +996,27 @@ - + + + + + + + + + + + + + + + + + + + + + @@ -984,23 +1074,9 @@ - - - - - - - - - - - - - - @@ -1058,6 +1134,24 @@ + + + + + + + + + + + + + + + + + + @@ -1065,7 +1159,18 @@ - + + + + + + + + + + + + @@ -1074,21 +1179,41 @@ - - - + + + - + - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/de/marcelkapfer/c/morseconverter/Main.java b/src/de/marcelkapfer/c/morseconverter/Main.java index 03fd24f..282a87e 100755 --- a/src/de/marcelkapfer/c/morseconverter/Main.java +++ b/src/de/marcelkapfer/c/morseconverter/Main.java @@ -36,17 +36,18 @@ import javax.swing.text.Element; import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.HTMLEditorKit; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.event.*; import java.io.IOException; import java.util.ResourceBundle; public class Main extends JFrame { // Version numbers for update check - public static final int currentVersion = 193; + public static final int currentVersion = 200; public static int latestVersion = currentVersion; public static ResourceBundle resourceBundle = ResourceBundle.getBundle("de.marcelkapfer.c.morseconverter.text"); @@ -102,6 +103,153 @@ public class Main extends JFrame { } }); + + // Mouse listener for selecting text on left click in output text area + outputAreaWrittenMorse.addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1) { + outputAreaWrittenMorse.requestFocus(); + outputAreaWrittenMorse.selectAll(); + } + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + }); + + outputAreaNormalMorse.addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1) { + outputAreaNormalMorse.requestFocus(); + outputAreaNormalMorse.selectAll(); + } + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + }); + + // Popup Menus + + // Popup Menu for writtenMorse input text field + + JPopupMenu wInputPopup = new JPopupMenu(); + addPopup(inputAreaWrittenMorse, wInputPopup); + + // Item for paste + JMenuItem pasteWInput = new JMenuItem(resourceBundle.getString("paste")); + pasteWInput.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + onPaste(inputAreaWrittenMorse); + instantWrittenMorseConvert(); + } + }); + wInputPopup.add(pasteWInput); + + // Item for clear + JMenuItem clearWInput = new JMenuItem(resourceBundle.getString("clear")); + clearWInput.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + clear(inputAreaWrittenMorse); + } + }); + wInputPopup.add(clearWInput); + + // Popup Menu for writtenMorse output text field + JPopupMenu wOutputPopup = new JPopupMenu(); + addPopup(outputAreaWrittenMorse, wOutputPopup); + + // Item for copy + JMenuItem copyWOutput = new JMenuItem(resourceBundle.getString("copy")); + copyWOutput.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + onCopy(outputAreaWrittenMorse); + } + }); + wOutputPopup.add(copyWOutput); + + + // Popups for Normal Morse + + // Popup for Normal Morse input text field + JPopupMenu nInputMenu = new JPopupMenu(); + addPopup(inputAreaNormalMorse, nInputMenu); + + // Item for paste + JMenuItem nPasteInput = new JMenuItem(resourceBundle.getString("paste")); + nPasteInput.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + onPaste(inputAreaNormalMorse); + instantNormalMorseConvert(); + } + }); + nInputMenu.add(nPasteInput); + + // Item for clear + JMenuItem nClearInput = new JMenuItem(resourceBundle.getString("clear")); + nClearInput.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + clear(inputAreaNormalMorse); + } + }); + nInputMenu.add(nClearInput); + + // Popup for output text field + + JPopupMenu nOutputMenu = new JPopupMenu(); + addPopup(outputAreaNormalMorse, nOutputMenu); + + // Menü item for copy + JMenuItem nCopyOutput = new JMenuItem(resourceBundle.getString("copy")); + nCopyOutput.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + onCopy(outputAreaNormalMorse); + } + }); + nOutputMenu.add(nCopyOutput); + } // The holy main method public static void main(String[] args){ @@ -114,7 +262,7 @@ public class Main extends JFrame { // Starting the application JFrame main = new JFrame("Main"); main.setContentPane(new Main().morseConverterPane); - main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + main.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // Title main.setTitle(resourceBundle.getString("title")); main.pack(); @@ -158,4 +306,55 @@ public class Main extends JFrame { UpdateDialog.main(null); } + 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) { + try { + 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 + } catch (Exception e) { + e.printStackTrace(); + } + }// onPaste + + /* + * Copy function + */ + private void onCopy(JTextArea tf) { + StringSelection selection = new StringSelection(tf.getText()); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(selection, selection); + } + + private void clear(JTextArea jTextArea) { + jTextArea.setText(""); + } } diff --git a/src/de/marcelkapfer/c/morseconverter/text.properties b/src/de/marcelkapfer/c/morseconverter/text.properties index 61aa48e..60a788d 100755 --- a/src/de/marcelkapfer/c/morseconverter/text.properties +++ b/src/de/marcelkapfer/c/morseconverter/text.properties @@ -1,7 +1,10 @@ -about=\n

\nVersion
1.9.3 beta\n

\n

\nDeveloper
Marcel Michael Kapfer\n

\n

\nWebsite
marcel-kapfer.de/writtenmorse\n

\n

\nContact
marcelmichaelkapfer@yahoo.co.nz\n

\n

\nLicense
GNU GPL v3.0\n

\n

\nBug
If you found a bug, please write me a mail to marcelmichaelkapfer@yahoo.co.nz with a short description of the problem.\n

\n

\nHow to
You can find a detailed guide on marcel-kapfer.de/writtenmorse/\#howto_desktop\n

\nMissing Code
If you discovered, that a code is missing, then write me a mail to marcelmichaelkapfer@yahoo.co.nz and tell me about it.\n

\n

\n +about=\n

\nVersion
2.0.0\n

\n

\nDeveloper
Marcel Michael Kapfer\n

\n

\nWebsite
marcel-kapfer.de/writtenmorse\n

\n

\nContact
marcelmichaelkapfer@yahoo.co.nz\n

\n

\nLicense
GNU GPL v3.0\n

\n

\nBug
If you found a bug, please write me a mail to marcelmichaelkapfer@yahoo.co.nz with a short description of the problem.\n

\n

\nHow to
You can find a detailed guide on marcel-kapfer.de/writtenmorse/\#howto_desktop\n

\nMissing Code
If you discovered, that a code is missing, then write me a mail to marcelmichaelkapfer@yahoo.co.nz and tell me about it.\n

\n

\n aboutUpdateAvailable=Update available aboutUpdateAvailableButton=Install Update +clear=Clear +copy=Copy inputText=Enter your text +paste=Paste tabAbout=About tabNormalMorse=Normal Morse title=Morse Converter diff --git a/src/de/marcelkapfer/c/morseconverter/text_de.properties b/src/de/marcelkapfer/c/morseconverter/text_de.properties index b6693af..cc984d8 100755 --- a/src/de/marcelkapfer/c/morseconverter/text_de.properties +++ b/src/de/marcelkapfer/c/morseconverter/text_de.properties @@ -1,7 +1,10 @@ -about=\n

\nVersion
1.9.3 beta\n

\n

\nEntwickler
Marcel Michael Kapfer\n

\n

\nWebsite
marcel-kapfer.de/writtenmorse\n

\n

\nKontakt
marcelmichaelkapfer@yahoo.co.nz\n

\n

\nLizenz
GNU GPL v3.0\n

\n

\nFehler
Wenn Du einen Fehler gefunden hast, schreibe mir bitte ein E-Mail an marcelmichaelkapfer@yahoo.co.nz\n

\n

\nHow to
Du kannst eine ausführliche Anleitung auf marcel-kapfer.de/writtenmorse/\#howto_android finden.\n

\nFehlender Code
Wenn Du auf einen fehlenden Code aufmerksam geworden bist, dann schreibe eine E-Mail an marcelmichaelkapfer@yahoo.co.nz.\n

\n

\n +about=\n

\nVersion
2.0.0\n

\n

\nEntwickler
Marcel Michael Kapfer\n

\n

\nWebsite
marcel-kapfer.de/writtenmorse\n

\n

\nKontakt
marcelmichaelkapfer@yahoo.co.nz\n

\n

\nLizenz
GNU GPL v3.0\n

\n

\nFehler
Wenn Du einen Fehler gefunden hast, schreibe mir bitte ein E-Mail an marcelmichaelkapfer@yahoo.co.nz\n

\n

\nHow to
Du kannst eine ausführliche Anleitung auf marcel-kapfer.de/writtenmorse/\#howto_android finden.\n

\nFehlender Code
Wenn Du auf einen fehlenden Code aufmerksam geworden bist, dann schreibe eine E-Mail an marcelmichaelkapfer@yahoo.co.nz.\n

\n

\n aboutUpdateAvailable=Update verfügbar aboutUpdateAvailableButton=Update installieren +clear=Bereinigen +copy=Kopieren inputText=Geben Sie einen Text ein +paste=Einfügen tabAbout=Über tabNormalMorse=Normales Morse title=Morse Umwandler