जोड़ना मैं एक JTextArea में स्क्रॉल बार जोड़ने की कोशिश कर रहा हूं। क्या कोई मुझे बताएगा कि मैंने नीचे दिए गए कोड के साथ क्या गलत किया है?स्क्रोल करने योग्य JTextArea (जावा)
JFrame frame = new JFrame ("Test");
JTextArea textArea = new JTextArea ("Test");
JScrollPane scrollV = new JScrollPane (textArea);
JScrollPane scrollH = new JScrollPane (textArea);
scrollV.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollH.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
frame.setVisible (true);
अग्रिम धन्यवाद।
संपादित करें: मैंने नीचे एडेल बुटरोस की सलाह के साथ कोड तय किया है।
//FRAME
JFrame frame = new JFrame ("Test");
frame.setSize(500,500);
frame.setResizable(false);
//
//TEXT AREA
JTextArea textArea = new JTextArea("TEST");
textArea.setSize(400,400);
textArea.setLineWrap(true);
textArea.setEditable(false);
textArea.setVisible(true);
JScrollPane scroll = new JScrollPane (textArea);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
frame.add(scroll);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@AdelBoutros नहीं, ऑप्स कोड अब सही है - कृपया विकल्प संपादित करें :-) – kleopatra