Hi Leute.
Ich habe ein Problem damit, aus einer anderen Klasse einen String aufzurufen.
[code=Java]public class Kalendarwoche {
@XmlElement(name = "Random1", required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected String random1;
@XmlElement(name = "Random2", required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected String random2;
@XmlElement(name = "Random3", required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected String random3;
/**
* Gets the value of the random1 property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRandom1() {
return random1;
}
/**
* Sets the value of the random1 property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRandom1(String value) {
this.random1 = value;
}
[/code]
der string aus dieser klasse soll in folgender klasse benutzt werden
[code=Java]public class Main extends JFrame {
public void Main() {
//Frame erstellen
UIManager.put("OptionPane.yesButtonText", "Ja");
UIManager.put("OptionPane.noButtonText", "Nein");
setSize(1000, 700);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setContentPane(new BackGroundPane("bg_main.jpg"));
setVisible(true);
addComponents();
}
public Main() {
super("TwitIt");
}
public static void main(String[] args) {
new Main();
}
class BackGroundPane extends JPanel {
Image img = null;
BackGroundPane(String imagefile) {
super(null);
if (imagefile != null) {
MediaTracker mt = new MediaTracker(this);
img = Toolkit.getDefaultToolkit().getImage(imagefile);
mt.addImage(img, 0);
try {
mt.waitForAll();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(img,0,0,this.getWidth(),this.getHeight(),this);
}
}
public void addComponents() {
//Komponenten initialisieren
Icon icon = new ImageIcon("send.gif");
Icon icon2 = new ImageIcon("random.gif");
Icon icon3 = new ImageIcon("logout.gif");
Icon icon4 = new ImageIcon("happy.gif");
Icon icon5 = new ImageIcon("angry.gif");
Icon icon6 = new ImageIcon("tired.gif");
Icon icon7 = new ImageIcon("frightened.gif");
Icon icon8 = new ImageIcon("bad.gif");
Icon icon9 = new ImageIcon("suprised.gif");
Icon icon10 = new ImageIcon("tweets.gif");
TextArea tt = new TextArea();
JTextArea tp = new JTextArea();
String wort = "Hase Haus Hose Helden";
tp.append(Hier muss der String rein);
tp.setLineWrap(true);
tp.setBorder(BorderFactory.createEtchedBorder());
...
[/code]
gruß
Alublech