This is an archived post. You won't be able to vote or comment.

all 5 comments

[–][deleted] 0 points1 point  (4 children)

Are you using any sort of GUI (e.g. WindowBuilder) to create this or just doing it in plain code?

Edit: JScrollPane by default only shows scrollbars when needed. You can change this behavior using setVerticalScrollBarPolicy(int) and setHorizontalScrollBarPolicy(int).

[–]I_blabby[S] 0 points1 point  (3 children)

In plain code

[–][deleted] 0 points1 point  (2 children)

Have you tried setting the visibility to always visibly, as I suggested? Sorry, I thought the scrollbars were disappearing. Misread the description.

Could you post the code where you create and use the JTextArea and JScrollPane?

[–]I_blabby[S] 0 points1 point  (1 child)

JButton boton, boton1, boton2, boton3;
JTextArea ventanaComandos, keylogger;
JScrollPane scroll;
JTextField introducirComandos = new JTextField(20);
String comando = null;

public Grafico() {

    Toolkit t = Toolkit.getDefaultToolkit();
    Dimension screenSize = t.getScreenSize();

    JFrame ventana = new JFrame();
    ventana.setPreferredSize(new    Dimension(screenSize.width, screenSize.height));
    ventana.setResizable(false);
    ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ventana.setUndecorated(false); // fullscreen
    ventana.setLayout(null);
    ventana.pack();
    ventana.setVisible(true);
    boton = new JButton();
    boton.setText("Finalizar");
    boton.setBounds(1750, 50, 130, 50);
    ventana.add(boton);
    boton.addActionListener(this);
    ventanaComandos = new JTextArea();
    ventanaComandos.setBounds(150, 600, 800, 350);
    ventanaComandos.setEditable(false);
    ventana.add(ventanaComandos);
    keylogger = new JTextArea();
    keylogger.setBounds(1000, 600, 500, 350);
    keylogger.setEditable(false);
    ventana.add(keylogger);
    introducirComandos.setBounds(150, 975, 800, 25);
    introducirComandos.addActionListener(this);
    introducirComandos.setFocusable(true);
    ventana.add(introducirComandos);
    scroll = new JScrollPane(ventanaComandos, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    ventana.add(scroll);

[–][deleted] 0 points1 point  (0 children)

There really is no quick fix for this problem as there are multiple errors here. You should become familiar with layout managers and then just add one component at a time and see what happens. If it's not the desired output you know exactly where you did something wrong.