JAVA中GridLayout的布局问题 如图,如何弄成这样的布局,
因为GridLayout的布局是均匀的大小我要将三个panel放入这三块区域中,大小要想如图样,求高手给出布局代码谢了设计成如图,右边的那个样子,求高手给出界面布局代码~...
因为GridLayout的布局是均匀的大小我要将三个panel放入这三块区域中,大小要想如图样,求高手给出布局代码 谢了
设计成如图,右边的那个样子,求高手给出界面布局代码~~~
符合要求的哥给10元移动充值卡~~~!~!!! 展开
设计成如图,右边的那个样子,求高手给出界面布局代码~~~
符合要求的哥给10元移动充值卡~~~!~!!! 展开
展开全部
public class NewJFrame1 extends javax.swing.JFrame {
/** Creates new form NewJFrame1 */
public NewJFrame1() {
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() {
java.awt.GridBagConstraints gridBagConstraints;
jScrollPane1 = new javax.swing.JScrollPane();
jTree1 = new javax.swing.JTree();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setName("Form"); // NOI18N
getContentPane().setLayout(new java.awt.GridBagLayout());
jScrollPane1.setName("jScrollPane1"); // NOI18N
jTree1.setName("jTree1"); // NOI18N
jScrollPane1.setViewportView(jTree1);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
getContentPane().add(jScrollPane1, gridBagConstraints);
jLabel1.setText(org.openide.util.NbBundle.getMessage(NewJFrame1.class, "NewJFrame1.jLabel1.text")); // NOI18N
jLabel1.setName("jLabel1"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipady = 15;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
getContentPane().add(jLabel1, gridBagConstraints);
jLabel2.setText(org.openide.util.NbBundle.getMessage(NewJFrame1.class, "NewJFrame1.jLabel2.text")); // NOI18N
jLabel2.setName("jLabel2"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipady = 15;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
getContentPane().add(jLabel2, gridBagConstraints);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame1().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTree jTree1;
// End of variables declaration
}
/** Creates new form NewJFrame1 */
public NewJFrame1() {
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() {
java.awt.GridBagConstraints gridBagConstraints;
jScrollPane1 = new javax.swing.JScrollPane();
jTree1 = new javax.swing.JTree();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setName("Form"); // NOI18N
getContentPane().setLayout(new java.awt.GridBagLayout());
jScrollPane1.setName("jScrollPane1"); // NOI18N
jTree1.setName("jTree1"); // NOI18N
jScrollPane1.setViewportView(jTree1);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
getContentPane().add(jScrollPane1, gridBagConstraints);
jLabel1.setText(org.openide.util.NbBundle.getMessage(NewJFrame1.class, "NewJFrame1.jLabel1.text")); // NOI18N
jLabel1.setName("jLabel1"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipady = 15;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
getContentPane().add(jLabel1, gridBagConstraints);
jLabel2.setText(org.openide.util.NbBundle.getMessage(NewJFrame1.class, "NewJFrame1.jLabel2.text")); // NOI18N
jLabel2.setName("jLabel2"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipady = 15;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
getContentPane().add(jLabel2, gridBagConstraints);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame1().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTree jTree1;
// End of variables declaration
}
展开全部
GridLayout是实现不了的
1.最简单,套两层BorderLayout
2.使用GridBagLayout
3.使用自定义布局
1.最简单,套两层BorderLayout
2.使用GridBagLayout
3.使用自定义布局
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
先分上下两个panel,再在下面的panel里面再分2个panel
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
应该不行吧,GridLayout只能平均分布几个模块吧。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询