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


Java LayoutFocusTraversalPolicy类代码示例

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


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

示例1: updateFocusTraversalPolicy

import javax.swing.LayoutFocusTraversalPolicy; //导入依赖的package包/类
/**
 * Sets a focus traversal policy that ignores invisible split pane components.
 */
private void updateFocusTraversalPolicy()
{
	setFocusTraversalPolicy(new LayoutFocusTraversalPolicy()
	{
		@Override
		protected boolean accept(Component component)
		{
			if (super.accept(component))
			{
				for (JSplitPane splitPane; (splitPane = (JSplitPane) SwingUtilities
						.getAncestorOfClass(JSplitPane.class, component)) != null; component = splitPane)
				{
					if (isChildComponentInvisible(splitPane, component))
					{
						return false;
					}
				}
				return true;
			}
			else
			{
				return false;
			}
		}
	});
	setFocusTraversalPolicyProvider(true);
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:31,代码来源:HomePane.java

示例2: createLayoutFocusTraversalPolicy

import javax.swing.LayoutFocusTraversalPolicy; //导入依赖的package包/类
private static FocusTraversalPolicy createLayoutFocusTraversalPolicy(Component initialComponent) {
    if (layoutFTPConstructor != null) {
        try {
            return layoutFTPConstructor.newInstance(initialComponent);
        } catch (IllegalArgumentException
                | InstantiationException
                | IllegalAccessException
                | InvocationTargetException ex) {
            // Ignore
        }
    }
    return new LayoutFocusTraversalPolicy();
}
 
开发者ID:JFormDesigner,项目名称:swing-jgoodies-forms,代码行数:14,代码来源:InternalFocusSetupUtils.java

示例3: rejectSettingFocusTraversalPolicyTwice

import javax.swing.LayoutFocusTraversalPolicy; //导入依赖的package包/类
@Test(expected=IllegalStateException.class)
public void rejectSettingFocusTraversalPolicyTwice() {
    FormBuilder.create()
        .columns("pref")
        .rows("pref")
        .focusTraversalPolicy(new ContainerOrderFocusTraversalPolicy())
        .focusTraversalPolicy(new LayoutFocusTraversalPolicy())
        .build();
}
 
开发者ID:JFormDesigner,项目名称:swing-jgoodies-forms,代码行数:10,代码来源:FormBuilderTest.java

示例4: JLightweightFrame

import javax.swing.LayoutFocusTraversalPolicy; //导入依赖的package包/类
/**
 * Constructs a new, initially invisible {@code JLightweightFrame}
 * instance.
 */
public JLightweightFrame() {
    super();
    copyBufferEnabled = "true".equals(AccessController.
        doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true")));

    add(rootPane, BorderLayout.CENTER);
    setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
    if (getGraphicsConfiguration().isTranslucencyCapable()) {
        setBackground(new Color(0, 0, 0, 0));
    }

    layoutSizeListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent e) {
            Dimension d = (Dimension)e.getNewValue();

            if ("preferredSize".equals(e.getPropertyName())) {
                content.preferredSizeChanged(d.width, d.height);

            } else if ("maximumSize".equals(e.getPropertyName())) {
                content.maximumSizeChanged(d.width, d.height);

            } else if ("minimumSize".equals(e.getPropertyName())) {
                content.minimumSizeChanged(d.width, d.height);
            }
        }
    };
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:33,代码来源:JLightweightFrame.java

示例5: initialize

import javax.swing.LayoutFocusTraversalPolicy; //导入依赖的package包/类
/**
 * <p><!-- Method description --></p>
 *
 */
private void initialize() {
    setLayout(new BorderLayout());
    add(getJPanel(), BorderLayout.NORTH);
    add(getListPanel(), BorderLayout.CENTER);
    setEnabled(false);
    setFocusCycleRoot(true);
    Dimension size = getPreferredSize();
    Dimension preferredSize = new Dimension(size.height, 200);
    setPreferredSize(preferredSize);

    //FocusTraversalPolicy policy = getFocusTraversalPolicy();
    setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {

        /*
         *  Warning, when a component should not be focused, I
         *  recursively call getComponentAfter, if all components should not be focused,
         * this could lead to an infinite loop.
         */
        @Override
        public Component getComponentAfter(final Container focusCycleRoot, final Component aComponent) {
            Component retval = super.getComponentAfter(focusCycleRoot, aComponent);
            if (retval == notesArea) {
                retval = this.getComponentAfter(focusCycleRoot, retval);
            }

            if (retval instanceof JList) {
                if (listPanel.getObservation().getAssociations().size() == 0) {
                    retval = this.getComponentAfter(focusCycleRoot, retval);
                }
            }

            return retval;
        }
    });
}
 
