Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Group project code
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
marc.sheppard
Group project code
Commits
201e91ff
Commit
201e91ff
authored
Nov 21, 2019
by
marc.sheppard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
3510724a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
0 deletions
+93
-0
GUI.java
GUI.java
+93
-0
No files found.
GUI.java
0 → 100644
View file @
201e91ff
import
java.awt.Panel
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
javax.swing.JButton
;
import
javax.swing.JFrame
;
import
javax.swing.JLabel
;
import
javax.swing.JTextArea
;
import
javax.swing.JTextField
;
/**
* GUI code
*
* @author Marc.
* Created 17 Nov 2019.
*/
public
class
GUI
{
private
int
input_language
=
0
,
output_language
=
0
;
private
JFrame
frame
=
new
JFrame
(
"GUI"
);
private
Panel
panel
=
new
Panel
();
private
JLabel
input_label
=
new
JLabel
(
"Input languge"
);
private
JLabel
output_label
=
new
JLabel
(
"output languge"
);
private
JLabel
in_label
=
new
JLabel
(
"In:"
);
private
JLabel
out_label
=
new
JLabel
(
"out:"
);
private
JButton
input_english_button
=
new
JButton
(
"English"
);
private
JButton
input_french_button
=
new
JButton
(
"French"
);
private
JButton
input_german_button
=
new
JButton
(
"German"
);
private
JButton
output_english_button
=
new
JButton
(
"English"
);
private
JButton
output_french_button
=
new
JButton
(
"French"
);
private
JButton
output_german_button
=
new
JButton
(
"German"
);
private
JTextField
input_textbox
=
new
JTextField
(
12
);
private
JTextArea
output_text
=
new
JTextArea
(
1
,
12
);
public
GUI
()
{
//setup window
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
setSize
(
350
,
150
);
panel
.
add
(
input_label
);
panel
.
add
(
input_english_button
);
panel
.
add
(
input_french_button
);
panel
.
add
(
input_german_button
);
panel
.
add
(
output_label
);
panel
.
add
(
output_english_button
);
panel
.
add
(
output_french_button
);
panel
.
add
(
output_german_button
);
panel
.
add
(
in_label
);
panel
.
add
(
input_textbox
);
panel
.
add
(
out_label
);
panel
.
add
(
output_text
);
frame
.
add
(
panel
);
frame
.
setVisible
(
true
);
//what the buttons do when pressed
input_english_button
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
input_language
=
0
;
}
});
input_french_button
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
input_language
=
1
;
}
});
input_german_button
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
input_language
=
2
;
}
});
output_english_button
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
output_language
=
0
;
}
});
output_french_button
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
output_language
=
1
;
}
});
output_german_button
.
addActionListener
(
new
ActionListener
()
{
public
void
actionPerformed
(
ActionEvent
e
)
{
output_language
=
2
;
}
});
}
//update output text
public
void
updateText
(
String
text
)
{
output_text
.
setText
(
text
);
}
//returns text typed into textbox
public
String
getTextInput
()
{
return
input_textbox
.
getText
();
}
//returns an int corresponding to the input language (0 = English, 1 = French, 2 = German)
public
int
getInputLanguage
()
{
return
input_language
;
}
//returns an int corresponding to the output language (0 = English, 1 = French, 2 = German)
public
int
getOutputLanguage
()
{
return
output_language
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment