Wie mache ich es nochmal das ich z.b. in ein BoarderLayout im westen ein gridLayout mache. versteht ihr was ich meine. ein codebeispiel wäre super. Danke mal.
import java.awt.*;
import javax.swing.*;
public class LayoutTest extends JFrame {
public LayoutTest(String title) {
super(title);
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
setSize((int)dim.width*60/100, (int)dim.height*60/100);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel westPanel = new JPanel(new GridLayout(0, 1));
westPanel.setPreferredSize(new Dimension(getSize().width/4, 0));
JLabel redLabel = new JLabel();
redLabel.setBackground(Color.RED);
redLabel.setOpaque(true);
westPanel.add(redLabel);
JLabel yellowLabel = new JLabel();
yellowLabel.setBackground(Color.YELLOW);
yellowLabel.setOpaque(true);
westPanel.add(yellowLabel);
JLabel greenLabel = new JLabel();
greenLabel.setBackground(Color.GREEN);
greenLabel.setOpaque(true);
westPanel.add(greenLabel);
add(westPanel, BorderLayout.WEST);
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
new LayoutTest("LayoutTest").setVisible(true);
}
}
ein Panel is doch auch ein Frame oder nich?L-ectron-X hat gesagt.:"extra Frame"? Du meinst wohl ein Panel...
mika.fhdw hat gesagt.:HTML programmiert :lol:
deswegen auch das ":lol:" (LOL)Hobbit_Im_Blutrausch hat gesagt.:mika.fhdw hat gesagt.:HTML programmiert :lol:
Ich mag Leute, die sich als Programmierer sehen und damit angeben, nur weil sies geschaft haben nen html-head-body tag zu definieren :roll: