Ein Problem der Sichtbarkeit in meiner benutzerdefinierten BenutzeroberflächeJava

Java-Forum
Anonymous
 Ein Problem der Sichtbarkeit in meiner benutzerdefinierten Benutzeroberfläche

Post by Anonymous »

Um meine GUI zu erstellen, habe ich eine Reihe von Unterklassen von Jpanel erstellt. Jede von denen ein bestimmtes Layout -Problem löst. Andere, die innere mit einem BoxLayout , um die Komponenten auf bevorzugte Weise zu verteilen, die äußere mit einem BorderLayout die Komponenten auf ihre minimale Dimension drücken. TitleBorder , das im Konstruktor angegebene innere und dessen Ziel ist es, das Layout innerhalb der Felderset Zone einzurichten. Vor kurzem musste ich beide verwenden: Ich wollte, dass ein Jbutton und ein jTextArea übereinander angezeigt werden, ohne künstlich erweitert zu werden (d. H. In einem AltboxLayout_Jpanel ) und von einem Border (d. H. Der AltboxLayout_Jpanel code> code> code> code> fieldset ). Da alle meine Komponenten bereits getestet wurden, war ich mir sicher, dass es gut laufen würde.
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

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post