Java 类java.awt.DefaultFocusTraversalPolicy 实例源码

项目:batmass    文件:DisabledPanel.java   
/**
 * 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());
}
项目:cn1    文件:FocusManagerTest.java   
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);
}
项目:cn1    文件:JComponentTest.java   
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));
}
项目:polydes    文件:DisabledPanel.java   
/**
 *  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() );
}
项目:freeVM    文件:FocusManagerTest.java   
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);
}
项目:freeVM    文件:JComponentTest.java   
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));
}
项目:freeVM    文件:FocusManagerTest.java   
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);
}
项目:freeVM    文件:JComponentTest.java   
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));
}
项目:incubator-netbeans    文件:ConnectionAction.java   
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);
}
项目:gcs    文件:PdfDockable.java   
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());
}
项目:btrace.nb    文件:PIDSelector.java   
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);
        }
项目:btrace.nb    文件:PIDSelector.java   
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);
        }
项目:cn1    文件:FocusManager.java   
@Deprecated
public static void disableSwingFocusManager() {
    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalPolicy(new DefaultFocusTraversalPolicy());
    focusManagerEnabled = false;
}
项目:freeVM    文件:FocusManager.java   
public static void disableSwingFocusManager() {
    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalPolicy(new DefaultFocusTraversalPolicy());
    focusManagerEnabled = false;
}
项目:freeVM    文件:FocusManager.java   
@Deprecated
public static void disableSwingFocusManager() {
    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalPolicy(new DefaultFocusTraversalPolicy());
    focusManagerEnabled = false;
}
项目:jdk8u-jdk    文件:InitialFTP_AWT.java   
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.");
}
项目:openjdk-jdk10    文件:InitialFTP_AWT.java   
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.");
}
项目:openjdk9    文件:InitialFTP_AWT.java   
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.");
}
项目:jdk8u_jdk    文件:InitialFTP_AWT.java   
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.");
}
项目:lookaside_java-1.8.0-openjdk    文件:InitialFTP_AWT.java   
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.");
}
项目:infobip-open-jdk-8    文件:InitialFTP_AWT.java   
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.");
}
项目:jdk8u-dev-jdk    文件:InitialFTP_AWT.java   
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.");
}
项目:OLD-OpenJDK8    文件:InitialFTP_AWT.java   
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.");
}
项目:openjdk-jdk7u-jdk    文件:InitialFTP_AWT.java   
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.");
}
项目:openjdk-icedtea7    文件:InitialFTP_AWT.java   
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.");
}