Mr. Hovercraft Full Of EelsJScrollPane не работает должным образом
Я почти сделал то, что вы сказали. МОЯ ИЗВИНЕНИЕ он еще не показывает :(
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 760, 666);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//frame.getContentPane().setLayout(null);
//frame.getContentPane().setLayout();
textArea = new JTextArea(20,20);
textArea.setPreferredSize(new Dimension(100, 100));
textArea.setLineWrap(true);
JScrollPane sp = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
frame.getContentPane().add(sp);
frame.setVisible(true);
}
Я следую учебник по YouTube с помощью WindowBuilderPro в Eclipse. Я хочу создать (прокручивать) JTextArea с помощью JScollPane. Несмотря на то, Я следовал принципам, он не работает! Эта маленькая вещь потребляет мое время, так что я решил спросить вас, ребята :( KINDLY, может кто-то сказать мне, почему JTextArea не показывается в JFrame.
public class ProjectGUI {
private JFrame frame;
private JTextField urls;
private JTextArea textArea;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ProjectGUI window = new ProjectGUI();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public ProjectGUI() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 760, 666);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JPanel panel = new JPanel();
panel.setBorder(new TitledBorder(null, "X.509 Extractor", TitledBorder.LEADING, TitledBorder.TOP, null, null));
panel.setBounds(18, 16, 722, 145);
panel.setLayout(null);
frame.getContentPane().add(panel);
urls = new JTextField();
urls.setText("For multiple URLs, separate them by comma ,");
urls.setForeground(Color.BLUE);
urls.setBounds(59, 57, 646, 28);
panel.add(urls);
JButton button1 = new JButton("EXTRACT");
button1.setBounds(303, 97, 117, 40);
frame.setLocationRelativeTo(null);
panel.add(button1);
textArea = new JTextArea();
textArea.setBounds(18, 212, 722, 414);
textArea.setLineWrap(true);
JScrollPane sp= new JScrollPane(textArea);
frame.getContentPane().add(sp);
frame.setVisible(true);
}
}
Eclipse удален из вашего названия - это не имеет никакого отношения к вашему вопросу. Полужирный текст удален. –
См. Править для ответа. –