java怎么样控制jpanel空间的的大小,和位置
2个回答
展开全部
import org.javabuilders.layout.Size;
import javax.swing.*;
import javax.swing.text.AbstractDocument;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by IntelliJ IDEA.
* User: DELL
* Date: 11-11-7
* Time: 下午2:40
* To change this template use File | Settings | File Templates.
*/
public class MyDear extends JFrame{
static JFrame frame = new JFrame("我是窗口");
static JButton button = new JButton("按钮");
static JPanel panel = new JPanel();
public static void main(String[] args) {
frame.setBounds(0,0,300,300);
Container contain = frame.getContentPane();
panel.add(button);
panel.setBackground(Color.green);
panel.setPreferredSize(new Dimension(100,200));
contain.add(panel,BorderLayout.NORTH);
frame.setVisible(true);
}
}
import javax.swing.*;
import javax.swing.text.AbstractDocument;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by IntelliJ IDEA.
* User: DELL
* Date: 11-11-7
* Time: 下午2:40
* To change this template use File | Settings | File Templates.
*/
public class MyDear extends JFrame{
static JFrame frame = new JFrame("我是窗口");
static JButton button = new JButton("按钮");
static JPanel panel = new JPanel();
public static void main(String[] args) {
frame.setBounds(0,0,300,300);
Container contain = frame.getContentPane();
panel.add(button);
panel.setBackground(Color.green);
panel.setPreferredSize(new Dimension(100,200));
contain.add(panel,BorderLayout.NORTH);
frame.setVisible(true);
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询