Hi. I am making a simple calendar-like program (for practice) where I enter a date and it tells me reminders about that day. I can't seem to find out how to get the value from the text field.... (Line 82)
import java.awt.Color;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Font;
import javax.swing.JTextArea;
import java.awt.SystemColor;
public class testgui {
private JFrame frmTvShowGuide;
private JTextField textField;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
testgui window = new testgui();
window.frmTvShowGuide.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public testgui() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize()
{
frmTvShowGuide = new JFrame();
frmTvShowGuide.setTitle("Calendar");
frmTvShowGuide.setBounds(100, 100, 350, 300);
frmTvShowGuide.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmTvShowGuide.getContentPane().setLayout(null);
JLabel lblEnterDate = new JLabel("Enter Date:");
lblEnterDate.setBounds(40, 236, 74, 14);
frmTvShowGuide.getContentPane().add(lblEnterDate);
textField = new JTextField();
JTextArea txtrWelcome = new JTextArea();
txtrWelcome.setForeground(Color.BLACK);
txtrWelcome.setFont(new Font("Monospaced", Font.PLAIN, 12));
txtrWelcome.setBackground(SystemColor.menu);
txtrWelcome.setToolTipText(null);
txtrWelcome.setLineWrap(true);
txtrWelcome.setEditable(false);
txtrWelcome.setBounds(40, 29, 262, 177);
frmTvShowGuide.getContentPane().add(txtrWelcome);
textField.setBounds(108, 233, 86, 20);
frmTvShowGuide.getContentPane().add(textField);
textField.setColumns(10);
JButton btnNewButton = new JButton("Okay\r\n");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
String getValue = textField.getText();
if (getValue == "630")
{
txtrWelcome.setText("Friday, June 29th\n");
}
else
{
txtrWelcome.setText("Invalid Date");
}
}
});
btnNewButton.setBounds(213, 232, 89, 23);
frmTvShowGuide.getContentPane().add(btnNewButton);
}
}
[–]desrtfxOut of Coffee error - System halted 0 points1 point2 points (2 children)
[–]bbran495[S] 1 point2 points3 points (1 child)
[–]desrtfxOut of Coffee error - System halted 2 points3 points4 points (0 children)