Ahoj, chtěl bych poprosit o radu s JScrollPane. Neumím tomu poručit aby se mně v JTextArea zobrazilo posunovátko... Pomůžete mně s tím prosím?
Díky, Nicolas.
package for1;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Main {
public static void main(String[]arg){
For1 apl = new For1();
}
}
class For1 extends JFrame {
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
JPanel panel4 = new JPanel();
JTextArea textarea1 = new JTextArea("",6,11);
JLabel label1 = new JLabel("Bottom level");
JLabel label2 = new JLabel("Upper level");
TextField textfield1 = new TextField("1",20);
TextField textfield2 = new TextField("9",20);
JButton button1 = new JButton("Start");
JScrollPane scrollpane1 = new JScrollPane(textarea1,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
public For1() {
super ("For");
setLayout (new FlowLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
setSize(230,260);
button1.addActionListener (new ActionButton1());
panel1.add(panel2);
panel1.add(panel3);
panel1.add(panel4);
panel1.setPreferredSize(new Dimension (220,220));
getContentPane().add(panel1);
panel2.setPreferredSize(new Dimension (130,105));
panel2.setBackground(Color.LIGHT_GRAY);
panel3.setPreferredSize(new Dimension (70,105));
panel3.setBackground(Color.LIGHT_GRAY);
panel4.setPreferredSize(new Dimension (205,110));
panel4.setBackground(Color.LIGHT_GRAY);
panel2.add(textarea1);
panel3.add(button1);
panel4.add(label1);
panel4.add(textfield1);
panel4.add(label2);
panel4.add(textfield2);
}
class ActionButton1 implements ActionListener {
public void actionPerformed(ActionEvent e) {
String varA = textfield1.getText();
int varB = Integer.parseInt(varA);
String varC = textfield2.getText();
int varD = Integer.parseInt(varC);
for (;varB < varD; varB++)
textarea1.append(varB + "\n");
textarea1.append(varB + "\n");
}
}
}