Java Code Examples for javax.swing.JPopupMenu#setLightWeightPopupEnabled()

The following examples show how to use javax.swing.JPopupMenu#setLightWeightPopupEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicDatePickerUI.java    From microba with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected void installComponents() {
	field = new JFormattedTextField(createFormatterFactory());
	field.setValue(peer.getDate());
	field.setFocusLostBehavior(peer.getFocusLostBehavior());
	field.setEditable(peer.isFieldEditable());
	field.setToolTipText(peer.getToolTipText());
	// button
	button = new JButton();
	button.setFocusable(false);
	button.setMargin(new Insets(0, 0, 0, 0));
	button.setToolTipText(peer.getToolTipText());

	setSimpeLook(false);
	// calendar
	calendarPane = new CalendarPane(peer.getStyle());
	calendarPane.setShowTodayButton(peer.isShowTodayButton());
	calendarPane.setFocusLostBehavior(JFormattedTextField.REVERT);
	calendarPane.setFocusCycleRoot(true);
	calendarPane.setBorder(BorderFactory.createEmptyBorder(1, 3, 0, 3));
	calendarPane.setStripTime(false);
	calendarPane.setLocale(peer.getLocale());
	calendarPane.setZone(peer.getZone());
	calendarPane.setFocusable(peer.isDropdownFocusable());
	calendarPane.setColorOverrideMap(peer.getColorOverrideMap());
	// popup
	popup = new JPopupMenu();
	popup.setLayout(new BorderLayout());
	popup.add(calendarPane, BorderLayout.CENTER);
	popup.setLightWeightPopupEnabled(true);
	// add
	peer.setLayout(new BorderLayout());

	switch (peer.getPickerStyle()) {
	case DatePicker.PICKER_STYLE_FIELD_AND_BUTTON:
		peer.add(field, BorderLayout.CENTER);
		peer.add(button, BorderLayout.EAST);
		break;
	case DatePicker.PICKER_STYLE_BUTTON:
		peer.add(button, BorderLayout.EAST);
		break;
	}

	peer.revalidate();
	peer.repaint();

	componentListener = new ComponentListener();

	button.addActionListener(componentListener);
	field.addPropertyChangeListener(componentListener);

	calendarPane.addPropertyChangeListener(componentListener);
	calendarPane.addCommitListener(componentListener);
	calendarPane.addActionListener(componentListener);

	peerDateChanged(peer.getDate());
}