Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't find symbol 'JTextField' in Java
    primarykey
    data
    text
    <pre><code>import javax.swing.*; public class Test { public static void main(String[] args) { JButton jbtOK = new JButton("OK"); JButton jbtCancel = new JButton("Cancel"); JLabel jlblName = new JLabel("Enter your name: "); JTextField jtfName = JTextField("Type Name Here"); JCheckBox jchkBold = new JCheckBox("Bold"); JCheckBox jchkItalic = new JCheckBox("Italic"); JRadioButton jrbRed = new JRadioButton("Red"); JRadioButton jrbYellow = new JRadioButton("Red"); JComboBox jcboColor = new JComboBox(new String[] {"Freshman", "Sophmore", "Junior", "Senior"}); JPanel panel = new JPanel(); panel.add(jbtOK); panel.add(jbtCancel); panel.add(jlblName); panel.add(jtfName); panel.add(jchkBold); panel.add(jchkItalic); panel.add(jrbRed); panel.add(jrbYellow); panel.add(jcboColor); JFrame frame = new JFrame(); frame.add(panel); frame.setTitle("Show GUI Components"); frame.setSize(450, 100); frame.setLocation(200, 100); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } </code></pre> <p><strong>The output that I get when I tried to compile</strong></p> <pre><code>gurbhej@Nanda:~/Dropbox/Programming/Java Programs/Test$ javac Test.java Test.java:9: error: cannot find symbol JTextField jtfName = JTextField("Type Name Here"); ^ symbol: method JTextField(String) location: class Test Note: Test.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error gurbhej@Nanda:~/Dropbox/Programming/Java Programs/Test$ </code></pre> <p>I got this example from a book and also didn't find anything from Errata. Why am I getting this error? This is my first time with GUI stuff in Java so I have no idea how to fix this. Does the JTextField even exits in the Java libraries or is there something that I am missing?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload