alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (CWrapper.java)

This example Java source code file (CWrapper.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

awt, cwrapper, geometry, max_window_levels, nscolor, nsfloatingwindowlevel, nsnormalwindowlevel, nsobject, nsview, nswindowabove, nswindowbelow, nswindowout, rectangle2d, string

The CWrapper.java Java example source code

/*
 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

package sun.lwawt.macosx;

import java.awt.geom.Rectangle2D;

public final class CWrapper {
    private CWrapper() { }

    public static final class NSWindow {
        // NSWindowOrderingMode
        public static final int NSWindowAbove = 1;
        public static final int NSWindowBelow = -1;
        public static final int NSWindowOut = 0;

        // Window level constants
        // The number of supported levels: (we'll use more in the future)
        public static final int MAX_WINDOW_LEVELS = 2;
        // The levels: (these are NOT real constants, these are keys. See native code.)
        public static final int NSNormalWindowLevel = 0;
        public static final int NSFloatingWindowLevel = 1;

        // 'level' is one of the keys defined above
        public static native void setLevel(long window, int level);

        public static native void makeKeyAndOrderFront(long window);
        public static native void makeKeyWindow(long window);
        public static native void makeMainWindow(long window);
        public static native boolean canBecomeMainWindow(long window);
        public static native boolean isKeyWindow(long window);

        public static native void orderFront(long window);
        public static native void orderFrontRegardless(long window);
        public static native void orderWindow(long window, int ordered, long relativeTo);
        public static native void orderOut(long window);

        public static native void addChildWindow(long parent, long child, int ordered);
        public static native void removeChildWindow(long parent, long child);

        public static native void setFrame(long window, int x, int y, int w, int h, boolean display);

        public static native void setAlphaValue(long window, float alpha);
        public static native void setOpaque(long window, boolean opaque);
        public static native void setBackgroundColor(long window, long color);

        public static native void miniaturize(long window);
        public static native void deminiaturize(long window);
        public static native boolean isZoomed(long window);
        public static native void zoom(long window);

        public static native void makeFirstResponder(long window, long responder);
    }

    public static final class NSView {
        public static native void addSubview(long view, long subview);
        public static native void removeFromSuperview(long view);

        public static native void setFrame(long view, int x, int y, int w, int h);
        public static native Rectangle2D frame(long view);
        public static native long window(long view);

        public static native void setHidden(long view, boolean hidden);

        public static native void setToolTip(long view, String msg);
    }

    public static final class NSObject {
        public static native void release(long object);
    }

    public static final class NSColor {
        public static native long clearColor();
    }
}

Other Java examples (source code examples)

Here is a short list of links related to this Java CWrapper.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.