(編輯) 好吧,我很可能會問錯誤的問題。JFrame中的兩個JPanels
我在發佈前檢查過佈局管理器,邊界佈局看起來與我希望達到的最接近。但是,它僅限於五個領域。
下面的界面我試圖分裂成不同的階級 interface image http://img821.imageshack.us/img821/2355/mockuphp.png
它由各種JPanels的,我真的不知道這件事,從要求所有以前的問題和閱讀了的圖片佈局教程因爲它看起來太複雜了。
所以我想我應該問的問題是 - 是否有可能通過使用佈局管理器使所有這些JPanel適合JFrame的外觀?如果沒有,是否有另一種方法來實現這一目標
我的目的是防止有一個長類的代碼。
(原問題) 我很清楚這裏有很多重複的問題,我已經閱讀了很多這些問題,但仍然不知道我的立場。
我是一個java的新手,真的需要幫助搞清楚這一點。
這是我想添加到JFrame的兩個面板。 (讓他們這麼簡單,這樣我就可以測試一旦它工作就繼續)。
第一的JPanel
package main;
/**
*
* @author Dell
*/
public class NewJPanel extends javax.swing.JPanel {
/**
* Creates new form NewJPanel
*/
public NewJPanel() {
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() {
jPanel1 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
}
第二面板是完全一樣的,只是它被稱爲NewJPanel1
我怎麼能並排把這兩個爲一個JFrame的一邊嗎?
您的閱讀材料肯定會引導您學習和使用版面管理器的建議,對不對?我會從GridLayout開始 - 谷歌教程,因爲它會解釋所有。編輯:你需要一些鏈接:[真正的大指數](http://docs.oracle.com/javase/tutorial/reallybigindex.html),[使用Swing組件](http://docs.oracle.com/ javase/tutorial/uiswing/components/index.html),[在容器中放置組件](http://docs.oracle.com/javase/tutorial/uiswing/layout/index.html),[GridLayout](http ://docs.oracle.com/javase/tutorial/uiswing/layout/grid.html)。 – 2012-02-28 22:43:24
佈局管理器教程:http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html – DNA 2012-02-28 22:45:16