java language
Please use the the language of your choice to complete the following problem:
Write a function or procedure that returns a hyphenated string. Valid input will be a string consisting only of alpha characters. Your function or procedure will return an alpha string where the interior letters are joined with a hyphen. For strings containing invalid input (non-alpha characters) please return an empty string (“” in most languages).
Please write a comment in your code to tell us the programming language you choose to use.
Example input:
Test
ou4
it
Example output:
T-e-s-t
i-t
package newpackage;
import javax.swing.JFrame;
/**
*
* @author Kandiman
*/
public class NewJFrame extends JFrame {
/**
* Creates new form NewJFrame
*/
public NewJFrame() {
initComponents();
init();
}
private void init(){
setVisible(true);
setTitle(“Job Test”);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
}
@SuppressWarnings(“unchecked”)
//
private void initComponents() {
txt1Input = new javax.swing.JTextField();
txt2Input = new javax.swing.JTextField();
txt3Input = new javax.swing.JTextField();
txt1Output = new javax.swing.JTextField();
txt2Output = new javax.swing.JTextField();
txt3Output = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
btnDisplayResults = new javax.swing.JButton();
btnClear = new javax.swing.JButton();
btnExit = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
txt1Input.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txt1InputActionPerformed(evt);
}
});
txt1Output.setEnabled(false);
txt1Output.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txt1OutputActionPerformed(evt);
}
});
txt2Output.setEnabled(false);
txt2Output.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txt2OutputActionPerformed(evt);
}
});
txt3Output.setEnabled(false);
jLabel1.setText(“Enter Alpha Characters”);
jLabel1.setMaximumSize(new java.awt.Dimension(138, 14));
jLabel1.setMinimumSize(new java.awt.Dimension(138, 14));
jLabel1.setPreferredSize(new java.awt.Dimension(138, 14));
jLabel1.setVerifyInputWhenFocusTarget(false);
btnDisplayResults.setText(“Display Results”);
btnDisplayResults.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDisplayResultsActionPerformed(evt);
}
});
btnClear.setText(“Clear”);
btnClear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnClearActionPerformed(evt);
}
});
btnExit.setText(“Exit”);
btnExit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnExitActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(53, 53, 53)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txt3Input)
.addComponent(txt1Output, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(txt2Output, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(txt3Output, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(txt1Input)
.addComponent(txt2Input)
.addComponent(btnDisplayResults, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnClear, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnExit, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt1Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txt2Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt3Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnDisplayResults, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txt1Output, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txt2Output, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txt3Output, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(13, 13, 13)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnClear)
.addComponent(btnExit))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}//
private void txt1InputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txt1InputActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txt1InputActionPerformed
private void btnDisplayResultsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDisplayResultsActionPerformed
// TODO add your handling code here:
String text1 = txt1Input.getText();
txt1Output.setText(text1);
String text2 = txt2Input.getText();
txt2Output.setText(text2);
String text3 = txt3Input.getText();
txt3Output.setText(text3);
}//GEN-LAST:event_btnDisplayResultsActionPerformed
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
//Close the application
System.exit(1);
}//GEN-LAST:event_btnExitActionPerformed
private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed
//Clear all text fields and disable the output text fields
txt1Input.setText(“”);
txt2Input.setText(“”);
txt3Input.setText(“”);
txt1Output.setText(“”);
txt2Output.setText(“”);
txt3Output.setText(“”);
}//GEN-LAST:event_btnClearActionPerformed
private void txt2OutputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txt2OutputActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txt2OutputActionPerformed
private void txt1OutputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txt1OutputActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txt1OutputActionPerformed
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if (“Nimbus”.equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
new NewJFrame();
}
// Variables declaration – do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnClear;
private javax.swing.JButton btnDisplayResults;
private javax.swing.JButton btnExit;
private javax.swing.JLabel jLabel1;
private javax.swing.JTextField txt1Input;
private javax.swing.JTextField txt1Output;
private javax.swing.JTextField txt2Input;
private javax.swing.JTextField txt2Output;
private javax.swing.JTextField txt3Input;
private javax.swing.JTextField txt3Output;
// End of variables declaration//GEN-END:variables
}
JobTest/build.xml
Builds, tests, and runs the project JobTest.
JobTest/manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
JobTest/nbproject/build-impl.xml
Must set src.dir
Must set test.src.dir
Must set build.dir
Must set dist.dir
Must set build.classes.dir
Must set dist.javadoc.dir
Must set build.test.classes.dir
Must set build.test.results.dir
Must set build.classes.excludes
Must set dist.jar
Must set javac.includes
No tests executed.
Must set JVM to use for profiling in profiler.info.jvm
Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
Must select some files in the IDE or set javac.includes
To run this application from the command line without Ant, try:
java -cp “${run.classpath.with.dist.jar}” ${main.class}
To run this application from the command line without Ant, try:
java -jar “${dist.jar.resolved}”
Must select one file in the IDE or set run.class
Must select one file in the IDE or set run.class
Must select one file in the IDE or set debug.class
Must select one file in the IDE or set debug.class
Must set fix.includes
This target only works when run from inside the NetBeans IDE.
Must select one file in the IDE or set profile.class
This target only works when run from inside the NetBeans IDE.
This target only works when run from inside the NetBeans IDE.
This target only works when run from inside the NetBeans IDE.
Must select one file in the IDE or set run.class
Must select some files in the IDE or set test.includes
Must select one file in the IDE or set run.class
Must select one file in the IDE or set applet.url
Must select some files in the IDE or set javac.includes
Some tests failed; see details above.
Must select some files in the IDE or set test.includes
Some tests failed; see details above.
Must select some files in the IDE or set test.class
Must select some method in the IDE or set test.method
Some tests failed; see details above.
Must select one file in the IDE or set test.class
Must select one file in the IDE or set test.class
Must select some method in the IDE or set test.method
Must select one file in the IDE or set applet.url
Must select one file in the IDE or set applet.url
JobTest/nbproject/genfiles.properties
build.xml.data.CRC32=bb74e99d
build.xml.script.CRC32=05e037e8
build.xml.stylesheet.CRC32=28e38971@1.53.1.46
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=bb74e99d
nbproject/build-impl.xml.script.CRC32=1189fcfe
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
JobTest/nbproject/project.properties
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/JobTest.jar
dist.javadoc.dir=${dist.dir}/javadoc
excludes=
includes=**
jar.compress=false
javac.classpath=
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.7
javac.target=1.7
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
main.class=newpackage.NewJFrame
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
test.src.dir=test
JobTest/nbproject/project.xml
org.netbeans.modules.java.j2seproject
JobTest
JobTest/src/newpackage/NewJFrame.form
JobTest/src/newpackage/NewJFrame.java
JobTest/src/newpackage/NewJFrame.java
package
newpackage
;
import
javax
.
swing
.
JFrame
;
/**
*
*
@author
Kandiman
*/
public
class
NewJFrame
extends
JFrame
{
/**
* Creates new form NewJFrame
*/
public
NewJFrame
()
{
initComponents
();
init
();
}
private
void
init
(){
setVisible
(
true
);
setTitle
(
“Job Test”
);
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
setLocationRelativeTo
(
null
);
}
@
SuppressWarnings
(
“unchecked”
)
//
private
void
initComponents
()
{
txt1Input
=
new
javax
.
swing
.
JTextField
();
txt2Input
=
new
javax
.
swing
.
JTextField
();
txt3Input
=
new
javax
.
swing
.
JTextField
();
txt1Output
=
new
javax
.
swing
.
JTextField
();
txt2Output
=
new
javax
.
swing
.
JTextField
();
txt3Output
=
new
javax
.
swing
.
JTextField
();
jLabel1
=
new
javax
.
swing
.
JLabel
();
btnDisplayResults
=
new
javax
.
swing
.
JButton
();
btnClear
=
new
javax
.
swing
.
JButton
();
btnExit
=
new
javax
.
swing
.
JButton
();
setDefaultCloseOperation
(
javax
.
swing
.
WindowConstants
.
EXIT_ON_CLOSE
);
txt1Input
.
addActionListener
(
new
java
.
awt
.
event
.
ActionListener
()
{
public
void
actionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
txt1InputActionPerformed
(
evt
);
}
});
txt1Output
.
setEnabled
(
false
);
txt1Output
.
addActionListener
(
new
java
.
awt
.
event
.
ActionListener
()
{
public
void
actionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
txt1OutputActionPerformed
(
evt
);
}
});
txt2Output
.
setEnabled
(
false
);
txt2Output
.
addActionListener
(
new
java
.
awt
.
event
.
ActionListener
()
{
public
void
actionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
txt2OutputActionPerformed
(
evt
);
}
});
txt3Output
.
setEnabled
(
false
);
jLabel1
.
setText
(
“Enter Alpha Characters”
);
jLabel1
.
setMaximumSize
(
new
java
.
awt
.
Dimension
(
138
,
14
));
jLabel1
.
setMinimumSize
(
new
java
.
awt
.
Dimension
(
138
,
14
));
jLabel1
.
setPreferredSize
(
new
java
.
awt
.
Dimension
(
138
,
14
));
jLabel1
.
setVerifyInputWhenFocusTarget
(
false
);
btnDisplayResults
.
setText
(
“Display Results”
);
btnDisplayResults
.
addActionListener
(
new
java
.
awt
.
event
.
ActionListener
()
{
public
void
actionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
btnDisplayResultsActionPerformed
(
evt
);
}
});
btnClear
.
setText
(
“Clear”
);
btnClear
.
addActionListener
(
new
java
.
awt
.
event
.
ActionListener
()
{
public
void
actionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
btnClearActionPerformed
(
evt
);
}
});
btnExit
.
setText
(
“Exit”
);
btnExit
.
addActionListener
(
new
java
.
awt
.
event
.
ActionListener
()
{
public
void
actionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
btnExitActionPerformed
(
evt
);
}
});
javax
.
swing
.
GroupLayout
layout
=
new
javax
.
swing
.
GroupLayout
(
getContentPane
());
getContentPane
().
setLayout
(
layout
);
layout
.
setHorizontalGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
TRAILING
,
layout
.
createSequentialGroup
()
.
addContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)
.
addComponent
(
jLabel1
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
153
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addGap
(
27
,
27
,
27
))
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGap
(
53
,
53
,
53
)
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
,
false
)
.
addComponent
(
txt3Input
)
.
addComponent
(
txt1Output
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
113
,
Short
.
MAX_VALUE
)
.
addComponent
(
txt2Output
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
113
,
Short
.
MAX_VALUE
)
.
addComponent
(
txt3Output
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
113
,
Short
.
MAX_VALUE
)
.
addComponent
(
txt1Input
)
.
addComponent
(
txt2Input
)
.
addComponent
(
btnDisplayResults
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
)))
.
addGroup
(
layout
.
createSequentialGroup
()
.
addContainerGap
()
.
addComponent
(
btnClear
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
101
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
RELATED
)
.
addComponent
(
btnExit
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
101
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)))
.
addContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
))
);
layout
.
setVerticalGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
LEADING
)
.
addGroup
(
layout
.
createSequentialGroup
()
.
addGap
(
6
,
6
,
6
)
.
addComponent
(
jLabel1
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
27
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
RELATED
)
.
addComponent
(
txt1Input
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
UNRELATED
)
.
addComponent
(
txt2Input
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
RELATED
)
.
addComponent
(
txt3Input
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
RELATED
)
.
addComponent
(
btnDisplayResults
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
29
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
UNRELATED
)
.
addComponent
(
txt1Output
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
UNRELATED
)
.
addComponent
(
txt2Output
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addPreferredGap
(
javax
.
swing
.
LayoutStyle
.
ComponentPlacement
.
UNRELATED
)
.
addComponent
(
txt3Output
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
,
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
javax
.
swing
.
GroupLayout
.
PREFERRED_SIZE
)
.
addGap
(
13
,
13
,
13
)
.
addGroup
(
layout
.
createParallelGroup
(
javax
.
swing
.
GroupLayout
.
Alignment
.
BASELINE
)
.
addComponent
(
btnClear
)
.
addComponent
(
btnExit
))
.
addContainerGap
(
javax
.
swing
.
GroupLayout
.
DEFAULT_SIZE
,
Short
.
MAX_VALUE
))
);
pack
();
}
// //GEN-END:initComponents
private
void
txt1InputActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_txt1InputActionPerformed
// TODO add your handling code here:
}
//GEN-LAST:event_txt1InputActionPerformed
private
void
btnDisplayResultsActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_btnDisplayResultsActionPerformed
// TODO add your handling code here:
String
text1
=
txt1Input
.
getText
();
txt1Output
.
setText
(
text1
);
String
text2
=
txt2Input
.
getText
();
txt2Output
.
setText
(
text2
);
String
text3
=
txt3Input
.
getText
();
txt3Output
.
setText
(
text3
);
}
//GEN-LAST:event_btnDisplayResultsActionPerformed
private
void
btnExitActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_btnExitActionPerformed
//Close the application
System
.
exit
(
1
);
}
//GEN-LAST:event_btnExitActionPerformed
private
void
btnClearActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_btnClearActionPerformed
//Clear all text fields and disable the output text fields
txt1Input
.
setText
(
“”
);
txt2Input
.
setText
(
“”
);
txt3Input
.
setText
(
“”
);
txt1Output
.
setText
(
“”
);
txt2Output
.
setText
(
“”
);
txt3Output
.
setText
(
“”
);
}
//GEN-LAST:event_btnClearActionPerformed
private
void
txt2OutputActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_txt2OutputActionPerformed
// TODO add your handling code here:
}
//GEN-LAST:event_txt2OutputActionPerformed
private
void
txt1OutputActionPerformed
(
java
.
awt
.
event
.
ActionEvent
evt
)
{
//GEN-FIRST:event_txt1OutputActionPerformed
// TODO add your handling code here:
}
//GEN-LAST:event_txt1OutputActionPerformed
public
static
void
main
(
String
args
[])
{
try
{
for
(
javax
.
swing
.
UIManager
.
LookAndFeelInfo
info
:
javax
.
swing
.
UIManager
.
getInstalledLookAndFeels
())
{
if
(
“Nimbus”
.
equals
(
info
.
getName
()))
{
javax
.
swing
.
UIManager
.
setLookAndFeel
(
info
.
getClassName
());
break
;
}
}
}
catch
(
ClassNotFoundException
ex
)
{
java
.
util
.
logging
.
Logger
.
getLogger
(
NewJFrame
.
class
.
getName
()).
log
(
java
.
util
.
logging
.
Level
.
SEVERE
,
null
,
ex
);
}
catch
(
InstantiationException
ex
)
{
java
.
util
.
logging
.
Logger
.
getLogger
(
NewJFrame
.
class
.
getName
()).
log
(
java
.
util
.
logging
.
Level
.
SEVERE
,
null
,
ex
);
}
catch
(
IllegalAccessException
ex
)
{
java
.
util
.
logging
.
Logger
.
getLogger
(
NewJFrame
.
class
.
getName
()).
log
(
java
.
util
.
logging
.
Level
.
SEVERE
,
null
,
ex
);
}
catch
(
javax
.
swing
.
UnsupportedLookAndFeelException
ex
)
{
java
.
util
.
logging
.
Logger
.
getLogger
(
NewJFrame
.
class
.
getName
()).
log
(
java
.
util
.
logging
.
Level
.
SEVERE
,
null
,
ex
);
}
new
NewJFrame
();
}
// Variables declaration – do not modify//GEN-BEGIN:variables
private
javax
.
swing
.
JButton
btnClear
;
private
javax
.
swing
.
JButton
btnDisplayResults
;
private
javax
.
swing
.
JButton
btnExit
;
private
javax
.
swing
.
JLabel
jLabel1
;
private
javax
.
swing
.
JTextField
txt1Input
;
private
javax
.
swing
.
JTextField
txt1Output
;
private
javax
.
swing
.
JTextField
txt2Input
;
private
javax
.
swing
.
JTextField
txt2Output
;
private
javax
.
swing
.
JTextField
txt3Input
;
private
javax
.
swing
.
JTextField
txt3Output
;
// End of variables declaration//GEN-END:variables
}