ok, ho del codice che funziona
codice:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class imageScroller extends JFrame implements ActionListener {
private JLabel img = new JLabel();
private JTextField imgt = new JTextField(20);
private JButton imgb = new JButton("Set Image");
private JScrollPane scr;
private JPanel north = new JPanel();
public void actionPerformed (ActionEvent ae) {
this.remove(scr);
img = new JLabel(new ImageIcon(imgt.getText()));
scr = new JScrollPane(img);
this.getContentPane().add(scr, BorderLayout.CENTER);
this.validate();
}
public imageScroller() {
super("Scroller di Immagini");
this.setSize(400, 300);
north.setLayout(new FlowLayout());
north.add(imgt);
north.add(imgb);
img = new JLabel(new ImageIcon("Immagine.jpg"));
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(north, BorderLayout.NORTH);
scr = new JScrollPane(img);
scr.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scr.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
this.getContentPane().add(scr, BorderLayout.CENTER);
scr.setVisible(true);
imgb.addActionListener(this);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main (String[] args) {
imageScroller ims = new imageScroller();
}
}
In altre parole elimino lo scrollpane e ne creo uno nuovo: vedi se lo adatti con i gli internal frames.
79, già già