Java Code Examples for sun.awt.AWTAccessor#ComponentAccessor

The following examples show how to use sun.awt.AWTAccessor#ComponentAccessor . 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: XWindowPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void repositionSecurityWarning() {
    // NOTE: On KWin if the window/border snapping option is enabled,
    // the Java window may be swinging while it's being moved.
    // This doesn't make the application unusable though looks quite ugly.
    // Probobly we need to find some hint to assign to our Security
    // Warning window in order to exclude it from the snapping option.
    // We are not currently aware of existance of such a property.
    if (warningWindow != null) {
        // We can't use the coordinates stored in the XBaseWindow since
        // they are zeros for decorated frames.
        AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
        int x = compAccessor.getX(target);
        int y = compAccessor.getY(target);
        int width = compAccessor.getWidth(target);
        int height = compAccessor.getHeight(target);
        warningWindow.reposition(x, y, width, height);
    }
}
 
Example 2
Source File: XGlobalCursorManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private Cursor getCapableCursor(Component comp) {
    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();

    Component c = comp;
    while ((c != null) && !(c instanceof Window)
           && compAccessor.isEnabled(c)
           && compAccessor.isVisible(c)
           && compAccessor.isDisplayable(c))
    {
        c = compAccessor.getParent(c);
    }
    if (c instanceof Window) {
        return (compAccessor.isEnabled(c)
                && compAccessor.isVisible(c)
                && compAccessor.isDisplayable(c)
                && compAccessor.isEnabled(comp))
               ?
                compAccessor.getCursor(comp)
               :
                Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
    } else if (c == null) {
        return null;
    }
    return getCapableCursor(compAccessor.getParent(c));
}
 
Example 3
Source File: XGlobalCursorManager.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private Cursor getCapableCursor(Component comp) {
    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();

    Component c = comp;
    while ((c != null) && !(c instanceof Window)
           && compAccessor.isEnabled(c)
           && compAccessor.isVisible(c)
           && compAccessor.isDisplayable(c))
    {
        c = compAccessor.getParent(c);
    }
    if (c instanceof Window) {
        return (compAccessor.isEnabled(c)
                && compAccessor.isVisible(c)
                && compAccessor.isDisplayable(c)
                && compAccessor.isEnabled(comp))
               ?
                compAccessor.getCursor(comp)
               :
                Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
    } else if (c == null) {
        return null;
    }
    return getCapableCursor(compAccessor.getParent(c));
}
 
Example 4
Source File: XGlobalCursorManager.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private Cursor getCapableCursor(Component comp) {
    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();

    Component c = comp;
    while ((c != null) && !(c instanceof Window)
           && compAccessor.isEnabled(c)
           && compAccessor.isVisible(c)
           && compAccessor.isDisplayable(c))
    {
        c = compAccessor.getParent(c);
    }
    if (c instanceof Window) {
        return (compAccessor.isEnabled(c)
                && compAccessor.isVisible(c)
                && compAccessor.isDisplayable(c)
                && compAccessor.isEnabled(comp))
               ?
                compAccessor.getCursor(comp)
               :
                Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
    } else if (c == null) {
        return null;
    }
    return getCapableCursor(compAccessor.getParent(c));
}
 
Example 5
Source File: XWindowPeer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void repositionSecurityWarning() {
    // NOTE: On KWin if the window/border snapping option is enabled,
    // the Java window may be swinging while it's being moved.
    // This doesn't make the application unusable though looks quite ugly.
    // Probobly we need to find some hint to assign to our Security
    // Warning window in order to exclude it from the snapping option.
    // We are not currently aware of existance of such a property.
    if (warningWindow != null) {
        // We can't use the coordinates stored in the XBaseWindow since
        // they are zeros for decorated frames.
        AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
        int x = compAccessor.getX(target);
        int y = compAccessor.getY(target);
        int width = compAccessor.getWidth(target);
        int height = compAccessor.getHeight(target);
        warningWindow.reposition(x, y, width, height);
    }
}
 
Example 6
Source File: XGlobalCursorManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private Cursor getCapableCursor(Component comp) {
    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();

    Component c = comp;
    while ((c != null) && !(c instanceof Window)
           && compAccessor.isEnabled(c)
           && compAccessor.isVisible(c)
           && compAccessor.isDisplayable(c))
    {
        c = compAccessor.getParent(c);
    }
    if (c instanceof Window) {
        return (compAccessor.isEnabled(c)
                && compAccessor.isVisible(c)
                && compAccessor.isDisplayable(c)
                && compAccessor.isEnabled(comp))
               ?
                compAccessor.getCursor(comp)
               :
                Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
    } else if (c == null) {
        return null;
    }
    return getCapableCursor(compAccessor.getParent(c));
}
 
