Es war nicht mehr sichtbar. Ich weiß, dass es da ist (ich habe überprüft) und ich übernehme , es wird von der jTextArea abgedeckt, aber ich habe keine weiteren Informationen. Unten ist mein Code.
Code: Select all
public class StackOverflowQuestion extends JFrame {
private static final long serialVersionUID = -5644282466098799568L;
private JPanel contentPanel;
// Display area
private Fieldset fieldset;
private JButton button;
private JTextArea jTextArea;
/**
* Create the frame.
*/
public StackOverflowQuestion() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 300, 140);
contentPanel = new JPanel();
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPanel.setLayout(new BorderLayout(0, 0));
setContentPane(contentPanel);
// Testing new components
// JPanel fieldsetLayoutPanel = new JPanel();
// BoxLayout fieldsetLayout = new BoxLayout(fieldsetLayoutPanel, BoxLayout.PAGE_AXIS);
// fieldsetLayoutPanel.setLayout(fieldsetLayout);
JPanel fieldsetLayoutPanel_2 = new AltBoxLayout_JPanel(BoxLayout.PAGE_AXIS);
this.fieldset = new Fieldset("Fieldset title", fieldsetLayoutPanel_2, null);
this.button = new JButton("Button text");
this.jTextArea = new JTextArea("JTextArea here!");
this.jTextArea.setRows(5);
this.jTextArea.setColumns(20);
this.button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.out.println("Action executed: " + arg0.toString());
}});
fieldset.add(button);
fieldset.add(jTextArea);
contentPanel.add(fieldset);
System.out.println("Analysis of the components of the contentPanel:");
analyzeLayoutsOfComponentAndSubComponents(contentPanel, 0);
pack();
}
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
StackOverflowQuestion frame = new StackOverflowQuestion();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/** A method that studies the {@link JPanel} and its sub-{@link JPanel}s, iterating through all the component tree.
*
* @param c
* @param tab
*/
public static void analyzeLayoutsOfComponentAndSubComponents(JPanel c, int tab) {
System.out.println(repeatChar('\t', tab) + c.toString());
for(int i=0 ; i