0
我是java GUI中的新手,所以我現在面臨一個問題... 我已經使用Netbeans GUI Builder創建了一個GUI .. 我創建了一個名爲MainUI.java和gdUI.Java的文件 的MainUI.java包含這樣如果一個按鈕被點擊的JPanel隱藏邊框和按鈕,並從gdUI.java如何隱藏JPanel並在其他Java文件中打開另一個文件?
打開面板這裏的代碼,到目前爲止,我已經做了:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jPanel1.setVisible(false);
}
和gdUI代碼是:
package GUI;
public class gdUI extends javax.swing.JPanel {
/**
* Creates new form gdUI
*/
public gdUI() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setBackground(new java.awt.Color(255, 153, 51));
setMaximumSize(new java.awt.Dimension(600, 500));
setMinimumSize(new java.awt.Dimension(600, 500));
setPreferredSize(new java.awt.Dimension(600, 500));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 600, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 500, Short.MAX_VALUE)
);
}// </editor-fold>
// Variables declaration - do not modify
// End of variables declaration
}
當我點擊按鈕,我成功隱藏了當前的JPanel,我怎樣才能添加其他文件新的?
在此先感謝
['CardLayout '](http://stackoverflow.com/tags/cardlayout/info)可能是一個合適的選擇。 – trashgod