Example 7
Source File: XGlobalCursorManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private Cursor getCapableCursor(Component comp) {
    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();

    Component c = comp;
    while ((c != null) && !(c instanceof Window)
           && compAccessor.isEnabled(c)
           && compAccessor.isVisible(c)
           && compAccessor.isDisplayable(c))
    {
        c = compAccessor.getParent(c);
    }
    if (c instanceof Window) {
        return (compAccessor.isEnabled(c)
                && compAccessor.isVisible(c)
                && compAccessor.isDisplayable(c)
                && compAccessor.isEnabled(comp))
               ?
                compAccessor.getCursor(comp)
               :
                Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
    } else if (c == null) {
        return null;
    }
    return getCapableCursor(compAccessor.getParent(c));
}
 
Example 8
Source File: XTextFieldPeer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void initTextField() {
    setVisible(target.isVisible());

    setBounds(x, y, width, height, SET_BOUNDS);

    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    foreground = compAccessor.getForeground(target);
    if (foreground == null)
        foreground = SystemColor.textText;

    setForeground(foreground);

    background = compAccessor.getBackground(target);
    if (background == null) {
        if (((TextField)target).isEditable()) background = SystemColor.text;
        else background = SystemColor.control;
    }
    setBackground(background);

    if (!target.isBackgroundSet()) {
        // This is a way to set the background color of the TextArea
        // without calling setBackground - go through accessor
        compAccessor.setBackground(target, background);
    }
    if (!target.isForegroundSet()) {
        target.setForeground(SystemColor.textText);
    }

    setFont(font);
}
 
Example 9
Source File: XDecoratedPeer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
final void dumpTarget() {
    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    int getWidth = compAccessor.getWidth((Component)target);
    int getHeight = compAccessor.getHeight((Component)target);
    int getTargetX = compAccessor.getX((Component)target);
    int getTargetY = compAccessor.getY((Component)target);
    System.err.println(">>> Target: " + getTargetX + ", " + getTargetY + ", " + getWidth + ", " + getHeight);
}
 
Example 10
Source File: XDecoratedPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Graphics getGraphics() {
    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    return getGraphics(content.surfaceData,
                       compAccessor.getForeground(target),
                       compAccessor.getBackground(target),
                       compAccessor.getFont(target));
}
 
Example 11
Source File: XDecoratedPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
final void dumpTarget() {
    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    int getWidth = compAccessor.getWidth((Component)target);
    int getHeight = compAccessor.getHeight((Component)target);
    int getTargetX = compAccessor.getX((Component)target);
    int getTargetY = compAccessor.getY((Component)target);
    System.err.println(">>> Target: " + getTargetX + ", " + getTargetY + ", " + getWidth + ", " + getHeight);
}
 
Example 12
Source File: XDecoratedPeer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
final void dumpTarget() {
    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    int getWidth = compAccessor.getWidth((Component)target);
    int getHeight = compAccessor.getHeight((Component)target);
    int getTargetX = compAccessor.getX((Component)target);
    int getTargetY = compAccessor.getY((Component)target);
    System.err.println(">>> Target: " + getTargetX + ", " + getTargetY + ", " + getWidth + ", " + getHeight);
}
 
Example 13
Source File: XDecoratedPeer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
final void dumpTarget() {
    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    int getWidth = compAccessor.getWidth((Component)target);
    int getHeight = compAccessor.getHeight((Component)target);
    int getTargetX = compAccessor.getX((Component)target);
    int getTargetY = compAccessor.getY((Component)target);
    System.err.println(">>> Target: " + getTargetX + ", " + getTargetY + ", " + getWidth + ", " + getHeight);
}
 
Example 14
Source File: XDecoratedPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Graphics getGraphics() {
    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    return getGraphics(content.surfaceData,
                       compAccessor.getForeground(target),
                       compAccessor.getBackground(target),
                       compAccessor.getFont(target));
}
 
Example 15
Source File: XDecoratedPeer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Graphics getGraphics() {
    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    return getGraphics(content.surfaceData,
                       compAccessor.getForeground(target),
                       compAccessor.getBackground(target),
                       compAccessor.getFont(target));
}
 
Example 16
Source File: XTextAreaPeer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a Text area.
 */
