当前位置: 首页>>代码示例>>Java>>正文


Java JPasswordField.setPreferredSize方法代码示例

本文整理汇总了Java中javax.swing.JPasswordField.setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java JPasswordField.setPreferredSize方法的具体用法?Java JPasswordField.setPreferredSize怎么用?Java JPasswordField.setPreferredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JPasswordField的用法示例。


在下文中一共展示了JPasswordField.setPreferredSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DBMSConnectionWindow

import javax.swing.JPasswordField; //导入方法依赖的package包/类
public DBMSConnectionWindow(JFrame owner) {
	super(owner);
	
	dbmsList = new JComboBox<String>(DBMS_LIST);
	hostname = new JTextField();
	port = new JTextField();
	username = new JTextField();
	password = new JPasswordField();
	nextButton = new JButton("✔ Next");
	
	hostname.setText(DEFAULT_HOSTNAME);
	port.setText(DEFAULT_PORT);
	username.setText(DEFAULT_USERNAME);
	password.setText(DEFAULT_PASSWORD);
	
	dbmsList.setPreferredSize(new Dimension(TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT));
	hostname.setPreferredSize(new Dimension(TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT));
	port.setPreferredSize(new Dimension(TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT));
	username.setPreferredSize(new Dimension(TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT));
	password.setPreferredSize(new Dimension(TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT));
	
	JPanel mainContainer = new JPanel();
	mainContainer.setLayout(new BoxLayout(mainContainer, BoxLayout.Y_AXIS));
	mainContainer.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
	
	JPanel dbmsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
	dbmsPanel.add(new JLabel("DBMS: "));
	dbmsPanel.add(dbmsList);
	
	JPanel hostnamePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
	hostnamePanel.add(new JLabel("Hostname: "));
	hostnamePanel.add(hostname);
	
	JPanel portPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
	portPanel.add(new JLabel("Port: "));
	portPanel.add(port);
	
	JPanel usernamePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
	usernamePanel.add(new JLabel("Username: "));
	usernamePanel.add(username);
	
	JPanel passwordPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
	passwordPanel.add(new JLabel("Password: "));
	passwordPanel.add(password);
	
	JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
	buttonsPanel.add(nextButton);
	
	mainContainer.add(dbmsPanel);
	mainContainer.add(hostnamePanel);
	mainContainer.add(portPanel);
	mainContainer.add(usernamePanel);
	mainContainer.add(passwordPanel);
	mainContainer.add(buttonsPanel);
	add(mainContainer);
	
	buildWindow();
	pack();
}
 
开发者ID:tteguayco,项目名称:JITRAX,代码行数:60,代码来源:DBMSConnectionWindow.java


注:本文中的javax.swing.JPasswordField.setPreferredSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。