Question: When you run the code below, does the TextArea have a horizontal scrollbar? Does it have a vertical scrollbar? If yes, when are they displayed?

When you run the code below, does the TextArea have a horizontal scrollbar? Does it have a vertical scrollbar? If yes, when are they displayed? How many lines of text are displayed in the textArea at a time?

private static final long serialVersionUID = 1L;

private static void createAndShowGUI() {

//create and set up the window

final JFrame frame = new JFrame("Scroll Pane Example");

//Display the window

frame.setSize(200,200);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE;

//set flow layout for the frame

frame.getContentPane().setLayout(new FlowLayout());

JtextArea textArea = new JTextArea (5, 5);

JScrollPane scrollableTextArea = new JScrollPane(textArea);

scrollableTextArea.setHorizontalScrollBarPolicy(JScrollPane.HORIZONATAL_SCROLLBAR_AS_NEEDED);

scrollableTextArea.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

frame.getContentPane().add(scrollableTextArea);

}

please answer this as soon as possible

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!