Fixed BUG0001

This commit is contained in:
mmk2410 2015-01-02 19:57:22 +01:00
parent f147ec1d72
commit 36ca7f81d3

View file

@ -17,7 +17,6 @@ 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;
@ -86,23 +85,18 @@ public class Morse extends JFrame {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 792, 443);
contentPane = new JPanel();
contentPane.setBackground(new Color(255, 255, 255));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JMenuBar menuBar = new JMenuBar();
menuBar.setBackground(new Color(51, 102, 255));
menuBar.setBorderPainted(false);
menuBar.setBounds(0, 0, 820, 21);
contentPane.add(menuBar);
JMenu mnMain = new JMenu("Main Menu");
mnMain.setBackground(new Color(255, 255, 255));
menuBar.add(mnMain);
JMenuItem mntmAbout = new JMenuItem("About");
mntmAbout.setBackground(new Color(255, 255, 255));
mntmAbout.setToolTipText("Information about the Software");
mntmAbout.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@ -112,7 +106,6 @@ public class Morse extends JFrame {
mnMain.add(mntmAbout);
JMenuItem mntmBug = new JMenuItem("Bug");
mntmBug.setBackground(new Color(255, 255, 255));
mntmBug.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Bug.main(null);
@ -122,7 +115,6 @@ public class Morse extends JFrame {
mnMain.add(mntmBug);
JMenuItem mntmHowTo = new JMenuItem("How to");
mntmHowTo.setBackground(new Color(255, 255, 255));
mntmHowTo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
HowTo.main(null);
@ -131,13 +123,11 @@ public class Morse extends JFrame {
mntmHowTo.setToolTipText("Information about how to use the software");
mnMain.add(mntmHowTo);
JMenuItem mntmMissingCode = new JMenuItem("Missing Code");
mntmMissingCode.setBackground(new Color(255, 255, 255));
mntmMissingCode
.setToolTipText("Information about handling a missing code");
mnMain.add(mntmMissingCode);
JMenuItem mntmExit = new JMenuItem("Exit");
mntmExit.setBackground(new Color(255, 255, 255));
mntmExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
@ -152,11 +142,9 @@ public class Morse extends JFrame {
});
JMenu mnClipboard = new JMenu("Clipboard");
mnClipboard.setBackground(new Color(255, 255, 255));
menuBar.add(mnClipboard);
JMenuItem mntnPaste = new JMenuItem("Paste from Clipboard");
mntnPaste.setBackground(new Color(255, 255, 255));
mntnPaste
.setToolTipText("Paste the text from your Clipboard into the input field");
mntnPaste.addActionListener(new ActionListener() {
@ -167,7 +155,6 @@ public class Morse extends JFrame {
mnClipboard.add(mntnPaste);
JMenuItem mntmCopy = new JMenuItem("Copy into Clipboard");
mntmCopy.setBackground(new Color(255, 255, 255));
mntmCopy.setToolTipText("Copy the text from the output field into your clipboard");
mntmCopy.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@ -178,7 +165,6 @@ public class Morse extends JFrame {
chckbxmntmClipboardAutomatic = new JCheckBoxMenuItem(
"Copy automatically into Clipboard");
chckbxmntmClipboardAutomatic.setBackground(new Color(255, 255, 255));
chckbxmntmClipboardAutomatic
.setToolTipText("Copy the text form the output field automatically into your clipboard");
mnClipboard.add(chckbxmntmClipboardAutomatic);
@ -241,12 +227,10 @@ public class Morse extends JFrame {
popupMenuIp.add(mntmIpDelete);
JLabel lblEnterYourText = new JLabel("Enter your text:");
lblEnterYourText.setBackground(new Color(255, 255, 255));
lblEnterYourText.setBounds(10, 33, 111, 15);
contentPane.add(lblEnterYourText);
rdbtnwmll = new JRadioButton("writtenMorse to Latin Letters");
rdbtnwmll.setBackground(new Color(255, 255, 255));
rdbtnwmll
.setToolTipText("Convert writtenMorse into normal latin letters");
buttonGroup.add(rdbtnwmll);
@ -254,7 +238,6 @@ public class Morse extends JFrame {
contentPane.add(rdbtnwmll);
rdbtnllwm = new JRadioButton("Latin Letters to writtenMorse");
rdbtnllwm.setBackground(new Color(255, 255, 255));
rdbtnllwm
.setToolTipText("Convert normal latin letters into writtenMorse");
buttonGroup.add(rdbtnllwm);
@ -262,22 +245,18 @@ public class Morse extends JFrame {
contentPane.add(rdbtnllwm);
rdbtnmll = new JRadioButton("Morse to Latin Letters");
rdbtnmll.setBackground(new Color(255, 255, 255));
rdbtnmll.setToolTipText("Convert normal morse code into normal latin letters");
buttonGroup.add(rdbtnmll);
rdbtnmll.setBounds(12, 235, 250, 23);
contentPane.add(rdbtnmll);
rdbtnllm = new JRadioButton("Latin Letters to Morse");
rdbtnllm.setBackground(new Color(255, 255, 255));
rdbtnllm.setToolTipText("convert normal latin letters into normal morse code");
buttonGroup.add(rdbtnllm);
rdbtnllm.setBounds(266, 235, 250, 23);
contentPane.add(rdbtnllm);
btnConvert = new JButton("Convert");
btnConvert.setForeground(new Color(255, 255, 255));
btnConvert.setBackground(new Color(51, 102, 255));
btnConvert
.setToolTipText("Convert the insert text to the choosen code");
btnConvert.addActionListener(new ActionListener() {
@ -319,8 +298,6 @@ public class Morse extends JFrame {
popupMenuOp.add(mntmOpSelect);
btnSelectInput = new JButton("Select Input Text");
btnSelectInput.setForeground(new Color(255, 255, 255));
btnSelectInput.setBackground(new Color(51, 102, 255));
btnSelectInput.setToolTipText("Select the whole text of the input box");
btnSelectInput.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@ -411,6 +388,9 @@ public class Morse extends JFrame {
} 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("A")) {
@ -585,9 +565,8 @@ public class Morse extends JFrame {
tfOutput.setText("Code not listed or wrong.");
}
}
if (output.toString().endsWith("#")
&& (output.toString().equals("#") == false)) {
output.delete(output.length() - 1, output.length());
if(output.toString().endsWith("#")){
output.delete(output.length() -1 , output.length());
}
tfOutput.setText(output.toString());
After();
@ -987,9 +966,8 @@ public class Morse extends JFrame {
tfOutput.setText("Code not listed or wrong.");
}
}
if (output.toString().endsWith(" ")
&& (output.toString().equals(" ") == false)) {
output.delete(output.length() - 3, output.length());
if(output.toString().endsWith(" ")){
output.delete(output.length() - 3 , output.length());
}
tfOutput.setText(output.toString());
After();