I'm writing a GUI for a DVD player. I'm attempting to align the JTextField to the center of the JPanel, but I am getting this error:
DVDPlayer.java:23: cannot find symbol
symbol : method setVerticalAlignment(int)
location: class javax.swing.JTextField
jtfDetails.setVerticalAlignment(JTextField.CENTER) ;
^
1 error
import javax.swing.*; import java.awt.*; import javax.swing.border.*; public class DVDPlayer extends JFrame { private JPanel p1, p2; private JButton jbtDVD, jbtPlay, jbtRewind, jbtFForward, jbtStop; private JTextField jtfDetails; public DVDPlayer() { add(jbtDVD = new JButton("DVD to be placed here")); add(jbtDVD, BorderLayout.NORTH); p1 = new JPanel(); p1.add(jtfDetails = new JTextField("DVD details to be displayed here")); jtfDetails.setVerticalAlignment(JTextField.CENTER); add(p1, BorderLayout.WEST); p2 = new JPanel(); p2.setLayout(new FlowLayout()); p2.setBorder(new LineBorder(Color.BLACK, 2)); p2.add(jbtPlay = new JButton("Play")); p2.add(jbtRewind = new JButton("<<")); p2.add(jbtFForward = new JButton(">>")); p2.add(jbtStop = new JButton("Stop")); add(p2, BorderLayout.EAST); } public static void main(String[] args) { DVDPlayer frame = new DVDPlayer(); frame.setTitle("The Front View of a DVD Player"); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); } }