开发者ID:hohonuuli,项目名称:vars,代码行数:40,代码来源:RowEditorPanel.java

示例6: TopWindow

import javax.swing.LayoutFocusTraversalPolicy; //导入依赖的package包/类
/**
 * <p>
 * Constructs a Window instance.</p>
 */
public TopWindow() {
    super();

    URL iconURL = getClass().getResource("/images/orca.png");
    setIconImage(Toolkit.getDefaultToolkit().createImage(iconURL));

    int x, y, width, height;
    x = prefs.getInt(this.getClass().getName() + ".x", 0);
    y = prefs.getInt(this.getClass().getName() + ".y", 0);
    width = prefs.getInt(this.getClass().getName() + ".width", DEFAULT_WIDTH);
    height = prefs.getInt(this.getClass().getName() + ".height", DEFAULT_HEIGHT - FOOTER);

    if (System.getProperty("monsia.topwindow.width") != null) {
        width = Integer.parseInt(System.getProperty("monsia.topwindow.width"));
    }
    if (System.getProperty("monsia.topwindow.height") != null) {
        height = Integer.parseInt(System.getProperty("monsia.topwindow.height"));
    }
    if (System.getProperty("monsia.topwindow.x") != null) {
        x = Integer.parseInt(System.getProperty("monsia.topwindow.x"));
    }
    if (System.getProperty("monsia.topwindow.y") != null) {
        y = Integer.parseInt(System.getProperty("monsia.topwindow.y"));
    }

    this.setLocation(x, y);
    this.setSize(width, height);
    this.addComponentListener(this);
    this.setFocusCycleRoot(true);
    this.setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
}
 
开发者ID:montsuqi,项目名称:monsiaj,代码行数:36,代码来源:TopWindow.java

示例7: JLightweightFrame

import javax.swing.LayoutFocusTraversalPolicy; //导入依赖的package包/类
/**
 * Constructs a new, initially invisible {@code JLightweightFrame}
 * instance.
 */
public JLightweightFrame() {
    super();
    copyBufferEnabled = "true".equals(AccessController.
        doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true")));

    add(rootPane, BorderLayout.CENTER);
    setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
    if (getGraphicsConfiguration().isTranslucencyCapable()) {
        setBackground(new Color(0, 0, 0, 0));
    }

    layoutSizeListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent e) {
            Dimension d = (Dimension)e.getNewValue();

            if ("preferredSize".equals(e.getPropertyName())) {
                content.preferredSizeChanged(d.width, d.height);

            } else if ("maximumSize".equals(e.getPropertyName())) {
                content.maximumSizeChanged(d.width, d.height);

            } else if ("minimumSize".equals(e.getPropertyName())) {
                content.minimumSizeChanged(d.width, d.height);
            }
        }
    };

    repaintListener = (JComponent c, int x, int y, int w, int h) -> {
        Window jlf = SwingUtilities.getWindowAncestor(c);
        if (jlf != JLightweightFrame.this) {
            return;
        }
        Point p = SwingUtilities.convertPoint(c, x, y, jlf);
        Rectangle r = new Rectangle(p.x, p.y, w, h).intersection(
                new Rectangle(0, 0, bbImage.getWidth() / scaleFactor,
                              bbImage.getHeight() / scaleFactor));

        if (!r.isEmpty()) {
            notifyImageUpdated(r.x, r.y, r.width, r.height);
        }
    };

    SwingAccessor.getRepaintManagerAccessor().addRepaintListener(
        RepaintManager.currentManager(this), repaintListener);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:JLightweightFrame.java

