javax.swing.LayoutFocusTraversalPolicy Java Examples

The following examples show how to use javax.swing.LayoutFocusTraversalPolicy. 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: SwingControl.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
protected void populate() {
	if (isDisposed()) { return; }
	if (!populated) {
		populated = true;
		frame = SWT_AWT.new_Frame(this);
		EventQueue.invokeLater(() -> {
			applet = new JApplet();
			if (PlatformHelper.isWindows()) {
				applet.setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
			}
			frame.add(applet);
			final Java2DDisplaySurface surface = createSwingComponent();
			applet.getRootPane().getContentPane().add(surface);
			WorkaroundForIssue2476.installOn(applet, surface);
			WorkbenchHelper.asyncRun(() -> SwingControl.this.getParent().layout(true, true));
		});
	}
}
 
Example #2
Source File: JLightweightFrame.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
            }
        }
    };
}
 
Example #3
Source File: JLightweightFrame.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
            }
        }
    };
}
 
Example #4
Source File: JLightweightFrame.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #5
Source File: JLightweightFrame.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #6
Source File: JLightweightFrame.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #7
Source File: JLightweightFrame.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #8
Source File: JLightweightFrame.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #9
Source File: JLightweightFrame.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #10
Source File: BlazeConsoleView.java    From intellij with Apache License 2.0 4 votes vote down vote up
void createToolWindowContent(ToolWindow toolWindow) {
  // Create runner UI layout
  RunnerLayoutUi.Factory factory = RunnerLayoutUi.Factory.getInstance(project);
  RunnerLayoutUi layoutUi = factory.create("", "", "session", project);
  layoutUi.getOptions().setMoveToGridActionEnabled(false).setMinimizeActionEnabled(false);

  Content console =
      layoutUi.createContent(
          BlazeConsoleToolWindowFactory.ID, consoleView.getComponent(), "", null, null);
  console.setCloseable(false);
  layoutUi.addContent(console, 0, PlaceInGrid.right, false);

  // Adding actions
  DefaultActionGroup group = new DefaultActionGroup();
  layoutUi.getOptions().setLeftToolbar(group, TOOLBAR_ACTION_PLACE);

  // Initializing prev and next occurrences actions
  OccurenceNavigator navigator = fromConsoleView(consoleView);
  CommonActionsManager actionsManager = CommonActionsManager.getInstance();
  AnAction prevAction = actionsManager.createPrevOccurenceAction(navigator);
  prevAction.getTemplatePresentation().setText(navigator.getPreviousOccurenceActionName());
  AnAction nextAction = actionsManager.createNextOccurenceAction(navigator);
  nextAction.getTemplatePresentation().setText(navigator.getNextOccurenceActionName());

  group.addAll(prevAction, nextAction);

  AnAction[] consoleActions = consoleView.createConsoleActions();
  for (AnAction action : consoleActions) {
    if (!shouldIgnoreAction(action)) {
      group.add(action);
    }
  }
  group.add(new StopAction());

  JComponent layoutComponent = layoutUi.getComponent();

  layoutComponent.setFocusTraversalPolicyProvider(true);
  layoutComponent.setFocusTraversalPolicy(
      new LayoutFocusTraversalPolicy() {
        @Override
        public Component getDefaultComponent(Container container) {
          if (container.equals(layoutComponent)) {
            return consoleView.getPreferredFocusableComponent();
          }
          return super.getDefaultComponent(container);
        }
      });

  Content content =
      ContentFactory.SERVICE.getInstance().createContent(layoutComponent, null, true);
  content.setCloseable(false);
  toolWindow.getContentManager().addContent(content);
}
 
Example #11
Source File: JLightweightFrame.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #12
Source File: JLightweightFrame.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #13
Source File: JLightweightFrame.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #14
Source File: JLightweightFrame.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #15
Source File: JLightweightFrame.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #16
Source File: JLightweightFrame.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #17
Source File: InitialFTP_Swing.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
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.");
}
 
Example #18
Source File: InitialFTP_Swing.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
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.");
}
 
Example #19
Source File: InitialFTP_Swing.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
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.");
}
 
Example #20
Source File: InitialFTP_Swing.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
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.");
}
 
Example #21
Source File: InitialFTP_Swing.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
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.");
}
 
Example #22
Source File: InitialFTP_Swing.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
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.");
}
 
Example #23
Source File: InitialFTP_Swing.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
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.");
}
 
Example #24
Source File: InitialFTP_Swing.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
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.");
}
 
Example #25
Source File: InitialFTP_Swing.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
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.");
}
 
Example #26
Source File: InitialFTP_Swing.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
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.");
}
 
Example #27
Source File: InitialFTP_Swing.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
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.");
}
 
Example #28
Source File: InitialFTP_Swing.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
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.");
}
 
Example #29
Source File: InitialFTP_Swing.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
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.");
}