當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。