Getting HWND to Swing component with C++ as main

I've ran into another issue with the Native interface , it occurs when mixing it with JNI.
Anyone know why the class load fails on the Native Invocatuon side if I include a JNI call on the Java side??
Here's the sequence
1 .Main.cpp -> 2 . MainNativeWindow.cpp (Native Interface) -> 3 . MyWindow.java (create Swing and call Native) -> 4. MyNativeWindow.cpp (get HWND and edit)
1. So the main app is C++.
2. The creates a JVM through the native interface
3. The Java Sides paint is overridden on the C++ side, this gives me a HWND to the Java Canvas.
4. The C++ side then writes to the Java Canvas.
My problem is the combination of the Native invocation and the JNI, if I include the JNI call on the Java side then the Native call to access the Java class fails (it works if I remove the JNI function) !!
Anyone know why the class load fails on the Native Invocatuon side if I include a JNI call on the Java side??
Is there an easier way to get access to the Java Canvas from the C++ side, besides using the Java Paint function to give me access , I've given snippets of the code below
1. and 2. C++ main
#include "MainNativeWindow.h"
//Native Interface
#include <stdio.h>
#include <jni.h>
JavaVM *jvm; /* Pointer to a Java VM */
JNIEnv *env; /* Pointer to native method interface */
int verbose = 1; /* Debugging flag */
int MainNativeWindow::InitJava()
  JavaVMInitArgs  vm_args;
  jclass cls;
  jmethodID main_methodID, test_methodID = NULL;
  jint res;
  JavaVMOption options[4];
  options[0].optionString = "-Djava.compiler=NONE"; /* disable JIT */
  options[1].optionString = "-Djava.class.path=${JDK_HOME}/lib;C:/jsdk1.4.2/_jvm/lib;."; /* user classes */
  options[2].optionString = "-Djava.library.path=lib"; /* set native library path */
  options[3].optionString = "-verbose:jni"; /* print JNI-related messages */
  /* Setup the environment */
  vm_args.version = JNI_VERSION_1_4;
  vm_args.options = options;
  vm_args.nOptions = 4;
  vm_args.ignoreUnrecognized = 1;
  JNI_GetDefaultJavaVMInitArgs(&vm_args);//REPLACE THIS
   res = JNI_CreateJavaVM(&jvm,(void **) &env, &vm_args );//REPLACE THIS
  cls = env->FindClass("MyWindow");
  if(cls)
    main_methodID = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");//"([Ljava/lang/String;)V" indicates that the Java mehtod takes an array "[" pf Strings and returns void "V"
  if(main_methodID)
     jstring first_str = env->NewStringUTF("The First String");//create string
     jobjectArray args = (jobjectArray)env->NewObjectArray(2,env->FindClass("java/lang/String"), first_str);//new array with 2 elements
                              env->SetObjectArrayElement(args, 1, first_str);//insert the second string into index 1 of the array
     jstring second_str = env->NewStringUTF("The Second String");//create string
                              env->SetObjectArrayElement(args, 2, second_str);//insert the second string into index 1 of the array
                         env->CallStaticVoidMethod(cls, main_methodID, args);//pass the array to the Java main method
  jvm->DestroyJavaVM( );
    return 1;
int main(int argc, char *argv[])
     MainNativeWindow *nativewin = new MainNativeWindow();
      return nativewin->InitJava();   
}3. JAVA side
import java.awt.*;
import javax.swing.*;
public class MyWindow extends Canvas {
     static {
          // Load the library that contains the paint code.
          System.loadLibrary("MyNativeWindow");
     // native entry point for Painting
     public native void paint(Graphics g);
     public static void main( String[] argv ){
          Frame f = new Frame();
          f.setSize(300,400);
          JWindow w = new JWindow(f);
          w.setBackground(new Color(0,0,0,255));
          w.getContentPane().setBackground(new Color(0,0,0,255));
          w.getContentPane().add(new MyWindow());
          w.setBounds(300,300,300,300);
          w.setVisible(true);
}4. C++ AWT interface (doesn't get here with the JNI in the Java class)
//AWT Native Interface
#include <windows.h>
#include <assert.h>
#include "jawt_md.h"
#include "MyWindow.h"
void DrawSmiley(HWND hWnd, HDC hdc);
HRGN hrgn = NULL;
JNIEXPORT void JNICALL
Java_MyWindow_paint(JNIEnv* env, jobject canvas, jobject graphics)
     JAWT awt;
     JAWT_DrawingSurface* ds;
     JAWT_DrawingSurfaceInfo* dsi;
     JAWT_Win32DrawingSurfaceInfo* dsi_win;
     jboolean result;
     jint lock;
     // Get the AWT
     awt.version = JAWT_VERSION_1_4;
     result = JAWT_GetAWT(env, &awt);
     assert(result != JNI_FALSE);
     // Get the drawing surface
     ds = awt.GetDrawingSurface(env, canvas);
     if(ds == NULL)
         return;
     // Lock the drawing surface
     lock = ds->Lock(ds);
     assert((lock & JAWT_LOCK_ERROR) == 0);
     // Get the drawing surface info
     dsi = ds->GetDrawingSurfaceInfo(ds);
     // Get the platform-specific drawing info
     dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
     HDC hdc = dsi_win->hdc;
     HWND hWnd = dsi_win->hwnd;
     // !!! DO PAINTING HERE !!! //
     if(hrgn == NULL)
          RECT rcBounds;
          GetWindowRect(hWnd,&rcBounds);
          long xLeft = 0;         // Use with scaling macros
          long yTop = 0;
          long xScale = rcBounds.right-rcBounds.left;
          long yScale = rcBounds.bottom-rcBounds.top;
          hrgn = CreateEllipticRgn(X(10), Y(15), X(90), Y(95));
          SetWindowRgn(GetParent(hWnd),hrgn,TRUE);
          InvalidateRect(hWnd,NULL,TRUE);
     } else {
          DrawSmiley(hWnd,hdc);
     // Free the drawing surface info
     ds->FreeDrawingSurfaceInfo(dsi);
     // Unlock the drawing surface
     ds->Unlock(ds);
     // Free the drawing surface
     awt.FreeDrawingSurface(ds);
}

See http://codeproject.com/cpp/OOJNIUse.asp

Similar Messages

  • How to get back deleted software component along with underlaying objects.

    Dear Experts,
    By mistake i deleted my software component. When i deleted it even doesn't ask for activate. When i check in change list there is no change list for that deleted software component. So request you please let me how to get back my software component with all the namespaces and objects.
    Please treat this as high priority and revert me back ASAP.
    Thanks in advance.
    HAri.

    I don't know if is possible to restore a deleted SoftComp and all dependent object in repository... You can try to renew the SoftComp import from SLD....

  • [Help] Unable to find component with absolute reference

    I've deployed my project files to server and registered in Application.
    Class Files under myclasses goes to -> /disk2/app/applmgr/comntop/java/ldc/oracle/apps/sla/calnet/xref/phone
    Page XML under myprojects goes to -> /disk2/app/applmgr/appltop/xx_custom/11.5.0/mds
    The page is rendered successfully.
    (In EBS, HTML Call registered in FUNCTION is OA.jsp?page=/ldc/oracle/apps/sla/calnet/xref/phone/webui/PhonePG)
    However, if I click any "action" such as <apply>, <delete>.. etc, I get "Unable to find component with absolute reference" error.
    I've verified -> exec JDR_UTILS.printDocument('/ldc/oracle/apps/sla/calnet/xref/phone/webui/PhonePG', 150), and it did fetch the XML code.
    I've verified I restart Apache as well as deleting out pages -> rm -rf $COMMONTOP/_pages
    What am I missing here? Please help.
    xmlimport.bat
    REM   Setting Up JDeveloper Path
         set JDEV_BIN_HOME=C:\JDev9i_OAExtend_RUP7\jdevbin
         set JDEV_USER_HOME=C:\JDev9i_OAExtend_RUP7\jdevhome\jdev
         set JDEV_PROJECT_HOME=%JDEV_USER_HOME%\myprojects
    REM   Location of the import file
         set PATH=%JDEV_BIN_HOME%\jdk\bin;%JDEV_BIN_HOME%\jdev\bin;%PATH%
    REM   Setting up DB Connection Path
             set DB_CONNECTION="(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = arebdt.xxx.com)(PORT = 1521))(CONNECT_DATA = (SID = ARTEST)))"     
    REM   Setting up Page(s) to upload
         set PAGE2UPLOAD=ldc\oracle\apps\sla\calnet\xref\phone\webui\PhonePG.xml
         set APPS_PASSWD=<pass>
    REM   Execute import.bat
         call import.bat %JDEV_PROJECT_HOME%\%PAGE2UPLOAD% -rootdir %JDEV_PROJECT_HOME% -username apps -password %APPS_PASSWD% -dbconnection %DB_CONNECTION%
         pause
    REM   End of process     Error page
    Exception Details. 
    oracle.apps.fnd.framework.OAException: Application: FND, Message Name: FND_NO_REGION_DATA. Tokens: REGIONCODE = ldc/oracle/apps/sla/calnet/xref/phone/webui/PhonePG;
         at oracle.apps.fnd.framework.webui.JRAD2AKMapper.getRootMElement(JRAD2AKMapper.java:529)
         at oracle.apps.fnd.framework.webui.OAWebBeanFactoryImpl.getWebBeanTypeDataFromJRAD(OAWebBeanFactoryImpl.java:3719)
         at oracle.apps.fnd.framework.webui.OAWebBeanFactoryImpl.getRootApplicationModuleClass(OAWebBeanFactoryImpl.java:3452)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1011)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:511)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:432)
         at _oa__html._OA._jspService(_OA.java:84)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
         at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
         at oracle.jsp.JspServlet.service(JspServlet.java:156)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at oracle.jsp.provider.Jsp20RequestDispatcher.forward(Jsp20RequestDispatcher.java:162)
         at oracle.jsp.runtime.OraclePageContext.forward(OraclePageContext.java:187)
         at _oa__html._OA._jspService(_OA.java:94)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
         at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
         at oracle.jsp.JspServlet.service(JspServlet.java:156)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
         at org.apache.jserv.JServConnection.run(JServConnection.java:294)
         at java.lang.Thread.run(Thread.java:595)
    ## Detail 0 ##
    Exception:
    oracle.adf.mds.MetadataDefException: Unable to find component with absolute reference = ldc/oracle/apps/sla/calnet/xref/phone/webui/PhonePG, XML Path = null. Please verify that the reference is valid and the definition of the component exists either on the File System or in the MDS Repository.
         at oracle.adf.mds.internal.MetadataManagerBase.findElement(MetadataManagerBase.java:1352)
         at oracle.adf.mds.MElement.findElement(MElement.java:97)
         at oracle.apps.fnd.framework.webui.JRAD2AKMapper.getRootMElement(JRAD2AKMapper.java:503)
         at oracle.apps.fnd.framework.webui.OAWebBeanFactoryImpl.getWebBeanTypeDataFromJRAD(OAWebBeanFactoryImpl.java:3719)
         at oracle.apps.fnd.framework.webui.OAWebBeanFactoryImpl.getRootApplicationModuleClass(OAWebBeanFactoryImpl.java:3452)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1011)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:511)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:432)
         at _oa__html._OA._jspService(_OA.java:84)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
         at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
         at oracle.jsp.JspServlet.service(JspServlet.java:156)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at oracle.jsp.provider.Jsp20RequestDispatcher.forward(Jsp20RequestDispatcher.java:162)
         at oracle.jsp.runtime.OraclePageContext.forward(OraclePageContext.java:187)
         at _oa__html._OA._jspService(_OA.java:94)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
         at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
         at oracle.jsp.JspServlet.service(JspServlet.java:156)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
         at org.apache.jserv.JServConnection.run(JServConnection.java:294)
         at java.lang.Thread.run(Thread.java:595)
    Exception:
    oracle.adf.mds.MetadataDefException: Unable to find component with absolute reference = ldc/oracle/apps/sla/calnet/xref/phone/webui/PhonePG, XML Path = null. Please verify that the reference is valid and the definition of the component exists either on the File System or in the MDS Repository.
         at oracle.adf.mds.internal.MetadataManagerBase.findElement(MetadataManagerBase.java:1352)
         at oracle.adf.mds.MElement.findElement(MElement.java:97)
         at oracle.apps.fnd.framework.webui.JRAD2AKMapper.getRootMElement(JRAD2AKMapper.java:503)
         at oracle.apps.fnd.framework.webui.OAWebBeanFactoryImpl.getWebBeanTypeDataFromJRAD(OAWebBeanFactoryImpl.java:3719)
         at oracle.apps.fnd.framework.webui.OAWebBeanFactoryImpl.getRootApplicationModuleClass(OAWebBeanFactoryImpl.java:3452)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1011)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:511)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:432)
         at _oa__html._OA._jspService(_OA.java:84)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
         at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
         at oracle.jsp.JspServlet.service(JspServlet.java:156)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at oracle.jsp.provider.Jsp20RequestDispatcher.forward(Jsp20RequestDispatcher.java:162)
         at oracle.jsp.runtime.OraclePageContext.forward(OraclePageContext.java:187)
         at _oa__html._OA._jspService(_OA.java:94)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
         at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
         at oracle.jsp.JspServlet.service(JspServlet.java:156)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
         at org.apache.jserv.JServConnection.run(JServConnection.java:294)
         at java.lang.Thread.run(Thread.java:595)

    Ok, I admit it's my mistake.
    I found a url coded in my CO miss a / at the beginning of the url address.
    So, the Application deployment was OK.
    Incorrect -> "OA.jsp?page=ldc/oracle/apps/sla/calnet/xref/phone/webui/PhonePG"
    Correct   -> "OA.jsp?page=/ldc/oracle/apps/sla/calnet/xref/phone/webui/PhonePG"Note that, in JDeveloper, page will function successfully without the /, but in EBS it will throw the error.
    Code with correct url address embedded.
           pageContext.forwardImmediately("OA.jsp?page=/ldc/oracle/apps/sla/calnet/xref/phone/webui/PhonePG",
                                          null,
                                          OAWebBeanConstants.REMOVE_MENU_CONTEXT,
                                          null,
                                          null,
                                          false, // retain AM
                                          OAWebBeanConstants.ADD_BREAD_CRUMB_NO); Edited by: user595907 on 2010/9/17 下午 4:28

  • I have an Retina display MacBook Pro with HMDI out port. I also have an HDMI to Component cable with Audio Plugs. How can I get HDMI out to work with this cable when plugged into the Component and Audio ports on my TV?

    I have an Retina display MacBook Pro with HMDI out port. I also have an HDMI to Component cable with Audio Plugs. How can I get HDMI out to work with this cable when plugged into the MacBook Pro and connected to the TVs Component and Audio in ports.

    Will not work.  To my knowledge, dual converting like that isn't supported.  The Mac must detect the connected video output device and that sort of info cannot be done across an analog component uni-directional connection.

  • Does anyone know why I can only get sound and no video with a compatible component cable?

    Does anyone know why I can only get sound and no video with a compatible component cable?

    What apps are you trying?  TV out video only works with apps that support TV out.  If the app does not support TV out you will still get aoudio via the component cable

  • Flicker with heavyweight swing component and setVisible(false) on Linux

    Hi All,
    I'm using Java 6 update 14 on Ubuntu Jaunty.
    I'm developing a GUI for a system running linux. I'm using the Swing framework for the GUI but need to include 3D animation accelerated in hardware. I'm using the JOGL framework for applying the 3D animations which supplies one with two swing-like components, the GLJPanel and GLCanvas. These two components are lightweight and heavyweight swing components respectively.
    The difficulty arises when adding the heavyweight GLCanvas component into the gui. Often I need to do a setVisible(false) on the component in which case the GLCanvas hides correctly, but shows a flicker before the background is displayed. On digging a little deeper I found that because the GLCanvas is heavyweight, on linux it calls down to the sun.awt.X11 classes to do the setVisible(false) on hide. The very deepest call, the xSetVisible(false) method of the XBaseWindow class, causes the component to be replaced by first a grey backgound, and then the correct background. This intermediate grey background is causing the flicker.
    The source for the sun.awt.X11 packages was not available with the standard JDK 6 but I've found the open jdk source which matches the steps taken by the call. The xSetVisible method is as follows:
    0667:            public void xSetVisible(boolean visible) {
    0668:                if (log.isLoggable(Level.FINE))
    0669:                    log.fine("Setting visible on " + this  + " to " + visible);
    0670:                XToolkit.awtLock();
    0671:                try {
    0672:                    this .visible = visible;
    0673:                    if (visible) {
    0674:                        XlibWrapper.XMapWindow(XToolkit.getDisplay(),
    0675:                                getWindow());
    0676:                    } else {
    0677:                        XlibWrapper.XUnmapWindow(XToolkit.getDisplay(),
    0678:                                getWindow());
    0679:                    }
    0680:                    XlibWrapper.XFlush(XToolkit.getDisplay());
    0681:                } finally {
    0682:                    XToolkit.awtUnlock();
    0683:                }
    0684:            }I've found that the XlibWrapper.XFlush(XToolkit.getDisplay()) line (680) causes the grey to appear and then the XToolkit.awtUnlock(); line repaints the correct background.
    Using the lightwieght GLJPanel resolves this issue as it is a light weight component but unfortunately I'm unable to use it as the target system does not have the GLX 1.3 libraries required because of intel chipset driver issues (it has GLX 1.2). I cannot enable the opengl pipline either (-Dsun.java2d.opengl=True) for the same reason.
    Is there a way to configure a heavyweight component to avoid the operation in line 680? As far as I can tell, the flicker would disappear and the display would still be correctly rendered had this line not been executed. This problem is not present in windows.
    I've put together a minimal example of the problem. It requires the JOGL 1.1.1 libraries in the classpath. They can be found here: [JOGL-download|https://jogl.dev.java.net/servlets/ProjectDocumentList?folderID=11509&expandFolder=11509&folderID=11508]
    I've also found that running the program with the -Dsun.awt.noerasebackground=true vm argument reduces the flicker to just one incorrect frame.
    The program creates a swing app with a button to switch between the GLCanvas and a normal JPanel. When switching from the GLCanvas to the JPanel a grey flicker is noticeable on Linux. Step through the code in debug mode to the classes mentioned above to see the grey flicker frame manifest.
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Insets;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.media.opengl.GLCanvas;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JInternalFrame;
    import javax.swing.JPanel;
    import javax.swing.WindowConstants;
    import javax.swing.border.EmptyBorder;
    public class SwitchUsingJInternalFrameSwappedExample {
         private static JPanel glPanel;
         private static JPanel mainPanel;
         private static JPanel swingPanel1;
         private static boolean state;
         private static JInternalFrame layerFrame;
         private static GLCanvas glCanvas;
         public static void main(String[] args) {
              state = true;
              JFrame frame = new JFrame();
              frame.setSize(800, 800);
              frame.setContentPane(getMainPanel());
              frame.setVisible(true);
              frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              frame.setBackground(Color.GREEN);
         // The main component.
         public static JPanel getMainPanel() {
              mainPanel = new JPanel();
              mainPanel.setBackground(new Color(0, 0, 255));
              mainPanel.setBorder(new EmptyBorder(new Insets(20, 20, 20, 20)));
              mainPanel.setLayout(new BorderLayout());
              mainPanel.add(getButton(), BorderLayout.NORTH);
              mainPanel.add(getAnimationPanel(), BorderLayout.CENTER);
              return mainPanel;
         // Switch button.
         private static JButton getButton() {
              JButton button = new JButton("Switch");
              button.addActionListener(new ActionListener() {
                   @Override
                   public void actionPerformed(ActionEvent e) {
                        switchToOpenGl();
              return button;
         // Do the switch.
         protected static void switchToOpenGl() {
              // Make the OpenGL overlay visible / invisible.
              if (!state) {
                   glCanvas.setVisible(false);
              } else {
                   glCanvas.setVisible(true);
              state = !state;
         // Normal swing panel with buttons
         public static JPanel getNormalPanel() {
              if (swingPanel1 == null) {
                   swingPanel1 = new JPanel();
                   for (int i = 0; i < 10; i++) {
                        swingPanel1.add(new JButton("Asdf" + i));
                   swingPanel1.setBackground(Color.black);
              return swingPanel1;
         // Extra panel container just for testing whether background colors show through.
         public static JPanel getAnimationPanel() {
              if (glPanel == null) {
                   glPanel = new JPanel(new BorderLayout());
                   glPanel.setBorder(new EmptyBorder(new Insets(20, 20, 20, 20)));
                   glPanel.setBackground(Color.YELLOW);
                   glPanel.add(getLayerFrame(), BorderLayout.CENTER);
              return glPanel;
         // A component that has two layers (panes), one containing the swing components and one containing the OpenGl animation.
         private static JInternalFrame getLayerFrame() {
              if (layerFrame == null) {
                   // Create a JInternalFrame that is not movable, iconifyable etc.
                   layerFrame = new JInternalFrame(null, false, false, false, false);
                   layerFrame.setBackground(new Color(155, 0, 0));
                   layerFrame.setVisible(true);     
                   // Remove the title bar and border of the JInternalFrame.
                   ((javax.swing.plaf.basic.BasicInternalFrameUI) layerFrame.getUI())
                             .setNorthPane(null);
                   layerFrame.setBorder(null);
                   // Add a normal swing component
                   layerFrame.setContentPane(getNormalPanel());
                   // Add the OpenGL animation overlay on a layer over the content layer.
                   layerFrame.setGlassPane(getGLCanvas());
              return layerFrame;
         // OpenGL component.
         public static GLCanvas getGLCanvas() {
              if (glCanvas == null) {
                   glCanvas = new GLCanvas();
                   glCanvas.setBackground(Color.CYAN);
              return glCanvas;
    }

    Oracle employees typically don't read these forums, you can report bugs here: http://bugs.sun.com/bugdatabase/

  • Swing component's margin in a frame

    Hello all,
    When you set the bounds of a Swing component in a frame, it will automatically apply those bounds to the VISIBLE part of the frame, so that, a Y value of 0, for example, will not be at the very top of the frame, but right underneath the title bar of the frame. If you give a regular AWT a value of 0 to it's Y coordinate, part (or all) of it will be covered by the title bar of the frame. This does not happen with Swing components, which automatically add the height of the title bar to the value you give to their Y coordinate.
    Now, what I want to know is, how can I retrieve the value of that "automatic margin"?. How can I know the number of pixels that the Swing component is being slided down, in order to save the title bar of the frame? This value can not be constant, since it will differ from one platform to another, and from one Look 'n Feel to another, but I have not been able to find out the way to get the value that it's being applied in each case.
    As allways, many thanks in advance for your help.

    Don't know if there is any direct way to get this information. But, assuming the border width/height is equal on all four sides you could try something like:
    Dimension frameD = frame.getSize();
    Dimension contentD = frame.getContentPane().getSize();
    int borderWidth = frameD.width - contentD.width;
    int titleHeight = frameD.height - contentD.height - borderWidth;

  • How to set a Swing component as Modal window on a SWT Component.?

    How to set a Swing component as Modal on a SWT Component.I mean, I have a window (SWT Container) with some menu items.
    When I click on one menu item then i will get one new Swing Window.
    When creating the new frame I had passed Modal value as TRUE in the constructer.Now child is not behaving as Modal Window.I mean I am able to go to parent window even though the child window is opened as a Modal Window.This is only happened when I double click on the Title Bar of the Parent Window.
    If I try to click on any other part of the Parent Window except Title bar ... the child window is working as a Modal Window.
    Can any one suggest me to solve this one !!

    int this case, do this :
    JFrame f = new JFrame("Authentification");
    f.getContentPane().setLayout(new BorderLayout());
    f.getContentPane().add(myJPanel, BorderLayout.CENTER);
    f.setBounds(x,y,w,h);
    f.setVisible(true);
    Where myJPanel is the Panel you developped.

  • How to embed swing component into javaFX ?

    Maybe I missed sth, but can someone explain us how can we embed swing component into javaFX 2.0 ?
    This was previously handled with javaFX "srcipt", why can't we do it anymore ?
    As far as the work to migrate from 1.3 to 2.0 is hard and huge, why do fx2.0 do not offer such feature anymore ? :(
    I know that ThingFx project try to cope with, but the current code doesn't match with my needs.
    Thanks for help,
    Edited by: tibO on 23 nov. 2011 14:35

    I know this post is old and the original authors might not even ben active; but it essentiall gets to the heart of what I'm trying to.
    I have a JDialogBox. In it I have a panel (which I have to change to a JScrollPane). Inside the JPanel I have a JLabel and a JTextArea.
    I was told to; make it scrollable in the event that there is too much info for the JDialogBox and to add HTML formatting (simple stuff like bold and colors.
    1) The JScrollBar doesn't seem to produce the scroll side bars.
    2) I must not be implementing the JEditorPane correctly. I just substituted JEditorPane for JTextArea in my code and it returned a type converstion error. Is JEditorPane even the correct object to use? Should I be using JTextPane?
    The reason I can't do this on a JLabel by JLabel basis is because I don't know how many labels I will need at each runtime. And I also have to have a swingtimer on it. I could create an array and loop around it to create the JLabels. But it seems a waste of commuting cycles. This is no good?

  • Custom ui component with default layout

    Hello,
    I am trying to develop custom swing components with default layout set.
    Both component class and its BeanInfo are written with NetBeans 6.1
    However, when trying to put this custom swing component into interface builder (matisse) of
    NetBeans 6.1, the default layout is always replaced with GroupLayout.
    Is there any way to correctly specify default layout manager used in a custom
    swing component?
    thanks a lot!

    Hi Jacek
    You can embed your custom component with IFrame element in WebDynpro view. IFrame element loads a content by URL which can be bound to controller's context. You can store your custom HTML content in MIME folder of the WebDynpro component. At runtime you can get the URL to the MIME content and initialize the IFrame with the URL.
    However, IFrame element is being reloaded by WebDynpro framework too often during each request/response cycle. This is a disadvantage of the solution.
    BR, Siarhei

  • How to get my custom controller updated with the global custom controller?

    Hi all,
    I'm new to CRM Web UI and need some advice from the expert. Currently I'm working on component ICCMP_BT_DATES and noticed something weird with this component. When this component is first launch it display the dates of a service ticket correctly. However when I navigate to another screen, save a new ticket and back, the dates are not reflected. When I went in and debug the component, I noticed that the context is still tied to the previous ticket. I think the custom controller is not updated with the latest from the global custom controller.
    My question is how do I get my custom controller updated with the latest.
    Regards,
    Ricky

    You have to bind your custom controllers context node to the event NEW_FOCUS of the collection wrapper on the global custom controller.
    Best place to do this might be the CONNECT_NODES of the context of your custom controller.
    Get the global CuCo with GET_CUSTOM_CONTROLLER() and then the appropriate context node. Now:
    SET HANDLER yourMethod for lr_global_cuco->typed_context->thecontextnode->collection_wrapper activation iv_activate.
    Of course you have to implement a method similar to ON_NEW_FOCUS as it is on many other nodes.
    cheers Carsten

  • How to get real value from selectOneChoice with javascript?

    Hi,
    How to get real value from selectOneChoice with javascript? The event.getNewValue() only gets me the index of the selected item, not the value/title.
    JSF page:
    <af:resource type="javascript">
    function parseAddress(event)
    alert("new value: " + event.getNewValue());
    </af:resource>
    <af:selectOneChoice label="Location:" value="" id="soc4">
    <af:clientListener type="valueChange" method="parseAddress" />
    <f:selectItems value="#{Person.locations}" id="si7"/>
    </af:selectOneChoice>
    HTML :
    <option title="225 Broadway, New York, NY-10007" selected="" value="0">225 Broadway (Central Office)</option>
    <option title="90 Mark St., New York, NY-10007" value="1">90 Mark St. (Central Office)</option>
    Thanks a lot.

    Something I was missing ,
    You need to add valuePassThru="true" in your <af:selectOneChoice component. I have personally tested it and got the actual value in alert box. I hope this time you got the real solution. You can also test the following code by your end.
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document id="d1">
    <af:form id="f1">
    <af:panelBox text="PanelBox1" id="pb1">
    <af:selectOneChoice label="Set Log Level" id="soc1"
    value="#{SelectManagedBean.loggerDefault}"
    valuePassThru="true">
    <af:selectItem label="select one" value="First" id="s6"/>
    <af:selectItem label="select two" value="Second" id="s56"/>
    <af:clientListener method="setLogLevel" type="valueChange"/>
    </af:selectOneChoice>
    <af:resource type="javascript">
    function setLogLevel(evt) {
    var selectOneChoice = evt.getSource();
    var logLevel = selectOneChoice.getSubmittedValue();
    // var logLevelObject = AdfLogger.NONE;
    alert("new value is : " + logLevel);
    //alert(evt.getSelection);
    //alert(logLevelObject);
    evt.cancel();
    </af:resource>
    </af:panelBox>
    </af:form>
    </af:document>
    </f:view>
    </jsp:root>

  • How can I select an item from a list component with a seperate button

    This is a repost, I decided it'd probably be better here than
    in the general discussion board. I will try to delete the other
    one.
    Hello Everyone,
    This is my first post here. I am trying to figure out how to
    select an item within a list component with a button. This button
    is calling a function. I have searched for the past 3 hours online
    and I can't find anything about it. I thought perhaps I could set
    the selectedItem parameter, but that is read only, and I believe it
    returns an object reference rather than something like a number so
    even if i could set it, it would be pointless. I also found a get
    focus button, thought that may lead me somewhere, but I think that
    is for setting which component has focus currently as far as typing
    in and things like that. I am lost.
    Basically I am looking for a way to type this
    myList.setSelected(5); where 5 is the 5th item in the list.
    Any help would be much appreciated.

    Never mind found it. It is the property called selectedIndex
    and it is writable

  • How to get bounds of a component in FreeDesign layout

    When I try to get bounds of a component that is inside JPanel with FreeDesign layout, I get (0,0,0,0)!
    How can I find out current bounds of those components?

    When I add a component on JPanel with FreeDesign layout (I use NetBeans GUI editor to do it), in generated code I find org.jdesktop.layout.GroupLayout with some HorizontalGroup and VerticalGroup components, and no bounds are ever set!!! When I start the application, a component is shown on JPanel, and definitely bounds are not 0,0,0,0! The components are stretched over window, and everything looks just as I set in GUI editor. A problem is that in runtime I need to know bounds of a component that is showed on screen. A method getBounds() returns (0,0,0,0), so I think that it is not appropriate for this layout.
    So, my question remains: How to find out bounds of a component in FreeDesign layout!
    Thanks!
    Message was edited by:
    mmilic

  • RegionRenderer encodeAll The region component with id: pt1:r1 has detected a page fragment with multiple root components. Fragments with more than one root component may not display correctly in a region and may have a negative impact on performance.

    Hi,
    I am using JDEV 11.1.2.1.0
    I am getting the following error :-
    <RegionRenderer> <encodeAll> The region component with id: pt1:r1 has detected a page fragment with multiple root components. Fragments with more than one root component may not display correctly in a region and may have a negative impact on performance. It is recommended that you restructure the page fragment to have a single root component.
    Piece of code is for region is:-
       <f:facet name="second">
                                                <af:panelStretchLayout id="pa1"
                                                                       binding="#{backingBeanScope.Assign.pa1}">
                                                    <f:facet name="center">
                                                        <af:region value="#{bindings.tfdAssignGraph1.regionModel}" id="r1"
                                                                   binding="#{backingBeanScope.Assign.r1}"/>
                                                    </f:facet>
                                                </af:panelStretchLayout>
                                            </f:facet>
    How do I resolve it ?
    Thanks,

    Hi,
    I see at least 3 errors
    1. <RegionRenderer> <encodeAll> The region component with id: pt1:r1 has detected a page fragment with multiple root components.
    the page fragment should only have a single component under the jsp:root tag. If you see more than one, wrap them in e.g. an af:panelGroupLayout or af:group component
    2. SAPFunction.jspx/.xml" has an invalid character ".".
    check the document (you can open it in JDeveloper if the customization was a seeded one. Seems that editing this file smething has gone bad
    3. The expression "#{bindings..regionModel}" (that was specified for the RegionModel "value" attribute of the region component with id "pePanel") evaluated to null.
    "pageeditorpanel" does seem to be missing in the PageDef file of the page holding the region
    Frank

Maybe you are looking for

  • SAP SRM Contract : identify Creation/Release and restrict BADI call

    Hi There! I need some suggestion on one of the issue i'm having now: The SRM contract workflow works on n-level approval for which a BADI is implemented for the approvers. Now for one of the custom sub-process i need to trigger a different workflow f

  • Displaying component in ADF conditionally

    Hi, I need to hide/display some fields in an ADF application based on some conditions. Please let me know how to achieve this. Is it possible to get the value from a java code or DB to take the decision. Please help.

  • Changing ERS & GR based IV flags

    SAP Experts, Is it possible to change the GR based IV and ERS flags on a schedule agreement after it has been released against? The problem we have is AP is forced to enter invoice only after GR has been performed and we would like to change that how

  • Exporting .mov as DV - NTSC Creates Letterbox Effect

    Hi, I've been trying to export a video and I'm getting some weird output. I want an uncompressed .mov file, so when I'm exporting I pick to export as .mov, then create a new preset, choose the "Apple DV/DVCPRO - NTSC" codec, and set it to 16:9 (becau

  • Extract HTML Meta information in the servlet ?

    Guys, I am using the following meta information in my HTML . <META HTTP-EQUIV="msisdn" CONTENT="99999999"> <META HTTP-EQUIV="name" CONTENT="XXXXXXXX"> However, I unable to extract the header information in my Servlet class using the String msisdn = r