示例8: JLightweightFrame

import javax.swing.LayoutFocusTraversalPolicy; //导入依赖的package包/类
/**
 * Constructs a new, initially invisible {@code JLightweightFrame}
 * instance.
 */
public JLightweightFrame() {
    super();
    AffineTransform defaultTransform =
                       getGraphicsConfiguration().getDefaultTransform();
    scaleFactorX = defaultTransform.getScaleX();
    scaleFactorY = defaultTransform.getScaleY();
    copyBufferEnabled = "true".equals(AccessController.
        doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true")));

    add(rootPane, BorderLayout.CENTER);
    setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
    if (getGraphicsConfiguration().isTranslucencyCapable()) {
        setBackground(new Color(0, 0, 0, 0));
    }

    layoutSizeListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent e) {
            Dimension d = (Dimension)e.getNewValue();

            if ("preferredSize".equals(e.getPropertyName())) {
                content.preferredSizeChanged(d.width, d.height);

            } else if ("maximumSize".equals(e.getPropertyName())) {
                content.maximumSizeChanged(d.width, d.height);

            } else if ("minimumSize".equals(e.getPropertyName())) {
                content.minimumSizeChanged(d.width, d.height);
            }
        }
    };

    repaintListener = (JComponent c, int x, int y, int w, int h) -> {
        Window jlf = SwingUtilities.getWindowAncestor(c);
        if (jlf != JLightweightFrame.this) {
            return;
        }
        Point p = SwingUtilities.convertPoint(c, x, y, jlf);
        Rectangle r = new Rectangle(p.x, p.y, w, h).intersection(
                new Rectangle(0, 0,
                      (int)Math.round(bbImage.getWidth() / scaleFactorX),
                      (int)Math.round(bbImage.getHeight() / scaleFactorY)));

        if (!r.isEmpty()) {
            notifyImageUpdated(r.x, r.y, r.width, r.height);
        }
    };

    SwingAccessor.getRepaintManagerAccessor().addRepaintListener(
        RepaintManager.currentManager(this), repaintListener);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:56,代码来源:JLightweightFrame.java

示例9: layoutComponents

import javax.swing.LayoutFocusTraversalPolicy; //导入依赖的package包/类
/**
 * Layouts the components displayed by this panel.
 */
