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