Wie setze ich einen Scrollbalken an ein JTextArea?

D

deIsa

Hallo ihr,

soweit bin ich mit meiner grafischen Oberfläche schon zufrieden, was noch fehlt, sind Scrollbalken am Rand der JTextAreas. Leider weiß ich nur nicht so richtig, wie ich das umsetzen und einfügen soll.

Ich freue mich schon auf baldige Antworten.

Liebe Grüße
die Isa


P.S.: Zur besseren Veranschaulichung und zum Verständnis hier der Quellcode:



import java.awt.event.ActionEvent;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.text.NumberFormat;


import javax.swing.*;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;


public class AdressDatenBank extends JFrame
{
JTextArea textarea_name;
JTextArea textarea_address;
JTextArea textarea_country;
JTextArea textarea_phone;
JTextArea textarea_email;
JTextArea textarea_net;
JTextArea textarea_extras;

JButton button;

JLabel jname = new JLabel("Name:");
JLabel jaddress = new JLabel("Adresse:");
JLabel jcountry = new JLabel("Land:");
JLabel jphone = new JLabel("Telefon:");
JLabel jemail = new JLabel("E-Mail:");
JLabel jnet = new JLabel("Internetadresse:");
JLabel jextras = new JLabel("Bemerkungen:");

//JPanel pname = new JPanel();

public AdressDatenBank()
{
this.getContentPane().setLayout(null);


this.getContentPane().add(jname); //das Panel hinzugefügt
jname.setBounds(5,10,110,35);
this.getContentPane().add(jaddress);
jaddress.setBounds(5,55,110,35);
this.getContentPane().add(jcountry);
jcountry.setBounds(5,150,110,35);
this.getContentPane().add(jphone);
jphone.setBounds(5,195,110,35);
this.getContentPane().add(jemail);
jemail.setBounds(5,265,110,35);
this.getContentPane().add(jnet);
jnet.setBounds(5,310,110,35);
this.getContentPane().add(jextras);
jextras.setBounds(5,355,110,35);


// Instanzieren:
textarea_name = new JTextArea();
textarea_address = new JTextArea();
textarea_country = new JTextArea();

textarea_phone = new JTextArea();
textarea_email = new JTextArea();
textarea_net = new JTextArea();
textarea_extras = new JTextArea();



button = new JButton("Speichern");



button.addActionListener(new ActionListener()
{

public void actionPerformed(ActionEvent arg0)
{
// TODO Auto-generated method stub

}
});



// Positionen festlegen
textarea_name.setBounds(120,17,450,25);
textarea_address.setBounds(120,62,450,75);
textarea_country.setBounds(120,157,450,25);
textarea_phone.setBounds(120,202,450,50);
textarea_email.setBounds(120,272,450,25);
textarea_net.setBounds(120,317,450,25);
textarea_extras.setBounds(120,362,450,75);
button.setBounds(469,470,100,30);



// Elemente dem Fenster hinzufügen:
this.getContentPane().add(textarea_name);
this.getContentPane().add(textarea_address);
this.getContentPane().add(textarea_country);
this.getContentPane().add(textarea_phone);
this.getContentPane().add(textarea_email);
this.getContentPane().add(textarea_net);
this.getContentPane().add(textarea_extras);
this.getContentPane().add(button);

this.pack();

this.addWindowListener(new WindowListener()
{

public void windowClosed(WindowEvent arg0)
{
}

public void windowActivated(WindowEvent e)
{
}

public void windowClosing(WindowEvent e)
{
System.exit(0);
}

public void windowDeactivated(WindowEvent e)
{
}

public void windowDeiconified(WindowEvent e)
{
}

public void windowIconified(WindowEvent e)
{
}

public void windowOpened(WindowEvent e)
{
}



});

}


public static void main(String[] args)
{
AdressDatenBank f=new AdressDatenBank();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(650,550);
f.setVisible(true);
}
}
 
Zurück