quando inserisco le aree
e uso il metodo set textArea e metto dei dati.
la text area non rispecchia questi valori e me ne crea una più grande.
come posso fare affinchè siano rispettati?
quando inserisco le aree
e uso il metodo set textArea e metto dei dati.
la text area non rispecchia questi valori e me ne crea una più grande.
come posso fare affinchè siano rispettati?
Nothing is Impossible
Spiegati meglio che non si è capito nulla.
Poi, posta un po' di codice perchè non conosco alcun metodo setTextArea...
Ciao.![]()
"Perchè spendere anche solo 5 dollari per un S.O., quando posso averne uno gratis e spendere quei 5 dollari per 5 bottiglie di birra?" [Jon "maddog" Hall]
Fatti non foste a viver come bruti, ma per seguir virtute e canoscenza
ok. ci provo
allora. io ho creato delle text aree per inserire del testo.
ublic class BrowserInternet {
JFrame finestra = new JFrame();
JPanel pane1 = new JPanel();
JPanel pane2 = new JPanel();
JPanel pane3 = new JPanel();
JPanel pane4 = new JPanel();
JPanel pane5 = new JPanel();
JButton bottone = new JButton ("vai");
String collegamento;
JTextField sito ;
JLabel titolo;
public Element text1;
public BrowserInternet() {
pane5.setSize(30, 30);
pane4.setSize(30,30);
bottone.addActionListener( new Click_su_vai());
titolo = new JLabel();
sito = new JTextField (30);
pane1.add(sito);
pane1.add(bottone);
finestra.getContentPane().setLayout(new BorderLayout());
pane2.setLayout(new BoxLayout( pane2, BoxLayout.Y_AXIS));
titolo.setAlignmentX(Component.CENTER_ALIGNMENT);
titolo.setVisible(false);
pane2.setVisible(false);
finestra.getContentPane().add(BorderLayout.NORTH, pane1);
finestra.getContentPane().add(BorderLayout.CENTER, pane2);
finestra.getContentPane().add(BorderLayout.EAST, pane5);
finestra.getContentPane().add(BorderLayout.WEST, pane4);
finestra.getContentPane().add(BorderLayout.SOUTH, pane3);
finestra.setTitle("Java Browser");
finestra.setVisible(true);
finestra.setSize(400, 600);
finestra.pack();
finestra.setDefaultCloseOperation(WindowConstants. DISPOSE_ON_CLOSE );
}
public static void main(String[] args) {
BrowserInternet b1 = new BrowserInternet();
}
private class Click_su_vai implements ActionListener
{
// metodo per la gestione dell'evento click sul pulsante vai
public void actionPerformed (ActionEvent e) {
pane2.setVisible(false);
pane2.removeAll();
pane2.repaint();
pane3.setVisible(false);
pane3.removeAll();
pane3.repaint();
// parserizzo il documento xml
SAXBuilder builder = new SAXBuilder();
Document doc;
try {
doc = builder.build(sito.getText());
if (doc.getRootElement().getName() == "book")
{ titolo.setText(doc.getRootElement().getChildText(" title"));
titolo.setAlignmentX(Component.CENTER_ALIGNMENT);
titolo.setVisible(true);
sito.setVisible(true);
JTextField nautore = new JTextField();
JTextField cautore = new JTextField();
JTextField data = new JTextField ();
JTextArea testo = new JTextArea();
testo.setSize(15,10);
JButton collegamentoautore = new JButton();
nautore.setText(doc.getRootElement().getChild("aut hor").getChildText("firstName"));
cautore.setText(doc.getRootElement().getChild("aut hor").getChildText("lastName"));
data.setText(doc.getRootElement().getChild("author ").getChild("bioAuthor").getChildText("text")) ;
testo.setText(doc.getRootElement().getChildText("a bstract"));
testo.setTabSize(1);
JScrollPane jp = new JScrollPane(testo);
collegamentoautore.setText(doc.getRootElement().ge tChild("author").getChild("bioAuthor").getChild("l ink").getChildText("textURL"));
collegamento = doc.getRootElement().getChild("author").getChild(" bioAuthor").getChild("link").getChildText("destina tionURL");
pane2.add(titolo);
pane2.add(nautore);
pane2.add(cautore);
pane2.add(data);
pane2.add(jp);
pane3.add(collegamentoautore);
collegamentoautore.addActionListener(new Mylistener());
}
else { // scorro i nodi dell'albero creato a partire dal documento xml
Element par = doc.getRootElement().getChild("info");
titolo.setText(par.getChildText("title"));
titolo.setAlignmentX(Component.CENTER_ALIGNMENT);
titolo.setVisible(true);
sito.setVisible(true);
pane2.add(titolo);
List paragrafi = par.getChildren("par");
Iterator scorrilista = paragrafi.iterator();
while( scorrilista.hasNext())
{Element item = (Element) scorrilista.next();
List part = item.getChildren();
Iterator scorripart = part.iterator();
while (scorripart.hasNext()) {
Element spart =(Element) scorripart.next();
if (spart.getName() == "image")
{
ImageIcon immagine=new ImageIcon(spart.getText());
JLabel sfondo=new JLabel(immagine);
sfondo.setAlignmentX(Component.CENTER_ALIGNMENT);
pane2.add(sfondo);
}
List text = spart.getChildren();
Iterator scorritesto = text.iterator();
while ( scorritesto.hasNext() ) {
text1 = (Element) scorritesto.next();
if (text1.getName()== "text" && text1.getText() != "" ) {
// inserisco per ogni paragrafo un'area di testo.
JTextArea area = new JTextArea(text1.getText());
area.setTabSize(1);
JScrollPane jp = new JScrollPane(area);
pane2.add(jp); }
else if ( text1.getName()== "link")
{ JButton link = new JButton();
link.setText(text1.getChildText("textURL"));
collegamento = text1.getChildText("destinationURL");
pane3.add(link);
link.addActionListener(new Mylistener()); }
}
}
}
}
}
catch (JDOMException e2) {
e2.printStackTrace();}
catch (IOException e1) {
e1.printStackTrace();}
pane2.setVisible(true);
pane3.setVisible(true);
}
}
utilizzo il metodo setSize (10,15) però l'area di testo ke mi viene creata e più grande.
Nothing is Impossible