Swing components and Mac OS/9

Hi all,
I 've developped an app using swing components (Simple app using a hsqlbd database) and i read that it was kind of possible to port it on a mac os/9.
I had a look on the net, on the apple site, without any luck as how to "add" swing library on the mac os/9.
If someone could point me to the right direction (Web site, book etc), I 've been looking for a while without finding any clear and precise info on how to tackle this kind of problem.
Thanks in advance.

As per my knowledge, u can use JJEdit editor on MAC OS X. By using this editor, you can run the applets. Here I am using JJEdit as a java editor on MAC OS X. just dowload the JJEdit. and run the applet on it.
regards
nr konjeti

Similar Messages

  • Swing Components and Fullscreen Exclusive

    Hi, I am trying to write a program that can switch between full screen and windowed mode seamlessly, while still being able to use standard swing components. I have never worked with the full screen exclusive mode before and am having trouble getting the components to repaint properly.
    The following code works fine in the windowed and undecorated modes, however when I switch to fullscreen exclusive mode all components disappear and only repaint upon mouseover or other interaction. Calls to repaint do not make any difference.
    import java.awt.Dimension;
    import java.awt.DisplayMode;
    import java.awt.FlowLayout;
    import java.awt.GraphicsDevice;
    import java.awt.GraphicsEnvironment;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.WindowConstants;
    public class FullscreenTests {
         private static boolean hwlast = false;
         private static GraphicsDevice dev = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
         public static void main(String[] args) {
              final JFrame fMain = new JFrame("Title");
              fMain.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              fMain.getRootPane().setLayout(new FlowLayout());
              JButton win = new JButton("Windowed");
              win.addActionListener(new ActionListener () {
                   public void actionPerformed (ActionEvent e) {
                        setWindowed(fMain);
              fMain.getRootPane().add(win);
              JButton ful = new JButton("Fullscreen");
              ful.addActionListener(new ActionListener () {
                   public void actionPerformed (ActionEvent e) {
                        setFullscreen(fMain);
              fMain.getRootPane().add(ful);
              JButton hw = new JButton("HW Fullscreen");
              hw.addActionListener(new ActionListener () {
                   public void actionPerformed (ActionEvent e) {
                        setHWFullscreen(fMain);
              fMain.getRootPane().add(hw);
              setWindowed(fMain);
         public static void setWindowed(JFrame f) {
              if (hwlast == true) {
                   dev.setFullScreenWindow(null);
                   hwlast = false;
              f.dispose();
              f.setIgnoreRepaint(false);
              f.setUndecorated(false);
              Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
              f.setSize(new Dimension(808,634));
              f.setMinimumSize(new Dimension(808,634));
              f.setLocation((d.width-f.getWidth())/2, (d.height-f.getHeight())/2);
              f.setVisible(true);
         public static void setHWFullscreen(JFrame f) {
              hwlast = true;
              f.dispose();
              f.setUndecorated(true);
              f.setIgnoreRepaint(true);
              f.setVisible(true);
              dev.setFullScreenWindow(f);
              dev.setDisplayMode(new DisplayMode(800, 600, 32, DisplayMode.REFRESH_RATE_UNKNOWN));
         public static void setFullscreen(JFrame f) {
              if (hwlast == true) {
                   dev.setFullScreenWindow(null);
                   hwlast = false;
              f.dispose();
              f.setIgnoreRepaint(false);
              f.setUndecorated(true);
              f.setSize(Toolkit.getDefaultToolkit().getScreenSize());
              f.setLocation(0,0);
              f.setVisible(true);
    }On the same note, if there are better ways of doing this I would be glad to know. This is just a quick test so I haven't done any checks etc when switching to fullscreen exclusive.

       public static void setHWFullscreen (JFrame f) {
          hwlast = true;
          f.dispose ();
          f.setUndecorated (true);
          f.setIgnoreRepaint (true);
          // add this
          Graphics g = f.getGraphics ();
          f.paintAll (g);
          f.setVisible (true);
          dev.setFullScreenWindow (f);
          dev.setDisplayMode (new DisplayMode (800, 600, 32, DisplayMode.REFRESH_RATE_UNKNOWN));
       }db

  • Swing components and the garbage collector

    How much care does one need to take with swing components, with reference to running out of stack space? I ask because I'm writing a system for an automotive parts company, and the company tends to not reboot the machines very often...
    Anyway... if a JFrame is closed, is it and all its components marked for GCing? Do I need to call the dispose method, or is this part of the default close behaviour? Or is there something else entirely?
    Cheers

    In class that calls for .setVisible(false) of one JFrame u MUST call
    for dispose() method.
    so
    myFrame.setVisible(false)
    myFrame.dispose()
    myFrame = null // to help the garbage collector
    If u have classes that becames from JFrame (or JDialog) u can
    invoke in its constructors:
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
    This makes uncecessary to call for dispose() method explicetly.
    If u do not have this kind of classes u can invoke this method
    after u have create your JFrame
    JFrame myFrame = new JFrame();
    myFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
    The most important thing is REMOVE ALL LISETNERS that u have added, so, if u have classes that becames from JFrame u can ovverride
    the dispose method to do that
    eg
    public void dispose()
    super.dispose()
    removeActionListener(.....)
    and so on
    If u do not have this kind of classes u must remove all listeners u have
    added before u invoke the setVisible(false) method.
    Regards

  • Third party Swing components and ADF need tips

    Need some tips how to
    1 - create databindings for them
    2 - automatically bind component when drag&drop from component palette
    Message was edited by:
    matal

    Matal,
    we don't yet have documentation for creating custom Swing bindings to ADF. Automating the binding with drag and drop would be the logical follow up. Note that if your custom component shares the same model with another existing components, you can first drag and drop the existing component to then change it to an instance of your custom component.
    Frank

  • Hindi characters' display in swing components on mac

    I have created a swing application that handles devanagari script.(script for Hindi language).The application works perfectly in windows but in apple macintosh
    there is a problem with the reordering of characters in text componets. Reordering means some characters needs to be displayed not in the exact order in which they are stored.I was wondering how this can happen as the application works fine on windows.Also other applications like text editor displays devanagari script correctly on macintosh.
    I tried with several fonts like Arial Unicode MS,Devanagari MT etc/.java

    OK, I asked the FTE team and got this reply: "Lucida Grande is CTS's fallback font for Thai.  This font on OS 10.7 and 10.6 are not supporting Thai anymore.  The version on 10.5 was supporting it." This means that it's our bug that we keep using Lucida Grande as fallback font even Apple dropped support Thai script with that font after 10.6. Unfortunately this bug was deferred from current development release (11.2) because of time constraint. If this support is critical for your business, can you open a bug in our public bugbase and ask as many vote as possible? In this way I may be able to convince internal team to fix this bug in next release.
    Thank you for your feedback!
    Hitomi

  • Size settings for swing components and resizing of a JFrame

    Hi all!
    I'd have the following question:
    There is a JFrame, which content panel has the GridBagLayout. In some places on that layout's grid there are JScrollPanels (let's name each as "inner panel") with JTables in the view ports.
    When user resizes the main JFrame, I'd like that all inner panels and corresponding tables would resize synchronously: if user enlarges the main JFrame, then the sizes of all those components should increase proportionally, when user makes the main JFrame smaller, then all the sizes should become proportionally less.
    I am confused with the settings for max, min and preffered sizes for inner panels as well as for their JTables. I have read about those size attributes and tried to play with them, but I can't obtain the needed result :-/
    Each inner panel has the "BOTH" value for the fill attribute in the GridBagLayout's constraints.
    Might someone help me?
    Thanks in advance!

    Hmm...
    The JPanel that contains all stuff is the JFrame's content pane...
    The entire JFrame's content pane contains another panels (JScrollPanels), which are all set to fill all available space on the parent panel (JFrame's content pane) with "both" value of the "fill" attribute.
    Should I put the only one JPanel on the JFrame's content pane and all other stuff at that additional JPanel...?

  • Managing Swing components and PLAF

    I have an application that has many JFrames, and JDialogs associated with it, and I was wonder what the best way to manage them are. What I mean is that The amount of JFrames and JDialogs that will be open is dynamic depending on the user selections. So, If I have an indeterminate number of JFrames and JDialogs, what is the most efficient way to change the plugable look and feel for all windows.
    The initial way I solved this problem was to create a WindowManager class and have factory methods that created Frames and Dialogs. The created Frames and Dialogs were then placed into a Collection, and another static method would change the look and feel and run the SwingUtilities.updateComponent() method on each of the items in the Collection.
    My problem is that I do not think this is the best solution, since it does not follow normal Design Patterns. I was thinking of implementing some sort of Decorator Pattern, or maybe a State Pattern, but I dont know what the "best" solution would be.
    Any help would be appreciated.

    bump

  • Trying to understand "thread-safe" w/ swing components

    The other day there was a big hullabaloo about some code I posted because I was calling JLabel.setText from a thread that wasn't the ui thread. On the other hand, this thread was the only thread making changes to the JLabel. My understanding is that in any kind of multi-threaded system, if you just have 1 writer / changer, then no matter how many readers there are, this is thread-safe. So why what I was doing not thread safe?
    Second question - JLabel.setText() is essentially setting data in the model for JLabel, which then gets picked up and displayed the next time the GUI thread paints it. So if it's not safe to update a JLabel's model, I assume its never safe to update any data that also is being displayed visually. So for instance, if I was showing some database table data in a JTable, I should do the update in the UI thread - probably not. But what is the distinction?
    Third question - what swing components and what operations need to be run on the UI thread to call your program "thread-safe". Validate? setSize()? setLocation()? add? remove? Is there anything that can be called on swing components from a non-ui thread?
    Edited by: tjacobs01 on Nov 2, 2008 8:29 PM

    tjacobs01 wrote:
    My understanding is that in any kind of multi-threaded system, if you just have 1 writer / changer, then no matter how many readers there are, this is thread-safe. So why what I was doing not thread safe?This is not true. As I mentioned in that hullabaloo thread, the Java Memory Model allows threads to cache values of variables they use. This means that values written by one thread are not guaranteed to ever be visible to other threads, unless you use proper synchronization.
    Take the following example:
    import java.util.concurrent.TimeUnit;
    public class ThreadExample {
        static class Foo {
            private String value = "A";
            public String getValue() {
                return value;
            public void setValue(String value) {
                this.value = value;
        public static void main(String[] args) {
            final Foo foo = new Foo();
            Thread writer = new Thread() {
                @Override
                public void run() {
                    try {
                        TimeUnit.SECONDS.sleep(1);
                        foo.setValue("B");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
            Thread reader = new Thread() {
                @Override
                public void run() {
                    try {
                        TimeUnit.MINUTES.sleep(1);
                        System.out.println(foo.getValue());
                    } catch (InterruptedException e) {
                        e.printStackTrace();
            writer.start();
            reader.start();
    }Here two different threads both access the same Foo instance, which is initialized with a value of "A". One thread, the writer, sleeps one second, and then sets foo's value to "B". The other thread, the reader, sleeps one minute (to avoid race conditions) and then prints foo's value to System.out. It may seem obvious that the reader thread will read the value "B", but this is in fact not guaranteed to be true. The reader thread may never see the value that was written by the writer thread, so it may very well read the old value "A".
    (If you run the code you will probably see "B" printed out, but again, this is not guaranteed behavior.)
    A simple way to fix this is to synchronize access to the mutable state that the two threads share. For example, change the class Foo to
        static class Foo {
            private String value = "A";
            public synchronized String getValue() {
                return value;
            public synchronized void setValue(String value) {
                this.value = value;
        }It's for this same reason that you often see the use of a volatile boolean as a control flag for stopping threads, rather than a plain old boolean. The use of volatile guarantees that the thread you want to stop actually sees the new value of the flag once it has been set by another thread.
    Here is an article that touches some of this stuff:
    [http://www.ibm.com/developerworks/java/library/j-jtp02244.html]
    I also highly recommend the book "Java Concurrency in Practice" (one of the authors of which, David Holmes, sometime hangs out on the Concurrency forum here, I believe).
    Edited by: Torgil on Nov 2, 2008 9:01 PM

  • Developing new Swing Components - Visibility problems with UI classes

    I was wondering if anyone out there had run into the following problems when developing new Swing components. If so it might be worth banding together and putting pressure on Sun to fix them. However, if no one else develops new Swing components then I guess I'm just a lone voice...
    I have been writing a new dockable toolpanel Swing component and when it came to implementing the UI manager I was unable to access many of the standard features in basic and metal LAFs because they had been made package protected. This forced me to reimplement quite a bit of existing code which took time as well as being bad practice.
    While in some cases I can understand this from a security POV I am pretty sure that in this case it is the result of lazy programming practice. Appart from basic architectural reasons for this I have noticed a trend where newer code seems to suffer from this more than the original code. The practice of using package protection reminds me of C++ style coding, or just that of an inexperienced developer who does not understand the need to code for extensibility.
    An additional problem arises because the Security manager stops you cheating the system by putting new classes into the javax.swing.plaf... package structure. Thus the only way to solve this nicely is a proper fix.
    This would entail going through all the UI PLAF classes and rationalizing the visibility to either public or protected as appropriate. Really there should be minimal use of package protection unless it is vital for security concerns.
    Some Examples (there are many more):
    javax.swing.plaf.basic.LazyActionMap
    javax.swing.plaf.basic.BasicBorders.RolloverMarginBorder
    javax.swing.plaf.basic.BasicBorders.SplitPaneDividerBorder (why are just these two classes package protected when all the others are public?)
    javax.swing.plaf.metal.MetalUtils
    javax.swing.plaf.metal.MetalBumps
    Anyway, I am happy to give advice to other poor saps who wind up fighting the UI manager but it would be better if we could get Sun to sort out this mess (after all they created it).
    Cheers, Lewis

    It may be more a case of creating new Swing components and trying to provide support for all the standard LnFs.
    This is very awkward although you can sometimes achieve what you want by borrowing resources from UIManager (a border here, an icon there etc.).
    Essentially the problem is that Swing is designed to have new components added to it but the standard LnFs aren't quite so accommodating!

  • JDBC-ODBC Bridge, Swing Components

    This program displays information from the Access database Autos.mdb.
    Uses the JDBC-ODBC Bridge.
    Requires a DSN called Autos pointing to Auto.mdb
    I am using the swing components and can't seem to set up my combobox to pull the right data which doesn't display any of the data from the database. I am able to do it using AWT but would like a sleeker look so I am trying to convert. I have made the text bold where I am having the problem. Any insight would be greatful! I am very new to JDBC-ODBC so please go easy on me...
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class JDBCApp extends Frame implements ItemListener
         //Declare database variables
         Connection conVehicle;
         Statement cmdVehicle;
         ResultSet rsVehicle;
         boolean blnSuccessfulOpen = false;
         //Declare components
         JComboBox lstManuf   = new JComboBox();
         JLabel lblModel  = new JLabel("                          ");
         JLabel lblYear        = new JLabel("                          ");
         JLabel lblCost      = new JLabel("                          ");
         JLabel lblID      = new JLabel("                              ");
         JLabel lblInstructions = new JLabel("Select Manufacturer to Display Record");
         public static void main(String args[])
              //Declare an instance of this application
              JDBCApp thisApp = new JDBCApp();
              thisApp.createInterface();
         public void createInterface()
              //Load the database and set up the frame
              loadDatabase();
              if (blnSuccessfulOpen)
                   setTitle("Display Auto's Database");
                   addWindowListener(new WindowAdapter()
                             public void windowClosing(WindowEvent event)
                                  stop();
                                  System.exit(0);
                   setLayout(new FlowLayout());
                   add(new JLabel("Manufacturer"));
                   add(lstManuf);
                   lstManuf.addItemListener(this);
                   add(lblInstructions);
                   add(new JLabel("Model"));
                   add(lblModel);
                   add(new JLabel("Year"));
                   add(lblYear);
                   add(new JLabel("Cost"));
                   add(lblCost);
                   add(new JLabel("Vehicle Identification"));
                   add(lblID);
                   setSize(300,300);
                   setVisible(true);
              else
                   stop();             //Close any open connection
                   System.exit(-1);    //Exit with error status
              public void loadDatabase()
                   try
                        //Load the MicroSoft drivers
                        Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
                   catch (ClassNotFoundException err)
                             //No drivers found
                             System.err.println("Driver did not load properly");
                   try
                        //Connect to the database
                        conVehicle = DriverManager.getConnection("jdbc:odbc:Auto");
                        //Create a ResultSet
                        cmdVehicle = conVehicle.createStatement();
                        rsVehicle = cmdVehicle.executeQuery(
                                            "Select * from Vehicle;");
                        loadNames(rsVehicle);
                        blnSuccessfulOpen = true;
                   catch(SQLException error)
                        System.err.println("Error: " + error.toString());
         public void loadNames(ResultSet rsVehicle)
              try
                   //Fill last name list box
                   while(rsVehicle.next())
                   lstManuf.addItem(rsVehicle.getString("Manufacturer"));
              catch (SQLException error)
                   System.err.println("Error in display record");
         public void itemStateChanged(ItemEvent event)
              //Display the selected record
              lblInstructions.setText("");          String strManufName = lstManuf.getText();
              try
                   Statement cmdVehicle = conVehicle.createStatement();
                   ResultSet rsVehicle = cmdVehicle.executeQuery(
                        "Select * from Vehicle where [Manufacturer] = '" + strManufName + "';");
                   DisplayRecord(rsVehicle);
              catch(SQLException error)
                   System.err.println("Error in recordset");
          public void DisplayRecord(ResultSet rsVehicle)
               try
                   //Display information
                   if(rsVehicle.next()) //If more records remain
                        lblModel.setText(rsVehicle.getString("ModelName"));
                        lblYear.setText(rsVehicle.getString("Year"));
                        lblCost.setText(rsVehicle.getString("CostValue"));
                        lblID.setText(rsVehicle.getString("VehicleID"));
                   else
                        System.err.println("No more records");
              catch (SQLException error)
                   System.err.println("Error in display record");
         public void stop()
              try
                   //Terminate the connection
                   if (conVehicle != null)
                        conVehicle.close();
              catch(SQLException error)
                   System.err.println("Unable to disconnect");
    }

    I am going to help you out but first I would like to advise you not to do this.
    Mixing JDBC and Swing (or any GUI for that matter) like this is not the preferred way to proceed. If you want to learn JDBC then command line/shell is fine. If you want to learn Swing learn Swing. When you want to use the two together learn about MVC first.
    I am advising you to do this because nobody writes code like this (mixing GUI and database and business logic all in one class). So if you want real world training MVC should be what you look at next.
    See http://en.wikipedia.org/wiki/Model-view-controller for more
    As near as I can tell your problem is mostly just because you aren't using the combo box correctly. Try
    String strManufName = lstManuf.getSelectedItem().toString();it's a bit of a hack but will work for your purposes. What you need in the eend is to use the methods JComboxBox has like getSelectedItem() or getSelectedIndex().
    See http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html for more.
    Some other comments.
    1) It's nice to see you aren't just swallowing exceptions but some of them are kind of pointless if you just continue on. Like here
    try
      //Load the MicroSoft drivers
      Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    catch (ClassNotFoundException err)
      //No drivers found
      System.err.println("Driver did not load properly");
    }And then you continue on with the method. What for? There's no point since the driver didn't load.
    2) Please look into the use of PreparedStatements. Very good things those. You can use them in place of your Statements. They are safer but for your purposes help you by you not having to worry about the formatting of data you bind to queries. For example what happens if a manufacturer name contains a ' (single quote) ? Trouble that's what. PreparedStatements make that problem go away.
    3) Don't use SELECT *. It is always good practice to put the names of the columns you are selecting. This prevents your code from breaking if the order of the columns should change in any way.

  • Not getting swing components when the applet reloads

    I am facing one problem that is related to reloading of swing components. I Have a JPanel inside JApplet which contains some swing components and a button to launch the same JPanel again in the JApplet. When I click on the button the JPanel should get added in the JApplet once again below the upper JPanel. But new JPanel is not getting displayed although the reference of the new JPanel is created.

    My guess is that you haven't added your swing components to the right place. Are you adding them to the contentpane?

  • 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/

  • About the difference between the AWT components and the swing components

    As we know that an AWT component has a peer, but dose a lightweight component(e.g: a swing component) has also a peer? And could somebody tell me that who and how creates the CLICKED_EVENT when I click a JButton(a swing component), and where the CLICKED_EVENT to go util it was processed by a method like btn_ok_clicked(Event e)? And if I click a Button(an AWT component), what's the difference?
    Thanks a lot!

    The main difference is that AWT are native components, and Swing components are entirely in java written. That's besides the look and feel. There are a lot of other differences between AWT and Swing, and there are better described in the documentation.

  • Hindi Numerals and Hejri calender in swing components

    Hi
    Are Hindi numerals and Hejri calender supported in JDK 1.4 swing components or not?
    Please I need this as soon as possible.
    Thanks in advance
    Marwa Aboulfadl

    hello!
    I am developing an arabic editor but i am unable to display the arbic numeric in swing text .Plz help me on this topic and send some code example on this topic.
    I have another problem about events i.e how can i handle the beckspace event, enter event, and spaceevent?
    plz send me mail .
    Thanx for advance.

  • Embedding Swing Components within Javafx Scene (on a Mac)

    Currently I trying to embed swing components into javafx through steps located here: SwingNode The Myth not the reality | In-SideFX
    Was able to get it working on a PC, however when the packaged jar is run on a mac, I end up with the "Headless exception"
    "Process manager already initialized: can't fully enable headless mode." (error attached below)
    Currently using java 7 update 51, using java 8 is not an option unfortunately.
    Does anyone know of a work around to get this working in mac or possibly point me in the right direction?
    Please let me know if providing other things would help. Thank you in advanced!

    Currently I trying to embed swing components into javafx through steps located here: SwingNode The Myth not the reality | In-SideFX
    Was able to get it working on a PC, however when the packaged jar is run on a mac, I end up with the "Headless exception"
    "Process manager already initialized: can't fully enable headless mode." (error attached below)
    Currently using java 7 update 51, using java 8 is not an option unfortunately.
    Does anyone know of a work around to get this working in mac or possibly point me in the right direction?
    Please let me know if providing other things would help. Thank you in advanced!

Maybe you are looking for

  • Error while entering Long message in Email Template

    Hi All, While Creating Email template with 28 kb data as Long message field in OIM 11g R2 Im getting error like "Invalid size of inputs in en_US in Locale  " so unable to save and please provide the solution Is there any changes in property or someth

  • JPEGS not showing on app

    Hi, I've installed the Lightbox gallery widget and exchanged the sample pictures with some of my own. Everything looks like in live view but not showing up on the app itsekf when loaded on the phone. Have I missed out on something? /Cynthia

  • Chinese seal script won't print, though other Chinese styles will print just fine

    Windows 8.1, Word 2013/365, printer is HP Photosmart 5514. The printer simply doesn't print the document. It says,  "The printer couldn't print Microsoft Word ____" (document name is where ___ is). I can print documents in other Chinese character sty

  • Render (both for preview and export) takes forever

    I'm running Premiere Elements 12.0 (really 12.1) in a MacBook Pro Retina running 10.10.1 (14B25) It has quad Core i7 each 2.7 gH,  NVIDIA GeForce GT 650M 1024 MB, 16 GB of ram, and a 750GB SSD disk. There are no other applications running on the comp

  • Safari Random Quit -- any solutions yet?

    Safari 6 on 10.7 Lion has been randomly quitting on me for months now. There is no error report just this message in the Console: Received an invalid message from the web process with message ID 323002f I see that others are having the same problem w