当前位置: 技术问答>java相关
努力努力再努力,帮忙帮忙来帮忙!
来源: 互联网 发布时间:2015-10-18
本文导语: import java.awt.*; import javax.swing.*; public class GridBagLayoutPane extends JPanel { public GridBagLayoutPane() { this.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.insets = new...
import java.awt.*;
import javax.swing.*;
public class GridBagLayoutPane extends JPanel {
public GridBagLayoutPane() {
this.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(5,5,5,5);
c.gridx = 0; c.gridy = 0; c.gridwidth = 4; c.gridheight=4;
c.weightx = c.weighty = 1.0;
this.add(new JButton("Button #1"), c);
c.gridx = 4; c.gridy = 0; c.gridwidth = 1; c.gridheight=1;
c.weightx = c.weighty = 0.0;
import javax.swing.*;
public class GridBagLayoutPane extends JPanel {
public GridBagLayoutPane() {
this.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(5,5,5,5);
c.gridx = 0; c.gridy = 0; c.gridwidth = 4; c.gridheight=4;
c.weightx = c.weighty = 1.0;
this.add(new JButton("Button #1"), c);
c.gridx = 4; c.gridy = 0; c.gridwidth = 1; c.gridheight=1;
c.weightx = c.weighty = 0.0;
|
public static void main(String[] args) {
GridBagLayoutPane p=new GridBagLayoutPane();
JFrame f = new JFrame();
f.getContentPane().add(p);
f.setSize(300,200);
f.setVisible(true);
}
GridBagLayoutPane p=new GridBagLayoutPane();
JFrame f = new JFrame();
f.getContentPane().add(p);
f.setSize(300,200);
f.setVisible(true);
}
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。