private void layoutComponents()
{
	int labelAlignment = OperatingSystem.isMacOSX() ? GridBagConstraints.LINE_END : GridBagConstraints.LINE_START;
	// First row
	Insets labelInsets = new Insets(0, 2, 5, 3);
	Insets componentInsets = new Insets(0, 2, 3, 0);
	if (!OperatingSystem.isMacOSX())
	{
		labelInsets.top = 2;
		componentInsets.top = 2;
		componentInsets.right = 2;
	}
	add(this.categoryFilterLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.LINE_START,
			GridBagConstraints.HORIZONTAL, labelInsets, 0, 0));
	add(this.categoryFilterComboBox, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.LINE_START,
			GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
	// Second row
	if (OperatingSystem.isMacOSXLeopardOrSuperior())
	{
		add(this.searchTextField, new GridBagConstraints(0, 1, 2, 1, 0, 0, GridBagConstraints.LINE_START,
				GridBagConstraints.HORIZONTAL, new Insets(0, 0, 3, 0), 0, 0));
	}
	else
	{
		add(this.searchLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, labelAlignment, GridBagConstraints.NONE,
				labelInsets, 0, 0));
		add(this.searchTextField, new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.LINE_START,
				GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
	}
	// Last row
	JScrollPane listScrollPane = new JScrollPane(this.catalogFurnitureList);
	listScrollPane.getVerticalScrollBar().addAdjustmentListener(
			SwingTools.createAdjustmentListenerUpdatingScrollPaneViewToolTip(listScrollPane));
	listScrollPane.setPreferredSize(new Dimension(250, 250));
	listScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	add(listScrollPane, new GridBagConstraints(0, 2, 2, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
			new Insets(0, 0, 0, 0), 0, 0));
	SwingTools.installFocusBorder(this.catalogFurnitureList);
	
	setFocusTraversalPolicyProvider(true);
	setFocusTraversalPolicy(new LayoutFocusTraversalPolicy()
	{
		@Override
		public Component getDefaultComponent(Container aContainer)
		{
			EventQueue.invokeLater(new Runnable()
			{
				public void run()
				{
					// Return furniture list only at the first request  
					setFocusTraversalPolicyProvider(false);
				}
			});
			return catalogFurnitureList;
		}
	});
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:61,代码来源:FurnitureCatalogListPanel.java

示例10: StringDialog

import javax.swing.LayoutFocusTraversalPolicy; //导入依赖的package包/类
public StringDialog(JabRefFrame frame, BasePanel panel, BibDatabase base) {
    super(frame, StringDialog.class);
    this.panel = panel;
    this.base = base;

    sortStrings();

    helpAction = new HelpAction(Localization.lang("Help"), HelpFile.STRING_EDITOR);

    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            closeAction.actionPerformed(null);
        }
    });

    // We replace the default FocusTraversalPolicy with a subclass
    // that only allows the StringTable to gain keyboard focus.
    setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {

        @Override
        protected boolean accept(Component c) {
            return super.accept(c) && (c instanceof StringTable);
        }
    });

    JPanel pan = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    pan.setLayout(gbl);
    GridBagConstraints con = new GridBagConstraints();
    con.fill = GridBagConstraints.BOTH;
    con.weighty = 1;
    con.weightx = 1;

    StringTableModel stm = new StringTableModel(this, base);
    table = new StringTable(stm);
    if (!base.hasNoStrings()) {
        table.setRowSelectionInterval(0, 0);
    }

    gbl.setConstraints(table.getPane(), con);
    pan.add(table.getPane());

    JToolBar tlb = new OSXCompatibleToolbar();
    InputMap im = tlb.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap am = tlb.getActionMap();
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.STRING_DIALOG_ADD_STRING), "add");
    NewStringAction newStringAction = new NewStringAction(this);
    am.put("add", newStringAction);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.STRING_DIALOG_REMOVE_STRING), "remove");
    RemoveStringAction removeStringAction = new RemoveStringAction(this);
    am.put("remove", removeStringAction);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.SAVE_DATABASE), "save");
    am.put("save", saveAction);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", closeAction);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.HELP), "help");
    am.put("help", helpAction);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.UNDO), "undo");
    UndoAction undoAction = new UndoAction();
    am.put("undo", undoAction);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.REDO), "redo");
    RedoAction redoAction = new RedoAction();
    am.put("redo", redoAction);

    tlb.add(newStringAction);
    tlb.add(removeStringAction);
    tlb.addSeparator();
    tlb.add(helpAction);
    Container conPane = getContentPane();
    conPane.add(tlb, BorderLayout.NORTH);
    conPane.add(pan, BorderLayout.CENTER);

    setTitle(STRINGS_TITLE + ": "
            + panel.getBibDatabaseContext().getDatabaseFile().map(File::getName).orElse(GUIGlobals.UNTITLED_TITLE));
    WindowLocation pw = new WindowLocation(this, JabRefPreferences.STRINGS_POS_X, JabRefPreferences.STRINGS_POS_Y,
            JabRefPreferences.STRINGS_SIZE_X, JabRefPreferences.STRINGS_SIZE_Y);
    pw.displayWindowAtStoredLocation();
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:81,代码来源:StringDialog.java

示例11: main

import javax.swing.LayoutFocusTraversalPolicy; //导入依赖的package包/类
public static void main(String[] args) {
    SwingFrame f0 = new SwingFrame("frame0");
    f0.setVisible(true);

    InitialFTP.test(f0, LayoutFocusTraversalPolicy.class);

    SwingFrame f1 = new SwingFrame("frame1");
    f1.setVisible(true);

    InitialFTP.test(f1, LayoutFocusTraversalPolicy.class);

    System.out.println("Test passed.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:InitialFTP_Swing.java


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