public class test {Boujour, j'ai un problème depuis quelque temps, je n'arrive pas à faire fonctionner un JScrollPane dans un JTextArea j'ai tout essayer mais je n'y arrive pas. Voici mon script.
Je croit que mon problème vien du .setlayout(null) mais j'ai besoin de la garder car je veux aussi ajouter une JTextField plus tard (je souhaite faire une sorte de terminal).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; private JFrame frame; public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { test window = new test(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the application. */ public test() { initialize(); } /** * Initialize the contents of the frame. */ public void initialize() { frame = new JFrame(); frame.setBounds(0, 0, 1340, 700); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(null); frame.setResizable(false); JTextArea area = new JTextArea("</User:/xschegel/main.computer/terminal.javascript/>"); area.setEditable(true); area.setVisible(true); area.setOpaque(false); JScrollPane scroll = new JScrollPane();[/SIZE][/SIZE][/SIZE] scroll.setBounds(0, 0, 600, 400); area.add(scroll); scroll.setOpaque(true); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); frame.add(scroll); } }
Merci
PS: je suis assez débutant
Partager