XTextAreaPeer(TextArea target) {
    super(target);

    // some initializations require that target be set even
    // though init(target) has not been called
    this.target = target;

    //ComponentAccessor.enableEvents(target,AWTEvent.MOUSE_WHEEL_EVENT_MASK);

    String text = target.getText();
    jtext = new AWTTextArea(text, this);
    jtext.setWrapStyleWord(true);
    jtext.getDocument().addDocumentListener(jtext);
    XToolkit.specialPeerMap.put(jtext,this);
    textPane = new AWTTextPane(jtext,this, target.getParent());

    setBounds(x, y, width, height, SET_BOUNDS);
    textPane.setVisible(true);
    textPane.validate();

    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    foreground = compAccessor.getForeground(target);
    if (foreground == null)  {
        foreground = SystemColor.textText;
    }
    setForeground(foreground);

    background = compAccessor.getBackground(target);
    if (background == null) {
        if (target.isEditable()) background = SystemColor.text;
        else background = SystemColor.control;
    }
    setBackground(background);

    if (!target.isBackgroundSet()) {
        // This is a way to set the background color of the TextArea
        // without calling setBackground - go through accessor
        compAccessor.setBackground(target, background);
    }
    if (!target.isForegroundSet()) {
        target.setForeground(SystemColor.textText);
    }

    setFont(font);

    // set the text of this object to the text of its target
    setTextImpl(target.getText());  //?? should this be setText

    int start = target.getSelectionStart();
    int end = target.getSelectionEnd();
    // Fix for 5100200
    // Restoring Motif behaviour
    // Since the end position of the selected text can be greater then the length of the text,
    // so we should set caret to max position of the text
    setCaretPosition(Math.min(end, text.length()));
    if (end > start) {
        // Should be called after setText() and setCaretPosition()
        select(start, end);
    }
    setEditable(target.isEditable());
    setScrollBarVisibility();
    // After this line we should not change the component's text
    firstChangeSkipped = true;
}
 
Example 17
Source File: XTextAreaPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a Text area.
 */
XTextAreaPeer(TextArea target) {
    super(target);

    // some initializations require that target be set even
    // though init(target) has not been called
    this.target = target;

    //ComponentAccessor.enableEvents(target,AWTEvent.MOUSE_WHEEL_EVENT_MASK);

    String text = target.getText();
    jtext = new AWTTextArea(text, this);
    jtext.setWrapStyleWord(true);
    jtext.getDocument().addDocumentListener(jtext);
    XToolkit.specialPeerMap.put(jtext,this);
    textPane = new AWTTextPane(jtext,this, target.getParent());

    setBounds(x, y, width, height, SET_BOUNDS);
    textPane.setVisible(true);
    textPane.validate();

    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    foreground = compAccessor.getForeground(target);
    if (foreground == null)  {
        foreground = SystemColor.textText;
    }
    setForeground(foreground);

    background = compAccessor.getBackground(target);
    if (background == null) {
        if (target.isEditable()) background = SystemColor.text;
        else background = SystemColor.control;
    }
    setBackground(background);

    if (!target.isBackgroundSet()) {
        // This is a way to set the background color of the TextArea
        // without calling setBackground - go through accessor
        compAccessor.setBackground(target, background);
    }
    if (!target.isForegroundSet()) {
        target.setForeground(SystemColor.textText);
    }

    setFont(font);

    // set the text of this object to the text of its target
    setTextImpl(target.getText());  //?? should this be setText

    int start = target.getSelectionStart();
    int end = target.getSelectionEnd();
    // Fix for 5100200
    // Restoring Motif behaviour
    // Since the end position of the selected text can be greater then the length of the text,
    // so we should set caret to max position of the text
    setCaretPosition(Math.min(end, text.length()));
    if (end > start) {
        // Should be called after setText() and setCaretPosition()
        select(start, end);
    }
    setEditable(target.isEditable());
    setScrollBarVisibility();
    // After this line we should not change the component's text
    firstChangeSkipped = true;
}
 
Example 18
Source File: XTextAreaPeer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a Text area.
 */
XTextAreaPeer(TextArea target) {
    super(target);

    // some initializations require that target be set even
    // though init(target) has not been called
    this.target = target;

    //ComponentAccessor.enableEvents(target,AWTEvent.MOUSE_WHEEL_EVENT_MASK);

    String text = target.getText();
    jtext = new AWTTextArea(text, this);
    jtext.setWrapStyleWord(true);
    jtext.getDocument().addDocumentListener(jtext);
    XToolkit.specialPeerMap.put(jtext,this);
    textPane = new AWTTextPane(jtext,this, target.getParent());

    setBounds(x, y, width, height, SET_BOUNDS);
    textPane.setVisible(true);
    textPane.validate();

    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    foreground = compAccessor.getForeground(target);
    if (foreground == null)  {
        foreground = SystemColor.textText;
    }
    setForeground(foreground);

    background = compAccessor.getBackground(target);
    if (background == null) {
        if (target.isEditable()) background = SystemColor.text;
        else background = SystemColor.control;
    }
    setBackground(background);

    if (!target.isBackgroundSet()) {
        // This is a way to set the background color of the TextArea
        // without calling setBackground - go through accessor
        compAccessor.setBackground(target, background);
    }
    if (!target.isForegroundSet()) {
        target.setForeground(SystemColor.textText);
    }

    setFont(font);

    // set the text of this object to the text of its target
    setTextImpl(target.getText());  //?? should this be setText

    int start = target.getSelectionStart();
    int end = target.getSelectionEnd();
    // Fix for 5100200
    // Restoring Motif behaviour
    // Since the end position of the selected text can be greater then the length of the text,
    // so we should set caret to max position of the text
    setCaretPosition(Math.min(end, text.length()));
    if (end > start) {
        // Should be called after setText() and setCaretPosition()
        select(start, end);
    }
    setEditable(target.isEditable());
    setScrollBarVisibility();
    // After this line we should not change the component's text
    firstChangeSkipped = true;
}
 
