本文整理汇总了Java中java.awt.DefaultFocusTraversalPolicy类的典型用法代码示例。如果您正苦于以下问题:Java DefaultFocusTraversalPolicy类的具体用法?Java DefaultFocusTraversalPolicy怎么用?Java DefaultFocusTraversalPolicy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultFocusTraversalPolicy类属于java.awt包,在下文中一共展示了DefaultFocusTraversalPolicy类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DisabledPanel
import java.awt.DefaultFocusTraversalPolicy; //导入依赖的package包/类
/**
* Create a DisablePanel for the specified Container using the specified
* disabled color.
*
* @param disabledColor the background color of the GlassPane
* @param container a Container to be added to this DisabledPanel
*/
public DisabledPanel(Container container, Color disabledColor) {
setLayout(new OverlapLayout());
add(container);
glassPane = new GlassPane();
add(glassPane);
if (disabledColor != null) {
glassPane.setBackground(disabledColor);
}
setFocusTraversalPolicy(new DefaultFocusTraversalPolicy());
}
示例2: testIsFocusManagerEnabled
import java.awt.DefaultFocusTraversalPolicy; //导入依赖的package包/类
public void testIsFocusManagerEnabled() throws Exception {
assertTrue(FocusManager.isFocusManagerEnabled());
assertFalse(KeyboardFocusManager.getCurrentKeyboardFocusManager()
.getDefaultFocusTraversalPolicy() instanceof DefaultFocusTraversalPolicy);
FocusManager.disableSwingFocusManager();
assertFalse(FocusManager.isFocusManagerEnabled());
assertTrue(KeyboardFocusManager.getCurrentKeyboardFocusManager()
.getDefaultFocusTraversalPolicy() instanceof DefaultFocusTraversalPolicy);
}
示例3: testSetNextFocusableComponent
import java.awt.DefaultFocusTraversalPolicy; //导入依赖的package包/类
public void testSetNextFocusableComponent() {
JComponent container = new JPanel();
JComponent panel1 = new JButton();
JComponent panel2 = new JButton();
PropertyChangeController changeListener = new PropertyChangeController();
panel.addPropertyChangeListener(changeListener);
panel.setNextFocusableComponent(panel1);
changeListener.checkLastPropertyFired(panel, "nextFocus", null, panel1);
changeListener.reset();
panel.setNextFocusableComponent(panel2);
changeListener.checkLastPropertyFired(panel, "nextFocus", panel1, panel2);
changeListener.reset();
panel.setNextFocusableComponent(panel2);
assertFalse("event's not fired", changeListener.isChanged());
JFrame frame = new JFrame();
container.add(panel1);
container.add(panel2);
frame.getContentPane().add(container);
frame.pack();
container.setFocusCycleRoot(true);
container.setFocusTraversalPolicy(new DefaultFocusTraversalPolicy());
panel1.setNextFocusableComponent(panel2);
assertNull(container.getFocusTraversalPolicy().getComponentBefore(container, panel1));
assertEquals(panel2, container.getFocusTraversalPolicy().getComponentAfter(container,
panel1));
assertEquals(panel1, container.getFocusTraversalPolicy().getComponentBefore(container,
panel2));
assertNull(container.getFocusTraversalPolicy().getComponentAfter(container, panel2));
}
示例4: DisabledPanel
import java.awt.DefaultFocusTraversalPolicy; //导入依赖的package包/类
/**
* Create a DisablePanel for the specified Container using the specified
* disabled color.
*
* @param disabledColor the background color of the GlassPane
* @param container a Container to be added to this DisabledPanel
*/
public DisabledPanel(Container container, Color disabledColor)
{
setLayout( new OverlapLayout() );
add( container );
glassPane = new GlassPane();
add( glassPane );
if (disabledColor != null)
glassPane.setBackground( disabledColor );
setFocusTraversalPolicy( new DefaultFocusTraversalPolicy() );
}
示例5: initComponents
import java.awt.DefaultFocusTraversalPolicy; //导入依赖的package包/类
private void initComponents() {
setLayout(new BorderLayout(4, 0));
setBorder(new EmptyBorder(0, 2, 0, 8));
setOpaque(false);
setFocusTraversalPolicyProvider(true);
setFocusTraversalPolicy(new DefaultFocusTraversalPolicy() {
@Override
public Component getDefaultComponent(Container aContainer) {
if (!SwingUtilities.isEventDispatchThread()) {
return null;
}
final EditorCookie ec = actionContext.lookup(
EditorCookie.class);
if (ec != null) {
JEditorPane[] panes = ec.getOpenedPanes();
if (panes != null) {
for (JEditorPane pane : panes) {
if (pane.isShowing()) {
return pane;
}
}
}
}
return null;
}
});
combo = new JComboBox();
combo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
DatabaseConnection dbconn = (DatabaseConnection)combo.getSelectedItem();
combo.setToolTipText(dbconn != null ? dbconn.getDisplayName() : null);
}
});
combo.setOpaque(false);
combo.setModel(new DefaultComboBoxModel(
new String[] { NbBundle.getMessage(ToolbarPresenter.class, "ConnectionAction.ToolbarPresenter.LoadingConnections") }));
combo.setRenderer(new DatabaseConnectionRenderer());
String accessibleName = NbBundle.getMessage(ConnectionAction.class, "LBL_DatabaseConnection");
combo.getAccessibleContext().setAccessibleName(accessibleName);
combo.getAccessibleContext().setAccessibleDescription(accessibleName);
combo.setPreferredSize (new Dimension (400, combo.getPreferredSize ().height));
add(combo, BorderLayout.CENTER);
comboLabel = new JLabel();
Mnemonics.setLocalizedText(comboLabel, NbBundle.getMessage(ConnectionAction.class, "LBL_ConnectionAction"));
comboLabel.setOpaque(false);
comboLabel.setLabelFor(combo);
add(comboLabel, BorderLayout.WEST);
}
示例6: PdfDockable
import java.awt.DefaultFocusTraversalPolicy; //导入依赖的package包/类
public PdfDockable(PdfRef pdfRef, int page, String highlight) {
super(new BorderLayout());
mFile = pdfRef.getFile();
int pageCount = 9999;
try {
mPdf = PDDocument.load(pdfRef.getFile(), MemoryUsageSetting.setupMixed(50 * 1024 * 1024));
pageCount = mPdf.getNumberOfPages();
} catch (Exception exception) {
Log.error(exception);
}
mToolbar = new Toolbar();
mZoomInButton = new IconButton(StdImage.get("ZoomIn"), formatWithKey(SCALE_DOC_UP, KeyStroke.getKeyStroke('=')), () -> mPanel.zoomIn()); //$NON-NLS-1$
mToolbar.add(mZoomInButton);
mZoomOutButton = new IconButton(StdImage.get("ZoomOut"), formatWithKey(SCALE_DOC_DOWN, KeyStroke.getKeyStroke('-')), () -> mPanel.zoomOut()); //$NON-NLS-1$
mToolbar.add(mZoomOutButton);
mActualSizeButton = new IconButton(StdImage.get("ActualSize"), formatWithKey(ACTUAL_SIZE, KeyStroke.getKeyStroke('1')), () -> mPanel.actualSize()); //$NON-NLS-1$
mToolbar.add(mActualSizeButton);
mZoomStatus = new JLabel("100%"); //$NON-NLS-1$
mToolbar.add(mZoomStatus);
mPageField = new EditorField(new DefaultFormatterFactory(new IntegerFormatter(1, pageCount, false)), event -> {
if (mPanel != null) {
int pageIndex = ((Integer) mPageField.getValue()).intValue() - 1;
int newPageIndex = mPanel.goToPageIndex(pageIndex, null);
if (pageIndex != newPageIndex) {
mPageField.setValue(Integer.valueOf(newPageIndex + 1));
} else {
mPanel.requestFocusInWindow();
}
}
}, SwingConstants.RIGHT, Integer.valueOf(page), Integer.valueOf(9999), null);
mToolbar.add(mPageField, Toolbar.LAYOUT_EXTRA_BEFORE);
mPageStatus = new JLabel("/ -"); //$NON-NLS-1$
mToolbar.add(mPageStatus);
mPreviousPageButton = new IconButton(StdImage.get("PageUp"), formatWithKey(PREVIOUS_PAGE, KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0)), () -> mPanel.previousPage()); //$NON-NLS-1$
mToolbar.add(mPreviousPageButton);
mNextPageButton = new IconButton(StdImage.get("PageDown"), formatWithKey(NEXT_PAGE, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0)), () -> mPanel.nextPage()); //$NON-NLS-1$
mToolbar.add(mNextPageButton);
add(mToolbar, BorderLayout.NORTH);
mPanel = new PdfPanel(this, mPdf, pdfRef, page, highlight);
add(new JScrollPane(mPanel), BorderLayout.CENTER);
setFocusCycleRoot(true);
setFocusTraversalPolicy(new DefaultFocusTraversalPolicy());
}
示例7: initComponents
import java.awt.DefaultFocusTraversalPolicy; //导入依赖的package包/类
private void initComponents() {
setLayout(new BorderLayout(4, 0));
setBorder(new EmptyBorder(0, 4, 0, 4));
setOpaque(false);
setFocusTraversalPolicyProvider(true);
setFocusTraversalPolicy(new DefaultFocusTraversalPolicy() {
@Override
public Component getDefaultComponent(Container aContainer) {
final EditorCookie ec = actionContext.lookup(
EditorCookie.class);
if (ec != null) {
JEditorPane[] panes = ec.getOpenedPanes();
if (panes != null) {
for (JEditorPane pane : panes) {
if (pane.isShowing()) {
return pane;
}
}
}
}
return null;
}
});
combo = new JComboBox();
combo.addItemListener((ItemEvent e) -> {
RunningVM vm = (RunningVM) combo.getSelectedItem();
combo.setToolTipText(vm != null ? vm.toString() : null);
});
combo.setOpaque(false);
model = new RunningVmsModel(actionContext);
combo.setModel(model);
combo.setRenderer(new VMRenderer());
String accessibleName = NbBundle.getMessage(PIDSelector.class, "LBL_RunningVM");
combo.getAccessibleContext().setAccessibleName(accessibleName);
combo.getAccessibleContext().setAccessibleDescription(accessibleName);
combo.setPreferredSize(new Dimension(Math.min(combo.getPreferredSize().width, 400), combo.getPreferredSize().height));
comboLabel = new JLabel();
Mnemonics.setLocalizedText(comboLabel, NbBundle.getMessage(PIDSelector.class, "LBL_SelectVM"));
comboLabel.setOpaque(false);
comboLabel.setLabelFor(combo);
// comboLabel.setFont(comboLabel.getFont().deriveFont(Font.BOLD));
add(comboLabel, BorderLayout.WEST);
add(combo, BorderLayout.CENTER);
}
示例8: disableSwingFocusManager
import java.awt.DefaultFocusTraversalPolicy; //导入依赖的package包/类
@Deprecated
public static void disableSwingFocusManager() {
KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalPolicy(new DefaultFocusTraversalPolicy());
focusManagerEnabled = false;
}
示例9: disableSwingFocusManager
import java.awt.DefaultFocusTraversalPolicy; //导入依赖的package包/类
public static void disableSwingFocusManager() {
KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalPolicy(new DefaultFocusTraversalPolicy());
focusManagerEnabled = false;
}
示例10: main
import java.awt.DefaultFocusTraversalPolicy; //导入依赖的package包/类
public static void main(String[] args) {
AWTFrame f0 = new AWTFrame("frame0");
f0.setVisible(true);
InitialFTP.test(f0, DefaultFocusTraversalPolicy.class);
AWTFrame f1 = new AWTFrame("frame1");
f1.setVisible(true);
InitialFTP.test(f1, DefaultFocusTraversalPolicy.class);
System.out.println("Test passed.");
}