"Always on TOP"option for my window

Hi All
I am developing an application in which I wanted to develop a facility for enabling "always stay on top" to one of the windows .How can I do this.
Thanks in advance
Haritha

I solved this problem using JNI, and I think that is the only way to allow the "Alwasy on Top" option. Here's how I did it.
1. Create an extension of JFrame or JDialog or JWindow, whatever you want.
2. Add the native method setAlwaysOnTop()
import java.awt.*;
import javax.swing.*;
public class MyFrame extends JFrame {
static { System.loadLibrary("MyFrame"); }
public MyFrame() {
super();
public void setAlwaysOnTop(boolean b) {
int hwnd = getNativeWindowHandle(this);
seteAlwaysOnTop(hwnd, b);
private native int getNativeWindowHandle(Window window);
private native void setAlwaysOnTop(int hwnd, boolean flag);
*NOTE the getNativeWindowHandle method is required to manipulate the frame in native code
**NOTE I will take about the static { System.loadLibrary("MyFrame"); }
at the end.
3. Compile your code.
4. Next you must create a c or c++ source file, name it whate every you want, and then define the setAlwaysOnTop method.
Heres the code for the native file.
#include <jni.h>
#include <jawt.h>
#include <afxwin.h>
#include <windows.h>
#include "MyFrame.h"
#include "jawt_md.h"
JNIEXPORT jint JNICALL
Java_MyFrame_getNativeWindowHandle(JNIEnv *env, jobject jobj, jobject window)
JAWT awt;
awt.version = JAWT_VERSION_1_3;
jboolean result = JAWT_GetAWT(env, &awt);
if (result == JNI_FALSE)
return 0;
JAWT_DrawingSurface* ds = awt.GetDrawingSurface(env, window);
if (ds == 0)
return 0;
jint lock = ds->Lock(ds);
if ((lock & JAWT_LOCK_ERROR) != 0)
return 0;
JAWT_DrawingSurfaceInfo* dsi = ds->GetDrawingSurfaceInfo(ds);
if (dsi != 0)
return 0;
JAWT_Win32DrawingSurfaceInfo* dsiwin = (JAWT_Win32DrawingSurfaceInfo*) dsi->platformInfo;
jint ret = reinterpret_cast<jint>(dsiwin->hwnd);
ds->FreeDrawingSurfaceInfo(dsi);
ds->Unlock(ds);
awt.FreeDrawingSurface(ds);
return ret;
JNIEXPORT void JNICALL
Java_MyFrame_windowAlwaysOnTop(JNIEnv *env, jobject jobj, jint hwnd, jboolean flag)
if (flag)
SetWindowPos((HWND) hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
else
SetWindowPos((HWND) hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
*NOTE say your class MyFrame is in the package com.me.swing then the method prototype would look like this:
JNIEXPORT void JNICALL
Java_com_me_swing_MyFrame_windowAlwaysOnTop(JNIEnv *env, jobject jobj, jint hwnd, jboolean flag)
5. you may have noticed the #include "MyFrame.h" line, well that is generated by the javah command. So, next run javah on your MyFrame.class file. you will have to look at the options to configure the command to do what you want, but essentially "javah MyFrame.class".
6. Make sure your MyFrame.h file and MyFrame.c or MyFrame.cpp file is in the same directory and compile them into an object file. Now you will have to figure out how to do this on your own. First you must get a c++ compiler, I use Visual C++ form Microsoft. If you are using that then
here is the command line
cl -Ic:\j2sdk1.4.0\include -Ic:\j2sdk1.4.0\include\win32 /c -LD
-IMyFrame.h MyFrame.cpp
Execute this command from the directory where you MyFrame.h and MyFrame.cpp files are or you will have to specify their paths.
the -Ic:\j2sdk1.4.0\include -Ic:\j2sdk1.4.0\include\win32 provide path information to include the jni.h and jawt.h files.
7. Now you will have to link the object file with the jawt.lib file and create the final dll. Again you will have to figure how to do this, but with VC++ the command is.
link /DLL MyFrame.obj c:\j2sdk1.4.0\lib\jawt.lib
Now you should 8 have files
MyFrame.java
MyFrame.class
MyFrame.h *created form javah
MyFrame.cpp
MyFrame.obj *created from compiling
MyFrame.exp *created from compiling
MyFrame.lib *created from compiling
MyFrame.dll *created from linking
You are done, now create a main class and instanciate and test your new frame.
**REMEBER the static { System.loadLibrary("MyFrame"); } line in your MyFrame.java file. This loads your newly created dll into the system so you can access it.
**IMPORTANT THE MyFrame.dll AND THE MyFrame.class FILE MUST BE IN THE SAME DIRECTORY, OR SPECIFY IT IN THE System.loadLibrary METHOD CALL.

Similar Messages

  • "Always on top" behavior for Navigator Window?

    Greetings,
    Several of our users have asked for an "Always on Top" feature for the OHJ help navigator window. We are using OHJ 4.2.3, on Windows platforms. Our application displays help topics from certain dialog buttons and menu items (using CshManager.showTopic()). If the help windows are currently displayed from a previous help request and the user maximizes the application window, any new help requests are not seen as the help windows do not top themselves.
    Is there any way to force the OHJ window to top itself when a new help topic is displayed? Our users are also asking for the help window to always be on top (a la Task Manager on windows) so they know where it is especially if they're performing a complex task and relying on a set of instructions in the help topic...
    thanks,
    Elizabeth Dyer.

    Elizabeth,
    As part of the showTopic() implementation OHJ calls toFront()
    to bring the help window to the front. If this isn't working
    in a particular case, please let us know. I don't think any
    permanent "on top" feature is feasible, since OHJ windows are
    normal Java dialogs and frames and selecting another Java
    window will activate it instead of OHJ.
    - Ryan (again with quoting from Jeff Stephenson)

  • Always on top feature for inspector window

    Are there any ability to enable/disable 'Always on top' feature for inspector shown in separate window in Mac OS ? On my laptop not always comfortable to keep inspector in browser window. On Ubuntu window managers allow to pin windows always on top but mac os has no abilities to do it. (using firefox developer edition)

    Elizabeth,
    As part of the showTopic() implementation OHJ calls toFront()
    to bring the help window to the front. If this isn't working
    in a particular case, please let us know. I don't think any
    permanent "on top" feature is feasible, since OHJ windows are
    normal Java dialogs and frames and selecting another Java
    window will activate it instead of OHJ.
    - Ryan (again with quoting from Jeff Stephenson)

  • Breadcrumbs to have "Always on top option"

    Hi,
    In my webhelp I have enabled the bread crumbs option....Now,
    I am having a small usability issue with this...
    I maintain breadcrumbs on the top left side of the
    page....When i scroll down the page, the breadcrumb is not visible
    and hence i always have to scroll back to the top/bottom of the
    page to navigate...
    I just wanted to know if it is possible to always have the
    bread crumbs at the top of the page regardless of the
    scrolling..something like the "always on top option"..
    Please let me now if this is possible in anyway..
    thanks in advance for your help!!!

    Hi there
    RoboHelp doesn't offer this functionality. But it doesn't
    mean that you can't have it if you are determined. There are some
    JavaScripts out there that can be used to achieve what you want.
    Note, however, that it will require post processing your WebHelp
    output to add the scripts to the pages.
    You might wish to begin at the link below:
    Click
    here
    Or this link:
    Click
    here
    Cheers... Rick

  • What are the best options for running windows on a Mac Pro

    what are the best options for running windows on a Mac Pro

    For gaming and other CPU intensive stuff: Boot Camp – https://www.apple.com/support/bootcamp/
    For the rest: any virtualization software (Parallels/Vmware Fusion/VirtualBox)

  • I just installed the lastest update of Firefox and now the Firefox window is always on top of all other windows - what a pain! How can I fix this?

    I looked at all of the options available to me and did not see where there is a link or anything saying "always on top." Is there such a thing somewhere and if so, where?

    Well hells bells - I went to watch TV and came back and all is good. Is it magic? :) (Some days I just plain don't understand anything - I swear!)

  • Adf mobile deployment option for blackberry/windows-mobile is disabled

    Hi,
    We are trying to deploy the sample FOD mobile app to blackberry simulator as per the tutorial given at:.
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/jdev/obe11jdev/ps3/adf_mobile_top/adf_mobile/jdtut_11r2_54_1.html
    We had followed all the steps given till Part 2 and were able to deploy the app to the BB simulator and test it also.
    After that, we followed the steps given in Part 3 and now when trying to deploy the mobile client app to the simulator, the deployment profile option for BB is disabled and hence we are not able to deploy the application.
    We have Jdev 11.1.1.4.0 with mobile client extension installed, and have also installed the BB JDE and simulator.
    Can someone please help us to get the deployment to BB profile option enabled again?
    PS: We also tried installing Jdev 11.1.1.4.0 with mobile adf extension on another machine with BB JDE and BB 9700 simulator, but on this new machine, the deployment profile option is disabled right from the start, we are not even able to deploy the changes we have done for part 2 of the tutorial.
    Regards,
    Hemant

    Hi, Hemant, just to make sure, did you try to kick off deployment from the MobileClient project, or at the Application menu? Mobile Client app needs to be deployed from the application menu.
    Also, if you have deployed already, the deployment profile has been created, so you simply would need to deploy again from the application menu.
    If you are seeing these items are somehow disabled, then I don't think I have seen it before. Perhaps we can set up a web conference to look at it.
    Please just ping me directly.
    Thanks,
    Joe Huang ([email protected])

  • 'separate video window' has no always-on-top option in miniplayer mode

    In miniplayer mode, the control panel can stay on top, but the video widow can't. This defeats the purpose of keeping the miniplayer on top.
    I hope this, and all the other problems are rectified in the next release.

    On most models, performing a factory reset will cause the TV to go through the initial setup, allowing you to specify its location. However, I don't see your model listed in our database. If it's not a US unit, you may want to contact Toshiba in your region.
    - Peter

  • Can you have an "always downoad attachments" option for imap?

    I would love to just click on attachments and have them open right away using an imap account, is there any way to configure mail to always download attachments? (I did not find a setting for this and I do not want to swtich to POP3).
    Mail is not very friendly in handling attachments that are not downloaded, the only way you can tell Mail is doing something to download an attachment is if you do a quicklook (then it shows a "downloading" message), but if you doubleclick or save all, it just does it in the back ground with no "progress" bar.

    Mail downloads attachments automatically in IMAP. Unlike POP there's no need to limit downloading attachments because they are stored on the server. If attachments are not coming through quickly enough at the time you see the message it could be due to something at your ISP.
    The only setting in Mail related to receiving attachments is in the Advanced section of Accounts in Mail preferences. There are several options in the drop down menu. Use the one that downloads all mail and attachments to the local machine. I believe it's the first option in the menu.

  • The best option for running Windows on a Mac?

    Though I'm loving my MacBook Pro, the only thing I would like to improve is the capacity for playing games. And for that I really need Windows.
    So, I have a copy of Windows XP, and I have a copy of Parallel. I've installed Parallel and Windows XP, but it's limited and I can't figure out how to make my graphics card (which is 256MB) work with it. It seems to need to use the Parallel Graphics. So, some questions:
    1) Is there a way to play the best Windows games using Parallel?
    2) Is there a better alternative? One of my friends mentioned Bootcamp to me. Would that be better? Is there any program that would allow me to run Windows and use the full power of my system to play the games?

    For gaming... your best option is to use BootCamp. Parallels is an excellent program... and it runs Windows well under most conditions... but it is still not great for gaming (even with version 3). BootCamp is free. It allows you to boot directly into Windows making your MacBook Pro a full fledged Windows PC. Games will run just as well as they would on any similarly spec'd PC notebook. The BootCamp utility in OS X will allow you to create a Windows driver CD for all of the hardware. You will get full speed 3D, ect. Also... you can use your BootCamp installation of Windows in Parallels... So, after you install Windows via BootCamp, you can delete your previous "Parallels Only" Windows installation and go through the process of installing a new version of Windows in Parallels... you will be able to point it to the copy of Windows you have set up in BootCamp. This way... when you want to play games... you can boot into Windows and run them at full speed... but for those times you are in OS X and you just want to launch an application that does not need all the 3d power, you can launch that same copy of Windows through Parallels.

  • Customizing the Home/Root/Top option for breadcrumbs.

    Hi:
    I want to know if there's a way to customize the "Home Page Name" text in the dialog for formatting Breadcrumb Options. The pull-down menu lists three options: Home, Root and Top. I want to have my custom text, but I see no way to disable the "Home Page Name" text and supply one in the "Label" text field.
    Example: I would like the breadcrumb to say "MyDoc > Book Blah > Topic Bleh" rather than " Home > Book Blah > Topic Bleh". Any thoughts?
    Thanks,
    K

    Hi,
    If you use Robo7, or Robo8 and add the breadcrumbs from the WebHelp navigation dialog, do the following:
    In the WebHelp dialog (when you select File | Generate primary layout / File | Generate | Primary Layout) you can check to add breadcrumbs. Click the Format button, and in the field Home Page Name, select another name from the list, or type your own.
    There's probably a way when you use Breadcrumbs placeholder, but I don't use that.
    Greet,
    Willam

  • Options for running Windows Apps

    Here goes - I'm a pc user. Developer to be specific, so I need to be able to run SQL Server 2005/2000 Visual Studio 2003/2005, and other Windows related apps to support my job. However, I'm interested in purchasing an Apple to support my hobbies (photography, etc). They're elegant in design/architecture, etc.
    I was really excited about the new MacBook Pro on an Intel platform - with dreams of "dual booting" Windows. Unfortunately, it does not appear that Windows (currently) supports the BIOS of the MacBook Pro - and I'm not interested in "hacking" a solution out. I need this thing to run, and run well.
    I've also heard about the VM and have used VM to support development work. However, I've found it to be clunky at best - and would rather pursue alternatives.
    So, ultimately my questions are - am I ultimately restricted to having multiple machines if I want a MacBook Pro? Is there any reality to the claim that Vista will be able to support the BIOS standard used by Apple? Should I just forget about it - and purchase another antiquated pc.
    Thanks in advance for any useful information. Sean

    It is possible that Microsoft will release a Virtual PC for Intel Mac, but that may be some time in the future.
    Currently you can obtain a boot loader that will instal Win XP on an Intel Mac. It is fairly straightforward but assumes that you are not a new computer user.
    Please be advised: This solution is not supported by Apple. Apple is not preventing people from instaling Windows, however they will not troubleshoot your problems. Furthermore you may wish to consider waiting a bit because the current instal does not contain fan drivers which means that while in Windows you run the chance of overheating your MacBook Pro. Given time this is likely to be fixed.
    http://download.onmac.net/
    In the long run it is better to only run OS X, however if you are forced to run Windows the least we Mac users can do is buy Apple hardware and software and dual boot our computers when required to. If I were in your situation I too would rather have a product made by Apple than any other manufacturer.

  • Lenovo support - options for recovering Windows 8 on new X230

    Hello, I recently purchased x230 with Windows 8.
    I installed Ubuntu 12.0 (attempting to dual boot).  Unfortuantely, Windows 8 is no longer accessible(UEFI error comes up on boot), the restore partition is also corrup ("required partition cannot be found").
    I attempted to install win 8 PRO that I purchased from scratch.  It failes because the Windows 8 key embedded into the EFI doesn't match the new Windows 8 PRO that I have on DVD.
    I chatted with Lenovo support, asking to purchase restore DVDs for my laptop - I was told that it's not possible (after going thorugh a couple of people and wasting 1.5 hours on chat_
    Please provide some support as it is unacceptable that I cannot install clean version of WIndows 8 and the restore disks are not available from Lenovo.
    Thank You.

    Unfortunately, win 8 doesn't support dual boot in native or not tweaked mode.
    Try this tool:
    http://support.lenovo.com/en_US/diagnose-and-fix/detail.page?LegacyDocID=LENV-DIAGS#uefi
    x220 | i5-2520m | Intel ssd 320 series | Gobi 2000 3G GPS | WiFi
    x220 | i5-2520m | hdd 320 | Intel msata ssd 310 series | 3G GPS | WiFi
    Do it well, worse becomes itself
    Русскоязычное Сообщество   English Community   Deutsche Community   Comunidad en Español

  • Which is the better option for using windows on mac ...parallel or vm ware fusion

    i want to use c# ,.net, c++ , on my macbook pro ....which software i should purchase parallel or vmware fusion

    They both work well. I like Fusion. Others like Parallels. Still others like VirtualBox.
    They all have free trials, VirtualBox is a free product, so try them for yourself and stick with the one that works best for you.
    I opted to install Windows using Boot Camp Assistant.

  • MacBook Pro - what's best option for university Windows apps?

    My son is starting university and considering buying a MacBook Pro (we are a Mac family). However, his math textbooks (calculus and linear algebra) come with bundled software, or keys to downloadable software, that only runs on Windows. I haven't been paying attention, and would appreciate some practical advice on how to run Windows. Please tell me if I understand correctly...
    To run either Boot Camp or Parallels, do you have to buy and install a copy of Windows separately? Or is Boot Camp an emulator that doesn't require stand-alone Windows?
    What Windows version do you recommend? (Sounds like Vista is problematic)
    Can you just install Windows like you install the Mac OS, or is it more complicated?
    In my experience, education software is poorly written. Comments on the Apple Store website say Parallels is "picky" about software. Do you think Boot Camp would be enough?
    With Boot Camp can you switch back and forth on the desktop (like Parallels says it can), or do you have to re-boot?
    Any other observations?
    Thanks for any help.

    You want a review that looks at both side by side.
    Vista is no more a problem than any other OS, and probably easier in some ways.
    From around the time Vista came out, so rather dated, and once SP1 is out, well I found BootCamp 1.3 and recent updates and drivers have made using 64-bit fine, stable, and can run all day w/o problems.
    http://www.tomshardware.com/2007/01/29/xp-vs-vista/
    Cnet Review - how to install Vista
    http://vistasupport.mvps.org/installwindowsvista.htm
    http://en.wikipedia.org/wiki/Windows_Vista
    Amazon: "Windows Vista Manual"
    http://www.mbreview.com/vista1.php
    ComputerWorld: Best and Worst of Vista
    http://www.macnn.com/articles/06/09/19/parallels.desktop.for.mac/
    Having used Vista for the last year, and OS X for 7, I think it would be easier to go with Vista than "back in time" with XP - if Windows is a new experience.
    If they are going to have to use and learn Windows, they'll need to get up to speed on how to lock down their system and use it. That would make a VM easier to get started but yes, native Windows (BootCamp) would be same as using a PC mostly. And force your son to learn Windows (but get him a book to help, too).

Maybe you are looking for

  • How to use inbound exit class for more than one workflow step

    Hi All, In Offline Workflow Approval Scenarios where the work items are sent to outlook of non sap users inbox through workitem exit of the respective workflow item. Based on the user reply from outlook email(either approve or reject) which sends an

  • How to set the out point beyond 9.95 seconds???

    how to set the out point  in Motion 5 beyond 9.95 seconds???

  • Interactive activity, external task example???

    Hi, I'm trying to search for a simple external task example, however it is totally imposible to find anything ... :( I would like to make a few questions about it. When you create an external task in a interactive activity, you can specify an URL whe

  • Minimize all frames

    i've got a program running, which if one of the window is being minimized all of the opened windows which is opeened will be minimized, and if clicked ffrom the taskbar all will be restored .. here is the code .... private void iconifyAllWindows(int

  • Dataaccess is not a member after dragging a table to a web form

    Problems using the oracle developer tools: 1) I got a project that is working fine with oracle tools 2) Create a new form 3) Select a table from oracle explorer and dropped on the form 4) I got the error dataaccess is not a member Seems like the auto