Example 19
Source File: XTextAreaPeer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a Text area.
 */
XTextAreaPeer(TextArea target) {
    super(target);

    // some initializations require that target be set even
    // though init(target) has not been called
    this.target = target;

    //ComponentAccessor.enableEvents(target,AWTEvent.MOUSE_WHEEL_EVENT_MASK);

    String text = target.getText();
    jtext = new AWTTextArea(text, this);
    jtext.setWrapStyleWord(true);
    jtext.getDocument().addDocumentListener(jtext);
    XToolkit.specialPeerMap.put(jtext,this);
    textPane = new AWTTextPane(jtext,this, target.getParent());

    setBounds(x, y, width, height, SET_BOUNDS);
    textPane.setVisible(true);
    textPane.validate();

    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    foreground = compAccessor.getForeground(target);
    if (foreground == null)  {
        foreground = SystemColor.textText;
    }
    setForeground(foreground);

    background = compAccessor.getBackground(target);
    if (background == null) {
        if (target.isEditable()) background = SystemColor.text;
        else background = SystemColor.control;
    }
    setBackground(background);

    if (!target.isBackgroundSet()) {
        // This is a way to set the background color of the TextArea
        // without calling setBackground - go through accessor
        compAccessor.setBackground(target, background);
    }
    if (!target.isForegroundSet()) {
        target.setForeground(SystemColor.textText);
    }

    setFont(font);

    // set the text of this object to the text of its target
    setTextImpl(target.getText());  //?? should this be setText

    int start = target.getSelectionStart();
    int end = target.getSelectionEnd();
    // Fix for 5100200
    // Restoring Motif behaviour
    // Since the end position of the selected text can be greater then the length of the text,
    // so we should set caret to max position of the text
    setCaretPosition(Math.min(end, text.length()));
    if (end > start) {
        // Should be called after setText() and setCaretPosition()
        select(start, end);
    }
    setEditable(target.isEditable());
    setScrollBarVisibility();
    // After this line we should not change the component's text
    firstChangeSkipped = true;
}
 
Example 20
Source File: XTextAreaPeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a Text area.
 */
XTextAreaPeer(TextArea target) {
    super(target);

    // some initializations require that target be set even
    // though init(target) has not been called
    this.target = target;

    //ComponentAccessor.enableEvents(target,AWTEvent.MOUSE_WHEEL_EVENT_MASK);

    String text = target.getText();
    jtext = new AWTTextArea(text, this);
    jtext.setWrapStyleWord(true);
    jtext.getDocument().addDocumentListener(jtext);
    XToolkit.specialPeerMap.put(jtext,this);
    textPane = new AWTTextPane(jtext,this, target.getParent());

    setBounds(x, y, width, height, SET_BOUNDS);
    textPane.setVisible(true);
    textPane.validate();

    AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
    foreground = compAccessor.getForeground(target);
    if (foreground == null)  {
        foreground = SystemColor.textText;
    }
    setForeground(foreground);

    background = compAccessor.getBackground(target);
    if (background == null) {
        if (target.isEditable()) background = SystemColor.text;
        else background = SystemColor.control;
    }
    setBackground(background);

    if (!target.isBackgroundSet()) {
        // This is a way to set the background color of the TextArea
        // without calling setBackground - go through accessor
        compAccessor.setBackground(target, background);
    }
    if (!target.isForegroundSet()) {
        target.setForeground(SystemColor.textText);
    }

    setFont(font);

    // set the text of this object to the text of its target
    setTextImpl(target.getText());  //?? should this be setText

    int start = target.getSelectionStart();
    int end = target.getSelectionEnd();
    // Fix for 5100200
    // Restoring Motif behaviour
    // Since the end position of the selected text can be greater then the length of the text,
    // so we should set caret to max position of the text
    setCaretPosition(Math.min(end, text.length()));
    if (end > start) {
        // Should be called after setText() and setCaretPosition()
        select(start, end);
    }
    setEditable(target.isEditable());
    setScrollBarVisibility();
    // After this line we should not change the component's text
    firstChangeSkipped = true;
}