Hallo ich wollte mir mal ein einfaches Applet erstellen wo ich die unterschiede zwischen den Layouts grafisch mir anschauen kann , aber es geht schon beim ersten code nicht.
Kann mir da bitte jemand helfen ?
Danke .
add.() fundktioniert nicht
i[HIGHLIGHT="Java"]mport javax.swing.*;
import java.awt.*;
public class BorderLayout extends JApplet {
/**
* Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init() {
Container cp = getContentPane();
JPanel panel = new JPanel(new BorderLayout(6, 6));
cp.add(BorderLayout.TOP_ALIGNMENT, new JButton("North"));
cp.add(BorderLayout.BOTTOM_ALIGNMENT, new JButton("North"));
cp.add(BorderLayout.LEFT_ALIGNMENT, new JButton("North"));
cp.add(BorderLayout.RIGHT_ALIGNMENT, new JButton("North"));
cp.add(BorderLayout.CENTER_ALIGNMENT, new JButton("North"));
// TODO start asynchronous download of heavy resources
}
// TODO overwrite start(), stop() and destroy() methods
}[/HIGHLIGHT]
PS: Ich habe keine Symbolleiste, wo mit ich den Txt editieren ,also BB Code verwenden kann..mhhh
[HIGHLIGHT="Java"]import javax.swing.*;
import java.awt.*;
public class JButton extends JFrame {
JButton button;
public JButton() {
Container cp = getContentPane();
button = new JButton("Button 1");
cp.add(button);
}
public static void main (String [] args) {
JButton mybutton = new JButton();
mybutton.pack();
mybutton.show();
}
}[/HIGHLIGHT]
Ich wäre euch auch sehr dankbar , wenn jemand hier drauf schaut.
Die Zeile solle ein Fehler sein : button = new JButton("Button 1");
Ich habe den Code von einen UNI Script übernommen, und es geht nicht...grrr
Kann mir da bitte jemand helfen ?
Danke .
add.() fundktioniert nicht
i[HIGHLIGHT="Java"]mport javax.swing.*;
import java.awt.*;
public class BorderLayout extends JApplet {
/**
* Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init() {
Container cp = getContentPane();
JPanel panel = new JPanel(new BorderLayout(6, 6));
cp.add(BorderLayout.TOP_ALIGNMENT, new JButton("North"));
cp.add(BorderLayout.BOTTOM_ALIGNMENT, new JButton("North"));
cp.add(BorderLayout.LEFT_ALIGNMENT, new JButton("North"));
cp.add(BorderLayout.RIGHT_ALIGNMENT, new JButton("North"));
cp.add(BorderLayout.CENTER_ALIGNMENT, new JButton("North"));
// TODO start asynchronous download of heavy resources
}
// TODO overwrite start(), stop() and destroy() methods
}[/HIGHLIGHT]
PS: Ich habe keine Symbolleiste, wo mit ich den Txt editieren ,also BB Code verwenden kann..mhhh
[HIGHLIGHT="Java"]import javax.swing.*;
import java.awt.*;
public class JButton extends JFrame {
JButton button;
public JButton() {
Container cp = getContentPane();
button = new JButton("Button 1");
cp.add(button);
}
public static void main (String [] args) {
JButton mybutton = new JButton();
mybutton.pack();
mybutton.show();
}
}[/HIGHLIGHT]
Ich wäre euch auch sehr dankbar , wenn jemand hier drauf schaut.
Die Zeile solle ein Fehler sein : button = new JButton("Button 1");
Ich habe den Code von einen UNI Script übernommen, und es geht nicht...grrr
Zuletzt bearbeitet von einem Moderator: