S
s.schmidt
Gast
hallo
wahrscheinlich liegt es daran, das Freitag ist, aber warum funktioniert es bei mir nicht, das ein JScrollPane ein Bild, welches in einem JLabel eingebunden wird, auch anzeigt???
lege ich das Bild direkt auf die ContentPane wie im folgenden, funktioniert es, das bild wird angezeigt.
Füge ich jedoch in den letzten Zeilen das JScrollPane ein und dann das JLabel mit dem Bild wiederrum da hinein, so funktoniert es einfach nicht.
Ich bräuchte aber ein Image Objekt, über welches ich scrollen kann.
Danke im Vorraus
Sebastian
wahrscheinlich liegt es daran, das Freitag ist, aber warum funktioniert es bei mir nicht, das ein JScrollPane ein Bild, welches in einem JLabel eingebunden wird, auch anzeigt???
lege ich das Bild direkt auf die ContentPane wie im folgenden, funktioniert es, das bild wird angezeigt.
Code:
public class test1 extends JFrame {
private JPanel jContentPane = null;
/**
* This is the default constructor
*/
public test1() {
super();
initialize();
this.setBackground(Color.red);
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(200, 200);
this.setContentPane(getJContentPane());
this.setTitle("JFrame");
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setBackground(Color.cyan);
jContentPane.setSize(150,150);
jContentPane.setLayout(new BorderLayout());
JScrollPane jsp = new JScrollPane();
BufferedImage i = null;
URL url = null;
try
{
url = new URL("http://www.wikipublisher.org/wiki/uploads/Examples/Testbild.s.gif");
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
i = ImageIO.read(url);
} catch (IOException e) {
e.printStackTrace();
}
jsp.setSize(100,100);
jsp.setBackground(Color.black);
//jContentPane.add(jsp);
//jsp.add(new JLabel(new ImageIcon(i)),0);
jContentPane.add(new JLabel(new ImageIcon(i)),0);
}
return jContentPane;
}
}
Füge ich jedoch in den letzten Zeilen das JScrollPane ein und dann das JLabel mit dem Bild wiederrum da hinein, so funktoniert es einfach nicht.
Code:
......
jsp.setSize(100,100);
jsp.setBackground(Color.black);
jContentPane.add(jsp);
jsp.add(new JLabel(new ImageIcon(i)),0);
//jContentPane.add(new JLabel(new ImageIcon(i)),0);
......
Ich bräuchte aber ein Image Objekt, über welches ich scrollen kann.
Danke im Vorraus
Sebastian