Perhaps this was already asked once but I am kinda stuck and cant find a solution by myself.
I got text from first button using text fields. And now i need to get this text into second button OR text file.
Code below and i know that this one gives error.
System.out.println("Author's name: " + newauthor());
System.out.println("Book name: " + newbook());
import java.awt.GridLayout;
import java.awt.event.*;
import java.io.FileNotFoundException;
import javax.swing.*;
public class library extends JFrame
{
private JPanel pnl;
public library() throws FileNotFoundException {
pnl = (JPanel) getContentPane();
JPanel panel = new JPanel();
getContentPane().add(panel);
panel.setLayout(null);
JButton addbutton = new JButton("Add new book");
addbutton.setBounds(75, 30, 150, 30);
addbutton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
JTextField authorfield = new JTextField(15);
JTextField bookField = new JTextField(15);
JPanel mypanel = new JPanel(new GridLayout(0, 1));
mypanel.add(new JLabel("Type Author's Name and Book name:"));
mypanel.add(new JLabel("Author's Name:"));
mypanel.add(authorfield);
mypanel.add(new JLabel("Book name:"));
mypanel.add(bookField);
int result = JOptionPane.showConfirmDialog(null, mypanel,
"Add a new book", JOptionPane.OK_CANCEL_OPTION);
if (result == JOptionPane.OK_OPTION)
{
String newauthor = authorfield.getText();
String newbook = bookField.getText();
if (!newauthor.isEmpty() && !newbook.isEmpty())
{
JOptionPane.showMessageDialog(pnl, "Book "+bookField.getText()+"\nAuthor "+authorfield.getText()+"\nSuccessfully added to the list.",
"Book was added.", JOptionPane.INFORMATION_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(pnl, "Both must be filled!",
"Error", JOptionPane.ERROR_MESSAGE);
}
}
}
});
panel.add(addbutton);
JButton listbutton = new JButton("List");
listbutton.setBounds(75, 60, 150, 30);
panel.add(listbutton);
addbutton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
System.out.println("Author's name: " + newauthor());
System.out.println("Book name: " + newbook());
}
});
JButton deletebutton = new JButton("Delete");
deletebutton.setBounds(75, 90, 150, 30);
panel.add(deletebutton);
setTitle("Library Menu");
setSize(300, 200);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args) throws FileNotFoundException {
library ex = new library();
ex.setVisible(true);
}
}
Your code is having many issues.
1.Both should be declared inside of your class but outside of your any method.
String newauthor = "";
String newbook = "";
Now in the if condition
if (result == JOptionPane.OK_OPTION)
{
newauthor = authorfield.getText();
newbook = bookField.getText();
..............................
2.
JButton listbutton = new JButton("List");
listbutton.setBounds(75, 60, 150, 30);
panel.add(listbutton);
listbutton.addActionListener(new ActionListener()// its listbutton not addbutton
{
public void actionPerformed(ActionEvent event)
{
System.out.println("Author's name: " + newauthor);
System.out.println("Book name: " + newbook);
}
});
Both newauthor and newbook are variables. But not methods.
Related
I create Two Java File, the one is Reg.java and the second is Get.java. in Reg.java I create a JFrame with textfield for name and textfield for age, and a button. all i want is when you enter the name and age in textfields and click button, it will pass the string name and age and show in Get.java.
this is my code for Reg.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Reg extends JFrame implements ActionListener {
private Container con = getContentPane();
FlowLayout fl = new FlowLayout();
JLabel lb1 = new JLabel(": ");
JTextField tf1 = new JTextField(14);
JLabel lb2 = new JLabel("Enter your Age: ");
JTextField tf2 = new JTextField(14);
JButton btnSub = new JButton("Submit");
public Reg(){
setLayout(fl);
setSize(350, 275);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
add(lb1);
add(tf1);
add(lb2);
add(tf2);
add(btnSub);
lb1.setAlignmentX(LEFT_ALIGNMENT);
lb2.setAlignmentX(LEFT_ALIGNMENT);
lb1.setPreferredSize(new Dimension(120,50));
lb2.setPreferredSize(new Dimension(120,50));
tf1.setAlignmentX(RIGHT_ALIGNMENT);
tf2.setAlignmentX(RIGHT_ALIGNMENT);
btnSub.setHorizontalAlignment(JButton.CENTER);
btnSub.setToolTipText("Click to Submit");
btnSub.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
String name = tf1.getText();
String age = tf2.getText();
}
public static void main(String[] args){
Reg fr = new Reg();
fr.setVisible(true);
}
}
For a more general situation you might provide methods for accessing the user name and password, and a reference from the main class to the login class in order to call those methods.
But this does not require two Java classes, let alone two Java files. It also does not require using two frames, in fact, this is one case where multiple frames makes the task more tricky, in that a frame is non-modal. Use a modal JDialog or a JOptionPane instead of the 'login frame'. That way, the password can be checked as soon it is dismissed.
This is what it might look like: (tip: the valid password for all users is 'guest')
Here's how to go about it:
import java.awt.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
public class LoginRequired {
private JTextField usernameField = new JTextField("Joe Blogs");
private JPasswordField passwordField = new JPasswordField();
char[] password = {'g', 'u', 'e', 's', 't'};
JPanel loginPanel;
LoginRequired() {
JFrame f = new JFrame("Login Required");
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
JLabel output = new JLabel(
"Login is required to use this application!",
SwingConstants.CENTER);
output.setBorder(new EmptyBorder(50, 100, 50, 100));
f.add(output);
f.pack();
f.setResizable(false);
f.setLocationByPlatform(true);
f.setVisible(true);
boolean loginValid = false;
while (!loginValid) {
showLogin(f);
loginValid = isLoginValid();
}
String user = usernameField.getText();
output.setText("Welcome back, " + user + "!");
f.setTitle("Logged In: " + user);
}
private boolean isLoginValid() {
char[] passwordEntered = passwordField.getPassword();
if (passwordEntered.length != password.length) {
return false;
} else {
for (int ii = 0; ii < password.length; ii++) {
if (password[ii] != passwordEntered[ii]) {
return false;
}
}
return true;
}
}
private void showLogin(JFrame frame) {
if (loginPanel==null) {
loginPanel = new JPanel(new BorderLayout(5, 5));
JPanel labels = new JPanel(new GridLayout(0, 1, 2, 2));
labels.add(new JLabel("User Name", SwingConstants.RIGHT));
labels.add(new JLabel("Password", SwingConstants.RIGHT));
loginPanel.add(labels, BorderLayout.WEST);
JPanel controls = new JPanel(new GridLayout(0, 1, 2, 2));
usernameField = new JTextField("Joe Blogs");
controls.add(usernameField);
passwordField = new JPasswordField();
controls.add(passwordField);
loginPanel.add(controls, BorderLayout.CENTER);
}
passwordField.setText("");
JOptionPane.showMessageDialog(
frame, loginPanel, "Log In", JOptionPane.QUESTION_MESSAGE);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
new LoginRequired();
}
});
}
}
public class Reg extends JFrame implements ActionListener {
.....
'''''
Get get;
public Reg(){
.....
.....
get = new Get();
}
#Override
public void actionPerformed(ActionEvent e){
String name = tf1.getText();
String age = tf2.getText();
get.print(name);
get.print(age);
}
}
class Get{
public void print(String txt) {
System.out.println(txt);
}
}
Use BuferedReader with get.java and use BufferedWriter with reg.java.
Use BufferedWriter in reg.java to write the Name and age in two lines and then use BufferedReader to read these values in Get.java.
I'm trying to access the int myInt in this GUI form class from another class. The method does pass the input variable to myInt properly but I have not been able to make it visible to the other java file. I have been reading about scope and class declarations and have been able to muddle along up until now, but I am doing something wrong here. Nothing I have tried has worked.
package com.jdividend.platform.allocation;
import com.ib.client.*;
import com.jdividend.platform.model.*;
import com.jdividend.platform.trader.*;
import com.jdividend.platform.util.*;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/**
* Dialog to show the account size allowed info.
*/
public class AllocationDialog extends JDialog {
/* inner class to define the "about" model */
public static class AllocationTableModel extends TableDataModel {
private AllocationTableModel() {
String[] aboutSchema = {"Property", "Value"};
setSchema(aboutSchema);
}
}
public AllocationDialog(JFrame parent) {
super(parent);
init();
pack();
setLocationRelativeTo(parent);
setVisible(true);
}
public void init() {
setModal(true);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setTitle("Allocation - JDividend");
JPanel contentPanel = new JPanel();
getContentPane().add(contentPanel, BorderLayout.CENTER);
contentPanel.setLayout(new BorderLayout(0, 0));
{
JPanel panel = new JPanel();
contentPanel.add(panel, BorderLayout.CENTER);
panel.setLayout(null);
JPanel panel_1 = new JPanel();
panel_1.setBounds(84, 146, 274, 19);
panel.add(panel_1);
JLabel lblNewLabel = new JLabel("Total account cash and margin that");
panel_1.add(lblNewLabel);
JPanel panel_2 = new JPanel();
panel_2.setBounds(84, 163, 274, 19);
panel.add(panel_2);
JLabel lblJdividendIsAllowed = new JLabel("JDividend is allowed to trade with.");
panel_2.add(lblJdividendIsAllowed);
JFormattedTextField formattedTextField = new JFormattedTextField();
formattedTextField.setBounds(172, 189, 100, 20);
panel.add(formattedTextField);
JButton btnOk = new JButton("OK");
btnOk.setBounds(121, 221, 89, 23);
panel.add(btnOk);
btnOk.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent arg0) {
try {
int myInt = Integer.parseInt(formattedTextField.getText());
System.out.println(myInt);
//do some stuff
}
catch (NumberFormatException ex) {
System.out.println("Not a number");
//do you want
}
JButton btnCancel = new JButton("Cancel");
btnCancel.setBounds(238, 220, 89, 23);
panel.add(btnCancel);
formattedTextField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JButton button = new JButton("OK");
}
});
}
});
}
String serverVersion = "Disconnected from server";
Trader trader = Dispatcher.getInstance().getTrader();
if (trader != null) {
int version = trader.getAssistant().getServerVersion();
if (version != 0) {
serverVersion = String.valueOf(version);
}
}
TableDataModel aboutModel = new AllocationTableModel();
getContentPane().setPreferredSize(new Dimension(450, 400));
Properties properties = System.getProperties();
Enumeration<?> propNames = properties.propertyNames();
while (propNames.hasMoreElements()) {
String key = (String) propNames.nextElement();
String value = properties.getProperty(key);
String[] row = {key, value};
aboutModel.addRow(row);
}
}
}
myInt should be declared inside the class, but outside of any method implementations:
public class AllocationDialog extends JDialog {
public int myInt;
// ...
}
I've been working at this problem for hours now, with no results. I cannot seem to get the applet to display properly when viewing the HTML page OR when running the applet through Eclipse. It is always blank. I've been searching for a long time now and decided just to ask.
Here's the code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
public class Topics extends Applet{
String topicTotal = "";
JPanel topicPanel;
JLabel title, username, topic, paragraph, topicsTitle;
JTextField nameField, topicField;
JButton submitButton;
JTextArea paragraphArea;
public String getTopicTotal() {
return topicTotal;
}
public JPanel createContentPane(){
final JPanel topicGUI = new JPanel();
topicGUI.setLayout(null);
//posting panel
final JPanel postPanel = new JPanel();
postPanel.setLayout(null);
postPanel.setLocation(0, 0);
postPanel.setSize(500, 270);
topicGUI.add(postPanel);
setVisible(true);
// JLabels
JLabel title = new JLabel("Make A Post");
title.setLocation(170, 3);
title.setSize(150,25);
title.setFont(new Font("Serif", Font.PLAIN, 25));
title.setHorizontalAlignment(0);
postPanel.add(title);
JLabel username = new JLabel("Username: ");
username.setLocation(20, 30);
username.setSize(70,15);
username.setHorizontalAlignment(0);
postPanel.add(username);
JLabel topic = new JLabel("Topic: ");
topic.setLocation(20, 50);
topic.setSize(40,15);
topic.setHorizontalAlignment(0);
postPanel.add(topic);
JLabel paragraph = new JLabel("Paragraph: ");
paragraph.setLocation(20, 70);
paragraph.setSize(70,15);
paragraph.setHorizontalAlignment(0);
postPanel.add(paragraph);
// JTextFields
nameField = new JTextField(8);
nameField.setLocation(90, 30);
nameField.setSize(150, 18);
postPanel.add(nameField);
topicField = new JTextField(8);
topicField.setLocation(60, 50);
topicField.setSize(180, 18);
postPanel.add(topicField);
// JTextAreas
paragraphArea = new JTextArea(8, 5);
paragraphArea.setLocation(20, 85);
paragraphArea.setSize(450, 100);
paragraphArea.setLineWrap(true);
paragraphArea.setEditable(true);
JScrollPane scrollParagraph = new JScrollPane (paragraphArea);
scrollParagraph.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
postPanel.add(paragraphArea);
// JButton
JButton submitButton = new JButton("SUBMIT");
submitButton.setLocation(250, 30);
submitButton.setSize(100, 30);
submitButton.addActionListener(new ActionListener(){
#Override
public void actionPerformed(ActionEvent e) {
topicTotal = topicTotal + "/n" + nameField + "/n" + topicTotal + "/n" + paragraphArea + "/n";
}
});
postPanel.add(submitButton);
setVisible(true);
return topicGUI;
}
private static void createAndShowGUI() {
JFrame frame = new JFrame("");
Topics display = new Topics();
frame.setContentPane(display.createContentPane());
frame.setSize(500, 270);
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
In order to run as an applet, you need to override the init method. You don't need a main method. Just add all you components inside the init method
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
public class Topics extends Applet {
String topicTotal = "";
JPanel topicPanel;
JLabel title, username, topic, paragraph, topicsTitle;
JTextField nameField, topicField;
JButton submitButton;
JTextArea paragraphArea;
public String getTopicTotal() {
return topicTotal;
}
public void init() {
final JPanel topicGUI = new JPanel();
topicGUI.setLayout(null);
// posting panel
final JPanel postPanel = new JPanel();
postPanel.setLayout(null);
postPanel.setLocation(0, 0);
postPanel.setSize(500, 270);
add(postPanel);
setVisible(true);
// JLabels
JLabel title = new JLabel("Make A Post");
title.setLocation(170, 3);
title.setSize(150, 25);
title.setFont(new Font("Serif", Font.PLAIN, 25));
title.setHorizontalAlignment(0);
add(title);
JLabel username = new JLabel("Username: ");
username.setLocation(20, 30);
username.setSize(70, 15);
username.setHorizontalAlignment(0);
add(username);
JLabel topic = new JLabel("Topic: ");
topic.setLocation(20, 50);
topic.setSize(40, 15);
topic.setHorizontalAlignment(0);
add(topic);
JLabel paragraph = new JLabel("Paragraph: ");
paragraph.setLocation(20, 70);
paragraph.setSize(70, 15);
paragraph.setHorizontalAlignment(0);
add(paragraph);
// JTextFields
nameField = new JTextField(8);
nameField.setLocation(90, 30);
nameField.setSize(150, 18);
add(nameField);
topicField = new JTextField(8);
topicField.setLocation(60, 50);
topicField.setSize(180, 18);
add(topicField);
// JTextAreas
paragraphArea = new JTextArea(8, 5);
paragraphArea.setLocation(20, 85);
paragraphArea.setSize(450, 100);
paragraphArea.setLineWrap(true);
paragraphArea.setEditable(true);
JScrollPane scrollParagraph = new JScrollPane(paragraphArea);
scrollParagraph
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
add(paragraphArea);
// JButton
JButton submitButton = new JButton("SUBMIT");
submitButton.setLocation(250, 30);
submitButton.setSize(100, 30);
submitButton.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent e) {
topicTotal = topicTotal + "/n" + nameField + "/n" + topicTotal
+ "/n" + paragraphArea + "/n";
}
});
add(submitButton);
}
}
The JLabel nameLabel will not appear on the gui. Ive tried to use a SwingWorker so concurrency isnt an issue. When the Jlabel is added to the West section of the BorderLayout of the internal JPanel the panel makes room for the label but the label doesnt actually appear. If anyone has had this problem or knows how to fix it i would be very appreciative
thanks
public class Frame_2
{
JButton done = new JButton("Next Page");
JLabel topLabel = new JLabel("2. Contact Information");
JTextField nameInput = new JTextField();
JTextField mailingAddressInput = new JTextField();
JTextField cityStateInput = new JTextField();
JTextField telephoneInput = new JTextField();
JTextField faxInput = new JTextField();
JTextField eMailInput = new JTextField();
JLabel nameLabel = new JLabel("Name:");
JPanel internal = new JPanel();
JPanel northGrid = new JPanel();
int keepTrack = 0;
String name;
String mailingAddress;
String cityState;
String telephone;
String fax;
String eMail;
public void buildFrame_2(JFrame frame)
{
nameLabel.setText("Name:");
nameInput.setText("Name:");
mailingAddressInput.setText("Mailing Address:");
cityStateInput.setText("City, State, Zip Code:");
telephoneInput.setText("Telephone:");
faxInput.setText("Fax:");
eMailInput.setText("E-mail:");
internal.setLayout(new BorderLayout());
topLabel.setHorizontalAlignment(SwingConstants.CENTER);
frame.setLayout(new BorderLayout());
northGrid.setLayout(new GridLayout(12,2));
nameInput.addActionListener((new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
name = nameInput.getText();
System.out.println(name);
nameInput.setVisible(false);
keepTrack++;
if(keepTrack == 6)
{
askForSecondary(internal);
}
}
}));
mailingAddressInput.addActionListener((new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
mailingAddress = mailingAddressInput.getText();
System.out.println(mailingAddress);
mailingAddressInput.setVisible(false);
keepTrack++;
if(keepTrack == 6)
{
askForSecondary(internal);
}
}
}));
cityStateInput.addActionListener((new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
cityState = cityStateInput.getText();
System.out.println(cityState);
cityStateInput.setVisible(false);
keepTrack++;
if(keepTrack == 6)
{
askForSecondary(internal);
}
}
}));
telephoneInput.addActionListener((new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
telephone = telephoneInput.getText();
System.out.println(telephone);
telephoneInput.setVisible(false);
keepTrack++;
if(keepTrack == 6)
{
askForSecondary(internal);
}
}
}));
faxInput.addActionListener((new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
fax = faxInput.getText();
System.out.println(fax);
faxInput.setVisible(false);
keepTrack++;
if(keepTrack == 6)
{
askForSecondary(internal);
}
}
}));
eMailInput.addActionListener((new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
eMail = eMailInput.getText();
System.out.println(eMail);
eMailInput.setVisible(false);
keepTrack++;
if(keepTrack == 6)
{
askForSecondary(internal);
}
}
}));
northGrid.add(nameInput);
northGrid.add(mailingAddressInput);
northGrid.add(cityStateInput);
northGrid.add(telephoneInput);
northGrid.add(faxInput);
northGrid.add(eMailInput);
internal.add(nameLabel, BorderLayout.WEST);
//internal.add(northGrid, BorderLayout.CENTER);
frame.add(internal, BorderLayout.CENTER);
frame.add(done, BorderLayout.SOUTH);
frame.add(topLabel, BorderLayout.NORTH);
}
Using the below code, label shows up fine for me.
JFrame f = new JFrame();
Frame_2 f2 = new Frame_2();
f2.buildFrame_2(f);
f.pack();
f.setVisible(true);
However, if the pack() call is removed, the frame defaults to its minimum size so that contents cannot be seen.
My guess is that you just need to resize frame. However, you really ought to provide an SSCCE if you want more accurate answers.
I think my error is my showGreeting() method. Specifically in the try. When the user presses the Get Greeting button I want it show a dialog box what says "Greetings, FirstName + MI + LastName" And when the user leaves a field blank an I created comes error comes up, that works fine, but I do not understand why my normal Greeting does not work.
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class GreetingApp extends JFrame {
private static final long serialVersionUID = 1L;
private final JTextField firstNameField,middleNameField,lastNameField;
private final JButton greetingButton;
public GreetingApp() {
super("Greetings");
this.firstNameField = new JTextField(8);
this.middleNameField = new JTextField(8);
this.lastNameField = new JTextField(8);
this.greetingButton = new JButton("Get Greeting");
greetingButton.addActionListener(new ActionListener() {
#Override
public void actionPerformed(final ActionEvent ae){
showGreeting();
}
});
final Container mainPanel = getContentPane();
mainPanel.setLayout(new BorderLayout());
final JPanel inputPanel = new JPanel();
final JPanel buttonPanel = new JPanel();
inputPanel.setLayout(new GridLayout(3,3,2,2));
buttonPanel.setLayout(new BorderLayout());
JSeparator sep = new JSeparator();
inputPanel.add(new JLabel("First Name: "),JLabel.LEFT_ALIGNMENT);
inputPanel.add(firstNameField);
inputPanel.add(new JLabel("MI: "),JLabel.LEFT_ALIGNMENT);
inputPanel.add(middleNameField);
inputPanel.add(new JLabel("Last Name: "),JLabel.LEFT_ALIGNMENT);
inputPanel.add(lastNameField);
mainPanel.add(inputPanel,BorderLayout.PAGE_START);
buttonPanel.add(sep,BorderLayout.PAGE_START);
buttonPanel.add(greetingButton);
mainPanel.add(buttonPanel,BorderLayout.PAGE_END);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setLocationRelativeTo(null);
setVisible(true);
}
private String getFullName() throws IllegalStateException{
if(firstNameField.getText().trim().length() == 0){
throw new IllegalArgumentException("First name cannot be blank");
}
if(middleNameField.getText().trim().length() == 0){
throw new IllegalArgumentException("Middle name cannot be blank");
}
if(lastNameField.getText().trim().length() == 0){
throw new IllegalArgumentException("Last name cannot be blank");
}
return "Greetings, "+this.firstNameField+" "+ this.middleNameField +". "+this.lastNameField+"!";
}
private void showGreeting(){
try{
String message = getFullName();
JOptionPane.showMessageDialog(this, message, "Greetings",JOptionPane.PLAIN_MESSAGE);
}catch(final IllegalArgumentException iae){
JOptionPane.showMessageDialog(this,
iae.getMessage(),
"Error",
JOptionPane.ERROR_MESSAGE);
}
}
public static void main(String[] args) {
GreetingApp g = new GreetingApp();
}
}
Edit:
Never mind guys got it I had to add a .getText()
return "Greetings, "+this.firstNameField+" "+ this.middleNameField +". "+this.lastNameField+"!";
after each of fields to actually get the Text from them
Never mind guys got it I had to add a .getText() return "Greetings, "+this.firstNameField+" "+ this.middleNameField +". "+this.lastNameField+"!"; after each of fields to actually get the Text from them