1.WindowBuilder安装
这个Eclipse插件能够实现在Java Swing编程中各种控件的拖拽
下载地址:http://www.eclipse.org/windowbuilder/download.php
Eclipse 3.7的安装方法(其它版本Eclipse类似):http://download.eclipse.org/windowbuilder/WB/release/R201309271200/3.7/
2.使JPanel成为JDialog的父窗口
JPanel panel = new JPanel(); Window parentWindow = SwingUtilities.windowForComponent(panel); Frame parentFrame = (Frame)parentWindow; JDialog dialog = new JDialog(parentFrame); ...
JComboBox<String> myComboBox = new JComboBox<String>(array); myJTable.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(myComboBox));
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);// 最大化
//获得屏幕宽度
public double getScreenWidth(){
return Toolkit.getDefaultToolkit().getScreenSize().getWidth();
}
//获得屏幕高度
public double getScreenHeight(){
return Toolkit.getDefaultToolkit().getScreenSize().getHeight();
}
//将Frame居中
public void setFrameOnCenter(Window win){
Window window = win;
int width = (int) getScreenWidth();
int height = (int) getScreenHeight();
window.setLocation((width - window.getWidth()) / 2, (height - window.getHeight()) / 2);
}((TitledBorder)panel.getBorder()).setTitleFont(new Font("宋体", Font.BOLD, 16));
Java Swing的一些技巧总结,布布扣,bubuko.com
原文:http://blog.csdn.net/huhui_cs/article/details/21005191