JavaHelp in JInternalFrame

Hello everyone, there is a method for view the Help (standard and Dynamic contest-sensitive) in a JInternalFrame and its not view in a Frame? Thanks all!!

I have finally discovered why this strange thing happens:
My local server is: linux.pp.com
My remote server is: www.pp.com
As I use linux.pp.com connection inside my local network, everything works fine.
As I use remotelly use a www.pp.com connection I get this (not so strange error) BECAUSE:
I had mistakenly entered a line "www CNAME otro_server" in my dns setup.
As soon as I changed it to "www CNAME linux" and restarted my dns, everything began
to work as expected.
So it has something to do with NAT...

Similar Messages

  • Use of JInternalFrame in populated JFrame?

    Hi,
    For my application I'm working on a simple Help screen (I do not want to use JavaHelp). The help screen I have developed is based on a JInternalFrame. This help screen is to be filled with HTML formatted text, that I load at start up. The loading of the text file works fine.
    The application displays everything in a JFrame. When request the helpscreen is also to be displayed.
    At start up I only display a JPanel taking up only (the middle) part of the JFrame. When I request the help screen, it is displayed to the right of the JPanel.
    When I request the help screen when my JFrame has content, it is not shown. Would you know why that is? Does the help screen have to compete for screen space, and failing in it? Should I use something of an Z-order to get my Help screen to be displayed over the other content of the JFrame?
    Abel
    The following (non compilable code, it contains errors :-( ) might show what I'm trying to do:
    import java.awt.*;
    import java.awt.event.*;
    import java.io.IOException;
    import javax.swing.*;
    public class HelpScreenPlace extends JFrame implements ActionListener {
         static HelpScreenPlace helpScreenPlace;
         static JMenuBar menuBar;
         static JMenu menu;
         static JMenuItem hMenuItem;
         static JInternalFrame helpFrame;
         static JEditorPane editorScrollPane;
         static int WIDTH = 450;
         static int HEIGHT = 350;
         static JTextField userNameField;
         static JLabel unameLabel = new JLabel("Username: ", SwingConstants.RIGHT);
         static JTextField passwordField;
         static JLabel passLabel = new JLabel("Password: ", SwingConstants.RIGHT);
         public HelpScreenPlace () {
              super("HelpScreenPlace");
              menuBar = new JMenuBar();
              menu = new JMenu ("Help");
              menu.setMnemonic(KeyEvent.VK_H);
              menu.getAccessibleContext().setAccessibleDescription("Help menu");
              menuBar.add(menu);          
              // The help contents functionality
              // TODO help functionality
              hMenuItem = new JMenuItem ("Help Contents");
              hMenuItem.setMnemonic(KeyEvent.VK_H);
              // What to do to get the keyboard shortcut F1 (no ALTMASK and the like)?
              hMenuItem.addActionListener(this);
              menu.add(hMenuItem);
              add(menuBar);
         public static void createAndShowGUI() {
              helpScreenPlace = new HelpScreenPlace();
              // Add a login panel (without functionality
              JPanel logInPanel = new JPanel();
              logInPanel.setLayout(new GridLayout (3, 2)); // 3 rows, 2 columns
              logInPanel.setBounds (WIDTH, HEIGHT, WIDTH, HEIGHT);
              userNameField = new JTextField ("jdoe", 10);
              passwordField = new JPasswordField("unanimous_unite", 10);
              logInPanel.add (unameLabel);
              logInPanel.add (userNameField);
              logInPanel.add(passLabel);
              logInPanel.add(passwordField);
              JComponent okButton = createButtonPanel();
              logInPanel.add(okButton);
              // An empty panel to fill up the empty spot after the button
              JPanel emptyPanel = new JPanel();
              emptyPanel.setBackground(Color.WHITE);
              logInPanel.add(emptyPanel);
              logInPanel.setSize(WIDTH, HEIGHT);
              logInPanel.setVisible (true);
         static JComponent createButtonPanel() {
              JPanel panel = new JPanel(new GridLayout(0,1));
              JButton okButton = new JButton("OK");
              okButton.setActionCommand("OK");
              // okButton.addActionListener(this); // Cannot use this in static reference (1st error)
              panel.add(okButton);
              return panel;
         public void actionPerformed (ActionEvent event) {
              String message = event.getActionCommand();
              if (message.equals("Help Contents")) {
                   helpFrame = new HelpFrame(); //  cannot convert from HelpScreenPlace.HelpFrame to JInternalFrame (2nd error)
                   helpFrame.setVisible(true);
                   add(helpFrame);
         public static void main(String[] args) {
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        createAndShowGUI();
         private class CloseListener extends WindowAdapter {
              public void windowClosing (WindowEvent we) {
                   System.exit(0);
            // - Syntax error on token "class", invalid Type
         // - Syntax error on token "extends", throws expected (etc on errors)
         private static class HelpFrame() extends JInternalFrame {
              super ("Help",
                        true,          // HelpFrame is resizable
                        true,          // HelpFrame is closable
                        true,          // HelpFrame is maximixable
                        true);          // HelpFrame is iconifiable
              // Get the helpPane from the model
              helpPane = model.getHelpPane();
              helpPane.setBackground(Color.WHITE);
              // Add helpPane to JScrollPane
              JEditorPane editorPane = getHelpPane();
              JScrollPane editorScrollPane = new JScrollPane(editorPane);
              editorScrollPane.setVerticalScrollBarPolicy(
                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
              editorScrollPane.setSize(250, 500);
              // editorScrollPane.setPreferredSize(new Dimension(250, 500));
              editorScrollPane.setMinimumSize(new Dimension(10, 10));
              add(editorScrollPane);
         JEditorPane getHelpPane() {
              JEditorPane pane = new JEditorPane();
              pane.setEditable(false); // Not editable
              java.net.URL helpURL = HelpFrame.class.getResource("HelpWindow.html");
              if (helpURL != null) {
                   try {
                        System.out.println ("Getting help file " + helpURL);
                        pane.setPage(helpURL);
                   } catch (IOException e) {
                        System.out.println ("Attempted to read a bad URL: " + helpURL);
              } else {
                   System.out.println ("Couldn't find file: HelpWindow.html");
              return pane;
    }For what it's worth, this is the HelpWindow.html file:
    <html>
    <body>
    This is the help file for this project.<p>
    <p>
    <p>
    <p>
    <p>
    <p>
    <p>
    <p>
    </body>
    </html>

    JInternalFrame's are meant to live in JDesktopPanes. Of course, they dont' strickly have to, but you aren't going to get it to act properly like an internal frame without jumping thru a lot of hoops. At least try packing or setting the size of the internal frame when you add it. If your layout is a border layout, then you're probably replacing the contents of the frame. And anyway, I don't see in your code where you are actually adding the main UI to the frame in the first place.
    Of course, you can wrap your whole UI in a JDesktopPane so that the main display is a panel filling the whole desktop pane on a layer, then add the help frame in there on a higher layer.
    Or maybe just not worry about internal frames and use a JDialog or another JFrame instead.
    Edited by: bsampieri on Apr 15, 2008 10:57 AM

  • Create a popup help window with javahelp

    hi:
    As the title states, I want to create a popup help window. I know there is
    a short hand, which uses "DisplayHelpFromSource(helpset)" as an action event. Then add this event to listener. I don't use this way, since
    I need to reserve the structure below (which implements actionListener interface). Any idea?
    * When user click the "help" button, "createHelpViewer" will create
    * a user help window & popup.
    public void actionPerformed(ActionEvent e) {
            try {
                MainFrame.getReference().createHelpViewer(javaHelpFrame);
            catch (GeneralException ex) {
                ErrorHandler.errDialog(ex.getDescription(), CommonUtil
                        .getActionName(this), ex);
         * Create java help viewer
        public void createHelpViewer(JInternalFrame javaHelpFrame) throws GeneralException {
            if (javaHelpFrame != null) {
                return;
            String mainHSName = "gui/files/jhelpset.hs";
            HelpSet mainHS = null;
            // Create helpset
            try {
                ClassLoader cl = this.getClass().getClassLoader();
                URL hsURL = CommonUtil.getResourceURL(mainHSName);
                mainHS = new HelpSet(cl, hsURL);
            catch (Exception ex) {
                throw new GeneralException(
                        "Help Set " + mainHSName + " not found",
                        ex);
            // Display javahelp
            // How to display the javahelp?
        }

    Here is a sample of a pop-up window that I did...
    I created a small gallery of some of my Edge animations..
    Use the left and right arrow on your keyboard to navigate through images...
    Click on the image you want to view...
    A large window pops up and you can view the animation...
    Click on the X to close the pop up
    http://www.meschrene.puremadnessproductions.net/Samples/Gallery/Edge-Samples.html

  • How do I get at a JTable on a JInternalFrame?

    I've been working on this Multiple Document Interface application, and things have been great up to this point. The user chooses to run a "report" and then selects an entity to get the info for. I then hit the database. Each row returned from the database query goes into it's own data object, which is added to an ArrayList in my custom table model, and that ArrayList is used to generate the JTable, which is then added to a ScrollPane, which is then added to the JInternalFrame, which is then added to the JDesktop pane. Good stuff, right?
    I'm now trying to add Print functionality, and I'm at a loss. What I want to do is have the user do the standard File->Print, which will print out the JTable on the currently selected inner frame. I can get a JTable to print using JTable.print(). What I can't do is find a way to get the JTable from the selected frame.
    I can get the selected frame using desktop.getSelectedFrame(), but I'm at a loss as to what to do next. I've played around with .getComponent, but I'm not having any luck. the components returned don't seem to do me any good...for example, JViewPort?
    Am I going about this the wrong way? Have I poorly designed this? Am I missing the obvious?
    Thanks,
    -Adam

    Well, if you only have a single component on the internal frame then you can use getComponent(0). But then you need to go up the parent chain to get the actual table. You will initially get the JScrollPane, then use that to get the JViewport and then use that to get the viewport component.
    Another option is to extend the JInternalFrame class and insted using the add method to add a component you create get/setTable(...) methods. Then you can save the table as a class variable before adding it the scrollpane and adding the scrollpane to the internal frame.

  • Alarm status drawing iow: recolour JInternalFrame components

    Greetings,
    Please have a look at this picture. It's a low res snapshot of
    a few quite complicated components. Most of the functionality isn't
    visible nor relevant in the example. What you're looking at is a real time
    process of some sort. Things can go wrong in that process. In a previous
    version of my views I'd turn the background colour of some components
    red/yellow/green according to the 'alarm status' of the process. One of
    my customers suggested the idea of turning everything red/yellow/green
    inside those JInternalFrames (that's what you're looking at in the example).
    Of course one fool can ask more than a dozen of wise men can answer
    and I am not that wise, so my question is: how would one change the
    colour of all components that are part of a JInternalFrame (or any
    other container) such that the colour wouldn't be 100% opague but
    still visible by itself and still showing the information originally present
    in each individual component. iow, as if a transparent monochrome
    filter were positioned in front of that entire JContainer.
    In a naive way I like the idea; if the idea turns out to be too complicated
    to realize I'd be happy with visual alternatives also. (such as big arrows
    pointing to the JContainer where the alarm happened).
    Note that these appliations run in a 'factory' environment where people
    either hardly watch the screens or they watch them at quite a great
    distance. The changing colours should just attract their attention so they
    will walk/run/drive/ride to the screens for a second inspection.
    Any ideas are appreciated.
    kind regards,
    Jos

    Not sure I understand the question, but I keyed in on:
    as if a transparent monochrome filter were positioned in front of that entire JContainer.So maybe you could use a GlassPane:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class GlassPaneTest extends JFrame
        public GlassPaneTest()
            final JComponent glassPane = new JComponent()
                public void paintComponent(Graphics g)
                    g.setColor( getBackground() );
                    g.fillRect(0, 0, getSize().width, getSize().height);
            glassPane.setOpaque( false );
            glassPane.setBackground( new Color(240, 20, 20, 100) );
            setGlassPane( glassPane );
            glassPane.addKeyListener( new KeyAdapter()
                public void keyPressed(KeyEvent e)
                    e.consume();
            glassPane.addMouseListener( new MouseAdapter()
                public void mousePressed(MouseEvent e)
                    e.consume();
            final JButton button = new JButton( "Click Me" );
            button.setMnemonic('c');
            button.addActionListener( new ActionListener()
                public void actionPerformed(ActionEvent e)
                       glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                       glassPane.setVisible( true );
                       glassPane.requestFocus();
                       Thread thread = new Thread()
                            public void run()
                                try { this.sleep(5000); }
                                catch (InterruptedException ie) {}
                                 glassPane.setVisible( false );
                                 glassPane.setCursor(null);
                    thread.start();
            getContentPane().add(new JLabel("NORTH"), BorderLayout.NORTH );
            getContentPane().add( button );
            getContentPane().add(new JTextField(), BorderLayout.SOUTH);
        public static void main(String[] args)
            GlassPaneTest frame = new GlassPaneTest();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.setSize(300, 300);
            frame.setLocationRelativeTo( null );
            frame.setVisible(true);
    }The Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html]How to Use Glass Panes shows how you can also do a simple drawing (your arrow?) on the glass pane.

  • Error in JavaHelp

    Hello:
    I have JWS app I've been working on for a long time. I just added JavaHelp to it. I got it all working nicely on my local machine. When I went to deploy in JWS, I ran into a permission problem. JavaHelp is included as an extension, and I've set <security> to <all-permissions/> in both JNLPs, but I still get the following exception:
    Parsing failed for null
    Exception caught while parsing nulljava.security.AccessControlException: access denied (java.util.PropertyPermission user.home read)
    java.lang.NullPointerException
      at javax.help.plaf.basic.BasicFavoritesNavigatorUI.reloadData(BasicFavoritesNavigatorUI.java:297)
      at javax.help.plaf.basic.BasicFavoritesNavigatorUI.installUI(BasicFavoritesNavigatorUI.java:235)
      at javax.swing.JComponent.setUI(JComponent.java:647)
      at javax.help.JHelpNavigator.setUI(JHelpNavigator.java:257)
      at javax.help.JHelpNavigator.updateUI(JHelpNavigator.java:276)
      at javax.help.JHelpNavigator.<init>(JHelpNavigator.java:105)
      at javax.help.JHelpFavoritesNavigator.<init>(JHelpFavoritesNavigator.java:62)
         ... more omitted
    Here are my JNLP files:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+"
    codebase="http://www.mydomain.com/"
    href="mydomain.jnlp"
    version="0.14">
      <information>
        <title>My Client</title>
        <vendor>MyCompany, LLC</vendor>
        <description>MyCompany rules.</description>
        <homepage href="http://mydomain.com"/>
        <offline-allowed/>
      </information>
      <resources>
        <jar href="mydomain.jar"/>
        <j2se version="1.5+" href="http://java.sun.com/products/autodl/j2se"/>
        <extension name="Java Help" href="lib/javahelp.jnlp"/>
      </resources>
      <application-desc main-class="com.mydomain.core.Main"/>
      <security>
        <all-permissions/>
      </security>
    </jnlp>
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+"
    codebase="http://www.digibunker.com/"
    href="lib/javahelp.jnlp"
    version="2.0">
      <information>
        <title>Java Help</title>
        <vendor>Sun Microsystems</vendor>
        <description>Java Help System.</description>
        <homepage href="http://java.sun.com/javase/technologies/desktop/javahelp"/>
        <offline-allowed/>
      </information>
      <resources>
        <jar href="lib/jh.jar" download="lazy" part="JavaHelp" />
        <jar href="lib/jhall.jar" download="lazy" part="JavaHelp" />
        <jar href="lib/jhbasic.jar" download="lazy" part="JavaHelp" />
        <jar href="lib/jsearch.jar" download="lazy" part="JavaHelp" />
        <j2se version="1.5+" href="http://java.sun.com/products/autodl/j2se"/>
      </resources>
      <component-desc>
      <security>
        <all-permissions/>
      </security>
    </jnlp>
    Any and all help welcomed.
    Thanks, Dan
    Edited by: dlamet on Jan 8, 2010 5:40 PM

    AndrewThompson64
    Thanks for the quick response. I downloaded your app (very good idea BTW!) and ran it against my JNLP file. It reported a number of issues to me, but I don't understand them. I subsequently located the JNLP spec 6.0.10 here and went through it carefully. (I ended up discovering some nice features I added to my file.) I ended up with the following file, but the errors seem to be the same. The output is below the JNLP.
    Is it possible that your app is analyzing against an outdated version of the JNLP spec? It's all that I can figure. Perhaps you could explain just one or two of the node errors to get me started. Thanks again! Dan
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+"
    codebase="http://www.digibunker.com/"
    href="digibunker.jnlp"
    version="0.14">
      <information>
        <title>DigiBunker Client</title>
        <vendor>DigiBunker, LLC</vendor>
        <homepage href="http://www.digibunker.com"/>
        <description kind="tooltip">Automated media back up.</description>
        <description kind="one-line">The DigiBunker client makes protecting your media files easy.</description>
        <icon href="http://www.digibunker.com/images/icon-32.png"
    version="1.0"
    width="32"
    height="32"
    size="6243" />
        <offline-allowed/>
        <shortcut>
          <desktop />
          <menu />
        </shortcut>
      </information>
      <security>
        <all-permissions/>
      </security>
      <resources>
        <j2se version="1.5+" href="http://java.sun.com/products/autodl/j2se"/>
        <jar href="digibunker.jar" main="true" />
        <extension name="Java Help" version="2.0" href="lib/javahelp.jnlp">
          <ext-download download="lazy" />
        </extension>
      </resources>
      <application-desc main-class="com.judedavid.eros.core.Main"/>
    </jnlp>
    Content type application/xml does not equal expected type of application/x-java-jnlp-file
    cvc-complex-type.2.4.a: Invalid content was found starting with element 'homepage'. One of '{description, icon, offline-allowed, shortcut, association, related-content}' is expected.
    cvc-complex-type.2.4.a: Invalid content was found starting with element 'j2se'. One of '{jar, nativelib, extension, property, package}' is expected.
    cvc-complex-type.2.4.d: Invalid content was found starting with element 'security'. No child element is expected at this point.
    cvc-complex-type.2.4.a: Invalid content was found starting with element 'homepage'. One of '{description, icon, offline-allowed, shortcut, association, related-content}' is expected.
    cvc-complex-type.2.4.a: Invalid content was found starting with element 'j2se'. One of '{jar, nativelib, extension, property, package}' is expected.
    cvc-complex-type.2.4.d: Invalid content was found starting with element 'security'. No child element is expected at this point.
    cvc-complex-type.2.4.a: Invalid content was found starting with element 'homepage'. One of '{description, icon, offline-allowed, shortcut, association, related-content}' is expected.
    cvc-complex-type.2.4.a: Invalid content was found starting with element 'homepage'. One of '{description, icon, offline-allowed, shortcut, association, related-content}' is expected.
    cvc-complex-type.2.4.a: Invalid content was found starting with element 'j2se'. One of '{jar, nativelib, extension, property, package}' is expected.
    cvc-complex-type.2.4.a: Invalid content was found starting with element 'j2se'. One of '{jar, nativelib, extension, property, package}' is expected.
    cvc-complex-type.2.4.d: Invalid content was found starting with element 'security'. No child element is expected at this point.
    cvc-complex-type.2.4.d: Invalid content was found starting with element 'security'. No child element is expected at this point.
    XML encoding not known, but declared as utf-8
    Codebase + href 'http://www.digibunker.com/digibunker.jnlp' is not equal to actual location of 'file:/Y:/Moonlighting/JudeDavid/site/athena/public/digibunker.jnlp'.
    Downloads can be optimized by specifying a resource size for 'digibunker.jar'.
    The resource download at digibunker.jar can be optimized by removing the (default) value of download='eager'.
    The resource download at digibunker.jar can be optimized by removing the (default) value of main='false'.
    It might be possible to optimize the start-up of the app. by specifying download='lazy' for the digibunker.jar resource.
    Lazy downloads might not work as expected for digibunker.jar unless the download 'part' is specified.
    Resource type com of resource http://digibunker.com is not one of the allowable types of jar.
    Report for http://www.digibunker.com/lib/javahelp.jnlp

  • What is equivalent of JInternalFrame in JavaFX 2.0?

    what is equivalent of JInternalFrame in JavaFX 2.0?
    Actually I want to use pure javaFX 2.0 to view report created in iReport 5.0.0.
    I have used java.swing code, and now I want to use pure javaFX 2.0.
    My code in swing is as follows
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package reports;
    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.util.HashMap;
    import net.sf.jasperreports.engine.JRException;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.view.JRViewer;
    * @author TANVIR AHMED
    public class ReportsViewer extends javax.swing.JInternalFrame {
    * Creates new form MyiReportViewer
    private ReportsViewer()
    super("Report Viewer",true,true,true,true);
    initComponents();
    setBounds(10,10,600,500);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    public ReportsViewer(String fileName)
    this(fileName,null);
    public ReportsViewer(String fileName,HashMap parameter)
    this();
    try
    /* load the required JDBC driver and create the connection
    here JDBC Type Four Driver for MySQL is used*/
    //Class.forName("com.mysql.jdbc.Driver");
    Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "invoice", "item");
    //Connection con=DriverManager.getConnection("jdbc:mysql://localhost/inventory","root","karim");
    /*(Here the parameter file should be in .jasper extension
    i.e., the compiled report)*/
    JasperPrint print = JasperFillManager.fillReport(
    fileName, parameter, con);
    JRViewer viewer=new JRViewer(print);
    Container c=getContentPane();
    c.setLayout(new BorderLayout());
    c.add(viewer);
    catch(SQLException sqle)
    sqle.printStackTrace();
    catch(JRException jre)
    jre.printStackTrace();
    * This method is called from within the constructor to initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is always
    * regenerated by the Form Editor.
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 394, Short.MAX_VALUE)
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 290, Short.MAX_VALUE)
    pack();
    }// </editor-fold>
    // Variables declaration - do not modify
    // End of variables declaration
    and
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package reports;
    import java.beans.PropertyVetoException;
    * @author TANVIR AHMED
    public class MainUI extends javax.swing.JFrame {
    * Creates new form MainUI
    public MainUI() {
    super("REPORTS");
    initComponents();
    setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize());
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
    jMenuItem1 = new javax.swing.JMenuItem();
    desktopPane = new javax.swing.JDesktopPane();
    salesTaxInv = new javax.swing.JButton();
    jLabel1 = new javax.swing.JLabel();
    supplyRegister = new javax.swing.JButton();
    PartyLedger = new javax.swing.JButton();
    menuBar = new javax.swing.JMenuBar();
    jMenuItem1.setText("jMenuItem1");
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    desktopPane.setBackground(new java.awt.Color(255, 204, 0));
    desktopPane.setBorder(new javax.swing.border.MatteBorder(null));
    desktopPane.setForeground(new java.awt.Color(255, 0, 102));
    desktopPane.setAutoscrolls(true);
    desktopPane.setFont(new java.awt.Font("Bookman Old Style", 0, 14)); // NOI18N
    desktopPane.setPreferredSize(new java.awt.Dimension(1024, 768));
    salesTaxInv.setBackground(new java.awt.Color(255, 255, 255));
    salesTaxInv.setFont(new java.awt.Font("Bookman Old Style", 1, 18)); // NOI18N
    salesTaxInv.setForeground(new java.awt.Color(204, 0, 0));
    salesTaxInv.setText("Sales Tax Invoice");
    salesTaxInv.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    salesTaxInvActionPerformed(evt);
    salesTaxInv.setBounds(20, 53, 200, 31);
    desktopPane.add(salesTaxInv, javax.swing.JLayeredPane.DEFAULT_LAYER);
    jLabel1.setFont(new java.awt.Font("Bookman Old Style", 0, 24)); // NOI18N
    jLabel1.setForeground(new java.awt.Color(50, 72, 255));
    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setText("Invoice System Reports");
    jLabel1.setBounds(0, -1, 1024, 50);
    desktopPane.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);
    supplyRegister.setFont(new java.awt.Font("Bookman Old Style", 1, 18)); // NOI18N
    supplyRegister.setForeground(new java.awt.Color(204, 0, 0));
    supplyRegister.setText("Supply Register");
    supplyRegister.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    supplyRegisterActionPerformed(evt);
    supplyRegister.setBounds(20, 100, 200, 30);
    desktopPane.add(supplyRegister, javax.swing.JLayeredPane.DEFAULT_LAYER);
    PartyLedger.setFont(new java.awt.Font("Bookman Old Style", 1, 18)); // NOI18N
    PartyLedger.setForeground(new java.awt.Color(204, 0, 0));
    PartyLedger.setText("Party Ledger");
    PartyLedger.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    PartyLedgerActionPerformed(evt);
    PartyLedger.setBounds(20, 140, 200, 30);
    desktopPane.add(PartyLedger, javax.swing.JLayeredPane.DEFAULT_LAYER);
    setJMenuBar(menuBar);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(desktopPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    pack();
    }// </editor-fold>
    private void salesTaxInvActionPerformed(java.awt.event.ActionEvent evt) {                                           
    try
    ReportsViewer myiReportViewer = new ReportsViewer("reports/INV.jasper");
    myiReportViewer.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
    myiReportViewer.setVisible(true);
    desktopPane.add(myiReportViewer);
    myiReportViewer.setSelected(true);
    catch (PropertyVetoException pve)
    pve.printStackTrace();
    private void supplyRegisterActionPerformed(java.awt.event.ActionEvent evt) {                                              
    try
    ReportsViewer myiReportViewer = new ReportsViewer("reports/supplyRegister.jasper");
    myiReportViewer.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
    myiReportViewer.setVisible(true);
    desktopPane.add(myiReportViewer);
    myiReportViewer.setSelected(true);
    catch (PropertyVetoException pve)
    pve.printStackTrace();
    private void PartyLedgerActionPerformed(java.awt.event.ActionEvent evt) {                                           
    try
    ReportsViewer myiReportViewer = new ReportsViewer("reports/CustomerLedger.jasper");
    myiReportViewer.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
    myiReportViewer.setVisible(true);
    desktopPane.add(myiReportViewer);
    myiReportViewer.setSelected(true);
    catch (PropertyVetoException pve)
    pve.printStackTrace();
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new MainUI().setVisible(true);
    // Variables declaration - do not modify
    private javax.swing.JButton PartyLedger;
    private javax.swing.JDesktopPane desktopPane;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JButton salesTaxInv;
    private javax.swing.JButton supplyRegister;
    // End of variables declaration
    Best Regards

    Dear Sir,
    I am using the swing code and running the jasper report with the above code.
    Realy!
    I start the thread with this code
    @FXML
    private void mainUiButtonAction(ActionEvent event) {
    try{
    new MainUI().setVisible(true);
    catch(Exception ex){                 
    }

  • JInternalFrame drawing problem.

    Hi gurus
    Please could you help with a java problem that I cant find an answer to over the net:
    I have a JDesktop which contains multiple JInternalFrames. On one JInternalFrame i have attached a JPanel on which to draw on. I have multiple threads (simple ball shapes) that need to be drawn onto the JPanel and have left it up to the indivual threads to draw themselves (as opposed to using paintComponent in the JPanel class). The drawing on the JInternalFrame works perfectly fine.
    The problem arises when the other JInternalFrames are placed on top of each other - the balls are drawn over the top most JInternalFrame. What am i doing wrong? I have attached snippets of the code:
    public class Desktop extends JFrame implements ActionListener
              public Desktop()
                        setTitle("Agent's world");
                        setSize(w,h);
                        setDefaultCloseOperation(EXIT_ON_CLOSE);
                        JDesktopPane desktop = new JDesktopPane();
                        setContentPane(desktop);
                        /************* Agent *************/
                        JInternalFrame agents = new JInternalFrame("Agents War", true, false, true, false);                    
                        agents.reshape(0,0,(int)((w/3)*2),h);
                        Container contentPane = agents.getContentPane();
                        canvas = new AgentPanel(agents);
                        contentPane.add(canvas);
                        /************* Button *************/
                        JPanel buttonPanel = new JPanel();
                        ButtonGroup buttonGroup = new ButtonGroup();
                        JButton start = new JButton("START");
                        start.addActionListener(this);
                        buttonPanel.add(start);
                        contentPane.add(buttonPanel, "North");
                        agents.setVisible(true);
                        desktop.add(agents);
                        //sets focus to other frames within the desktop
                        try
                                  agents.setSelected(true);
                        catch(PropertyVetoException e)
                                  //attempt to refocus was vetoed by a frame
              /** Method to listen for event actions, i.e. button clicks **/
         public void actionPerformed(ActionEvent event)
                   //passes through 'this' to allow access to the getList method
                   Agents agent = new Agents(canvas, this);
                   agent.start();
    public class Agents extends Thread
              public Agents(AgentPanel panel, Desktop desktop)
                        panel =_panel;
                        desktop = _desktop;
                        setDaemon(true);
    /** Moves the agent from a spefic position to a new position **/
              public void move()
                        Graphics g = panel.getGraphics();
                        Graphics2D g2 = (Graphics2D)g;
                        try
                                  //set XOR mode
                                  g.setXORMode(panel.getBackground());
                                  //draw over old
                                  Ellipse2D.Double ballOld = new Ellipse2D.Double(i , j, length, length);
                                  g2.fill(ballOld);     
                                  i++;
                                  j++;
                                  if(flag == true)
                                            //draw new
                                            Ellipse2D.Double ballNew = new Ellipse2D.Double(i , j, length, length);
                                            g2.fill(ballNew);
                                            g2.setPaintMode();
                        finally
                                  g.dispose();
              /** Activates the Thread **/
              public void run()
                   int i = 0;
                   while(!interrupted() && i<100)
                        try
                                       for(i = 0 ; i <100 ; i++)
                                                 //draw ball in old position                                             move();          
                                                 sleep(100);                              
                             catch(InterruptedException e)
    public class AgentPanel extends JPanel
              /** local copy of internal frame */
              private JInternalFrame frame;
              public AgentPanel(JInternalFrame _frame)
                        frame = _frame;
                        setSize(frame.getWidth(), frame.getHeight());
                        setBackground(Color.white);          
              public void paintComponent(Graphics g)
                        super.paintComponent(g);
    Thank you in advance.
    Ravs

    I have the same problem. Seems to be a bug. See:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=231037
    Bummer.

  • Need to convert a JFrame to an jinternalframe

    Hello,
    I have an application that is comprised of 7 classes. I'm attempting to rewrite it so that the one class that I have which is for the JFrame is converted to an internal frame so that I can add the complete application to the desktop pane of a gui which I've created, to be a part of a bigger application. I've tried the code that converts JFrames to JInternalFrames but that doesn't seem to work, maybe I'm missing something here. I'm relatively new to the Java Programming world but I'm moving along. Any help is more than welcomed.

    Hello,
    I don't think you can directly convert a JFrame to JInternalFrame
    But panels are compatible
    (for example you can do this : yourJInternalFrame.setContent(yourJFrame.getContent);
    When i program in java, my main classes extends JPanel and not JFrame or JInternalFrame, then you can use this application into every frames or applets :)
    If you do that, set in your main:
    JFrame myJFrame = new JFrame(...);
    MyClass myClassWhichExtendsJPanel = new MYClass(...);
    yourJFrame.setContent(myClassWhichExtendsJPanel);

  • Repaint Problem in JInternalFrame!!!! help plz.

    hi,
    I have a question I have an application that has internal frames, Basically it is a MDI Application. I am using JDK 1.2.2 and windows 2000. The following example shows that when I drag my JInternalFrames only the border is shown and the contents are not shown as being dragged that's fine, but the application I am running have lot of components in my JInternalFrames. And when I drag the JInternalFrame my contents are not being dragged and that's what I want but when I let go the internalFrame it takes time to repaint all the components in the internalFrame. Is there any way I can make the repaint goes faster after I am done dragging the internalFrame. It takes lot of time to bring up the internalframe and it's components at a new location after dragging. Is there a way to speed up the repainting. The following example just shows how the outline border is shown when you drag the internalFrame. As there are not enough components in the internal frame so shows up quickly. But when there are lots of components specially gif images inside the internalframe it takes time.
    /*************** MDITest ************/
    import javax.swing.*;
    * An application that displays a frame that
    * contains internal frames in an MDI type
    * interface.
    * @author Mike Foley
    public class MDITest extends Object {
    * Application entry point.
    * Create the frame, and display it.
    * @param args Command line parameter. Not used.
    public static void main( String args[] ) {
    try {
    UIManager.setLookAndFeel(
    "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
    } catch( Exception ex ) {
    System.err.println( "Exception: " +
    ex.getLocalizedMessage() );
    JFrame frame = new MDIFrame( "MDI Test" );
    frame.pack();
    frame.setVisible( true );
    } // main
    } // MDITest
    /*********** MDIFrame.java ************/
    import java.awt.*;
    import java.awt.event.*;
    import java.io.Serializable;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    * A top-level frame. The frame configures itself
    * with a JDesktopPane in its content pane.
    * @author Mike Foley
    public class MDIFrame extends JFrame implements Serializable {
    * The desktop pane in our content pane.
    private JDesktopPane desktopPane;
    * MDIFrame, null constructor.
    public MDIFrame() {
    this( null );
    * MDIFrame, constructor.
    * @param title The title for the frame.
    public MDIFrame( String title ) {
    super( title );
    * Customize the frame for our application.
    protected void frameInit() {
    // Let the super create the panes.
    super.frameInit();
    JMenuBar menuBar = createMenu();
    setJMenuBar( menuBar );
    JToolBar toolBar = createToolBar();
    Container content = getContentPane();
    content.add( toolBar, BorderLayout.NORTH );
    desktopPane = new JDesktopPane();
    desktopPane.putClientProperty("JDesktopPane.dragMode", "outline");
    desktopPane.setPreferredSize( new Dimension( 400, 300 ) );
    content.add( desktopPane, BorderLayout.CENTER );
    } // frameInit
    * Create the menu for the frame.
    * <p>
    * @return The menu for the frame.
    protected JMenuBar createMenu() {
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu( "File" );
    file.setMnemonic( KeyEvent.VK_F );
    JMenuItem item;
    file.add( new NewInternalFrameAction() );
    // file.add( new ExitAction() );
    menuBar.add( file );
    return( menuBar );
    } // createMenuBar
    * Create the toolbar for this frame.
    * <p>
    * @return The newly created toolbar.
    protected JToolBar createToolBar() {
    final JToolBar toolBar = new JToolBar();
    toolBar.setFloatable( false );
    toolBar.add( new NewInternalFrameAction() );
    // toolBar.add( new ExitAction() );
    return( toolBar );
    * Create an internal frame.
    * A JLabel is added to its content pane for an example
    * of content in the internal frame. However, any
    * JComponent may be used for content.
    * <p>
    * @return The newly created internal frame.
    public JInternalFrame createInternalFrame() {
    JInternalFrame internalFrame =
    new JInternalFrame( "Internal JLabel" );
    internalFrame.getContentPane().add(
    new JLabel( "Internal Frame Content" ) );
    internalFrame.setResizable( true );
    internalFrame.setClosable( true );
    internalFrame.setIconifiable( true );
    internalFrame.setMaximizable( true );
    internalFrame.pack();
    return( internalFrame );
    * An Action that creates a new internal frame and
    * adds it to this frame's desktop pane.
    public class NewInternalFrameAction extends AbstractAction {
    * NewInternalFrameAction, constructor.
    * Set the name and icon for this action.
    public NewInternalFrameAction() {
    super( "New", new ImageIcon( "new.gif" ) );
    * Perform the action, create an internal frame and
    * add it to the desktop pane.
    * <p>
    * @param e The event causing us to be called.
    public void actionPerformed( ActionEvent e ) {
    JInternalFrame internalFrame = createInternalFrame();
    desktopPane.add( internalFrame,
    JLayeredPane.DEFAULT_LAYER );
    } // NewInternalFrameAction
    } // MDIFrame
    I'll really appreciate for any help.
    Thank you

    Hi
    if you fill the ranges
    r_rundate-sign = 'I'.
    r_rundate-option = 'EQ'.
    r_rundate-low = '20080613'.
    r_rundate-high = '20080613'.
    APPEND r_rundate.
    EQ = 'equal', the select check the record with data EQ r_rundate-low.
    change EQ with BT  
    BT = between
    r_rundate-sign = 'I'.
    r_rundate-option = 'BT'.
    r_rundate-low = '20080613'.
    r_rundate-high = '20080613'.
    APPEND r_rundate.
    reward if useful, bye

  • Problems getting data from JMenuBar to JInternalFrame

    I have modified an example to show my problem. I am trying to take text input from the menu bar and print it into a JTextArea. I don't know how to reference the data in my ActionListener.
    The ActionListener is incomplete, but this is basically what I am trying to do:
    import javax.swing.JInternalFrame;
    import javax.swing.JDesktopPane;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JMenuBar;
    import javax.swing.JFrame;
    import javax.swing.KeyStroke;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    * InternalFrameDemo.java is a 1.4 application that requires:
    *   MyInternalFrame.java
    public class InternalFrameDemo extends JFrame
                                   implements ActionListener {
        JDesktopPane desktop;
        JTextField memAddrBox;
        JTextArea menuText;
        JTextArea frame;
        String textFieldString = " Input Text: ";
        ActionListener al;
        public InternalFrameDemo() {
            super("InternalFrameDemo");
            //Make the big window be indented 50 pixels from each edge
            //of the screen.
            int inset = 50;
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds(inset, inset,
                      screenSize.width  - inset*2,
                      screenSize.height - inset*2);
            //Set up the GUI.
            desktop = new JDesktopPane(); //a specialized layered pane
            frame = createFrame(); //create first "window"
            setContentPane(desktop);
            setJMenuBar(createMenuBar());
            //Make dragging a little faster but perhaps uglier.
            desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        protected JMenuBar createMenuBar() {
            JMenuBar menuBar = new JMenuBar();
            JLabel memAddrLabel = new JLabel(textFieldString);
            memAddrLabel.setLabelFor(memAddrBox);
            menuBar.add(memAddrLabel);
            JTextField memAddrBox = new JTextField();
            memAddrBox.addActionListener(this);
            memAddrBox.setActionCommand("chMemAddr");
            menuBar.add(memAddrBox);
            return menuBar;
        //React to menu selections.
        public void actionPerformed(ActionEvent e) {
            if ("chMemAddr".equals(e.getActionCommand())) 
                JMenuBar bar = getJMenuBar();
    //            JTextField memAddrBox = bar.getParent();
                String memStartString = memAddrBox.getText();
                update(memStartString);
        public void update(String temp)
            frame.setText(temp);
        //Create a new internal frame.
        protected JTextArea createFrame() {
            JInternalFrame frame = new JInternalFrame("Memory",true,true,true,true);      
            frame.setSize(650, 500);
            frame.setVisible(true);
            frame.setLocation(200, 0);
            desktop.add(frame);  
            JTextArea textArea = new JTextArea();
            frame.getContentPane().add("Center", textArea);
            textArea.setFont(new Font("SansSerif", Font.PLAIN, 12));
            textArea.setVisible(true);
            textArea.setText("Initial Text");
            return textArea;
        //Quit the application.
        protected void quit() {
            System.exit(0);
        public static void main(String[] args) {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            InternalFrameDemo frame = new InternalFrameDemo();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Display the window.
            frame.setVisible(true);
    class MyInternalFrame extends JInternalFrame {
        static int openFrameCount = 0;
        static final int xOffset = 30, yOffset = 30;
        public MyInternalFrame() {
            super("Document #" + (++openFrameCount),
                  true, //resizable
                  true, //closable
                  true, //maximizable
                  true);//iconifiable
            //...Create the GUI and put it in the window...
            //...Then set the window size or call pack...
            setSize(300,300);
            //Set the window's location.
            setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
    }I want to take the input from the "memAddrBox" and put it into the "frame" using the update() method. Probably a simple solution, but I have not found a similar problem in the Forums.

    I knew it had to be something simple, here is the fix I found:
    import javax.swing.JInternalFrame;
    import javax.swing.JDesktopPane;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JMenuBar;
    import javax.swing.JFrame;
    import javax.swing.KeyStroke;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    * InternalFrameDemo.java is a 1.4 application that requires:
    *   MyInternalFrame.java
    public class InternalFrameDemo extends JFrame
                                   implements ActionListener {
        JDesktopPane desktop;
        JTextField memAddrBox;
        JTextArea menuText;
        JTextArea frame;
        String textFieldString = " Input Text: ";
        ActionListener al;
        public InternalFrameDemo() {
            super("InternalFrameDemo");
            //Make the big window be indented 50 pixels from each edge
            //of the screen.
            int inset = 50;
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds(inset, inset,
                      screenSize.width  - inset*2,
                      screenSize.height - inset*2);
            //Set up the GUI.
            desktop = new JDesktopPane(); //a specialized layered pane
            frame = createFrame(); //create first "window"
            setContentPane(desktop);
            setJMenuBar(createMenuBar());
            //Make dragging a little faster but perhaps uglier.
            desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        protected JMenuBar createMenuBar() {
            JMenuBar menuBar = new JMenuBar();
            JLabel memAddrLabel = new JLabel(textFieldString);
            memAddrLabel.setLabelFor(memAddrBox);
            menuBar.add(memAddrLabel);
            JTextField memAddrBox = new JTextField();
            memAddrBox.addActionListener(this);
            memAddrBox.setActionCommand("chMemAddr");
            menuBar.add(memAddrBox);
            return menuBar;
        //React to menu selections.
        public void actionPerformed(ActionEvent e) {
            if ("chMemAddr".equals(e.getActionCommand())) 
               JTextField textField =
                 (JTextField)e.getSource();
                String memStartString = textField.getText();
                update(memStartString);
        public void update(String temp)
            frame.setText(temp);
        //Create a new internal frame.
        protected JTextArea createFrame() {
            JInternalFrame frame = new JInternalFrame("Memory",true,true,true,true);      
            frame.setSize(650, 500);
            frame.setVisible(true);
            frame.setLocation(200, 0);
            desktop.add(frame);  
            JTextArea textArea = new JTextArea();
            frame.getContentPane().add("Center", textArea);
            textArea.setFont(new Font("SansSerif", Font.PLAIN, 12));
            textArea.setVisible(true);
            textArea.setText("Initial Text");
            return textArea;
        //Quit the application.
        protected void quit() {
            System.exit(0);
        public static void main(String[] args) {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            InternalFrameDemo frame = new InternalFrameDemo();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Display the window.
            frame.setVisible(true);
    class MyInternalFrame extends JInternalFrame {
        static int openFrameCount = 0;
        static final int xOffset = 30, yOffset = 30;
        public MyInternalFrame() {
            super("Document #" + (++openFrameCount),
                  true, //resizable
                  true, //closable
                  true, //maximizable
                  true);//iconifiable
            //...Create the GUI and put it in the window...
            //...Then set the window size or call pack...
            setSize(300,300);
            //Set the window's location.
            setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
    }Note the e.getSource() change in the ActionListener.

  • Opening a Second JInternalFrame

    Below I have two classes InternalFrameDemo instantiates MyInternalFrame (extends javax.swing.JInternalFrame ) in doing this the application creates a JDesktopPane and creates a MyInternalFrame to put in it.
    What I want to happen is when the jButton1 on the MyInternalFrame is clicked is for a second MyInternalFrame to open and the first MyInternalFrame to close is this possible?
    I think that I would need to have the action Method in MyInternalFrame trigger a method call in the InternalFrameDemo and do the closing and opening of new MyInternalFrame from there?
    Thanks
    package components;
    import javax.swing.JInternalFrame;
    import javax.swing.JDesktopPane;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JMenuBar;
    import javax.swing.JFrame;
    import javax.swing.KeyStroke;
    import java.awt.event.*;
    import java.awt.*;
    public class InternalFrameDemo extends JFrame
    implements ActionListener {
    JDesktopPane desktop;
    public InternalFrameDemo() {
    super("InternalFrameDemo");
    int inset = 50;
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setBounds(inset, inset,
    screenSize.width - inset*2,
    screenSize.height - inset*2);
    desktop = new JDesktopPane();
    createFrame();
    setContentPane(desktop);
    setJMenuBar(createMenuBar());
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    protected JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("Document");
    menu.setMnemonic(KeyEvent.VK_D);
    menuBar.add(menu);
    JMenuItem menuItem = new JMenuItem("New");
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(
    KeyEvent.VK_N, ActionEvent.ALT_MASK));
    menuItem.setActionCommand("new");
    menuItem.addActionListener(this);
    menu.add(menuItem);
    return menuBar;
    public void actionPerformed(ActionEvent e) {
    if ("new".equals(e.getActionCommand())) {
    createFrame();
    } else {
    quit();
    protected void createFrame() {
    MyInternalFrame frame = new MyInternalFrame();
    frame.setVisible(true);
    desktop.add(frame);
    try {
    frame.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {}
    MyInternalFrame frame2 = new MyInternalFrame();
    frame.setVisible(true);
    desktop.add(frame2);
    try {
    frame2.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {}
    public void closeWin(){
    protected void quit() {
    System.exit(0);
    private static void createAndShowGUI() {
    JFrame.setDefaultLookAndFeelDecorated(true);
    InternalFrameDemo frame = new InternalFrameDemo();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    public static void main(String[] args) {     
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    /*MyInternalFrame */
    package components;
    public class MyInternalFrame extends javax.swing.JInternalFrame {
    @SuppressWarnings("unchecked")
    private void initComponents() {
    jButton1 = new javax.swing.JButton();
    jButton1.setText("jButton1");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jButton1ActionPerformed(evt);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(152, 152, 152)
    .addComponent(jButton1)
    .addContainerGap(169, Short.MAX_VALUE))
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(108, 108, 108)
    .addComponent(jButton1)
    .addContainerGap(147, Short.MAX_VALUE))
    pack();
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    this.dispose();
    private javax.swing.JButton jButton1;
    }

    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
    I think that I would need to have the action Method in MyInternalFrame trigger a method call in the InternalFrameDemo and do the closing and opening of new MyInternalFrame from there?Correct. So give it a try and see what happens.

  • JInternalFrame problem

    Hello,
    I've got a JFrame class like this :
    public class FrameTest extends JFrame
    public JFrameTest()
    JDesktopPane desktop = new JDesktopPane();
    this.setContentPane(desktop);
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    Test panelTest = new Test();
    Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());
    contentPane.add(panelTest , panelTest .gridBagConstraints);
    At this point, I've got no problem. My frame is visible and my panel is inside.
    On the listener of a button of my panel, I want to open an JInternalFrame.
    My JInternal class is like this :
    public class JInternalFrameTest extends JInternalFrame
    public JInternalFrameTest(String title)
    super(title, true, true, true);
    this.pack();
    this.setVisible(true);
    The code of the listener is like this :
    JInternalFrameTest internalFrameTest = new JInternalFrameTest("TITLE");
    frameTest.getContentPane().add(internalFrameTest ); //frameTest is a reference on the main frame (instance of JFrameTest)
    At the execution of my application, when the listener starts, the JInternalFrameTest is created but near the panel not on the top. Moreover, I can't specify the position and the size of my JInternalFrameTest object because when I specify them in the JInternalFrameTest class, nothing happen.
    If you have a solution for me because I don't understand what I have forgotten.
    Thanks.

    michal1101 wrote:
    As I understand, in mvc - if the view is not updated , so it's a bug.What are you trying to say here? There are two options: there is a bug in Java that millions of people have missed, and you've somehow found OR you're misunderstanding something. Which do you think is more likely?
    Does anyone had that kind of mvc problem?No. Either something in your code is wrong, or you're misunderstanding something pretty basic.
    Ps. It's difficult to send an example, since i can't send the code from work.Then you understand that it's difficult to help you, right? Without seeing code, we can't tell you what's wrong with your code. You were asked for an SSCCE, which shouldn't contain any extra "company-sensitive" code. It's your call, but claiming that your problems must be a "bug" and refusing to post any code won't get you very far.

  • Problem with JInternalFrame

    Hii there,
    I'm having a problem with JInternalFrame, that is, when I'm trying to open multiple frames, it is overlapping one another and sometimes one of them disappears, I did something like this,
    dpane=new JDesktopPane();                                                 
                            dpane.setDesktopManager(new DefaultDesktopManager());
                            dpane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
                            iframe=new JInternalFrame("Title" ,true,true,true,true);  
                            //iframe.setPreferredSize(new Dimension(1010,800));
                            iframe.setResizable(false);
                            vScrollPane = new JScrollPane(viewPanel,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);                       
                            iframe.setPreferredSize(new Dimension(1010,800));
                            iframe.setLocation(0,1);
                            iframe.setVisible(true);
                            iframe.show();
                            iframe.getContentPane().add(vScrollPane,BorderLayout.EAST);                      
                            iframe.getContentPane().add(hScrollBar,BorderLayout.SOUTH);
                            iframe.moveToFront();
                            iframe.setFocusable(true);
                            iframe.pack();
                            dpane.add(iframe);                                      
                            getContentPane().add(dpane);could u someone plz help me !
    Dev

    [How to Use Internal Frames|http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html]

  • Undecorated JInternalFrame becomes decorated by itself.

    Hi,
    I’m facing a problem with JInternalFrame implementation. I have made the JInternalFrame undecorated, so that the title bar and border of the JInternalFrame gets removed. The problem occurs in the following scenario.
    *1)     Execute the program in a Windows 7 machine.*
    *•     At this point the JInternalFrame remains undecorated.*
    *2)     Access the Windows 7 machine using remote desktop sharing from another machine.*
    *•     Now the title bar and border of the internal frame becomes visible.*
    This issue occurs only in Windows 7 machine, and not in Windows XP. You can access the Windows 7 machine using remote desktop sharing from another Windows 7 machine or Windows XP machine.
    Also if you access the machine using remote desktop sharing first, and then execute the program, the JInternalFrame remains undecorated.
    Steps to reproduce
    Step 1: Execute the application in a Windows 7 machine.
    Step 2: Access the Windows 7 machine using remote desktop sharing from another Windows 7 or Windows XP machine.
    Step 3: Check the GUI of the application
    Result :- The title bar and border of the undecorated JInternalFrame becomes visible.
    If anyone has faced this issue or if anyone has a solution for this issue, kindly share your thoughts.
    A sample code using which you can reproduce this issue is given below.
    * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    * - Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    * - Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    * - Neither the name of Oracle or the names of its
    * contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
    * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    import javax.swing.JInternalFrame;
    import javax.swing.JDesktopPane;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JMenuBar;
    import javax.swing.JFrame;
    import javax.swing.KeyStroke;
    import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
    import javax.swing.plaf.basic.BasicInternalFrameUI;
    import java.awt.event.*;
    import java.awt.*;
    * InternalFrameDemo.java requires:
    * MyInternalFrame.java
    public class InternalFrameDemo extends JFrame
    implements ActionListener {
    JDesktopPane desktop;
    public InternalFrameDemo() {
    super("InternalFrameDemo");
    //Make the big window be indented 50 pixels from each edge
    //of the screen.
    int inset = 50;
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setBounds(inset, inset,
    screenSize.width - inset*2,
    screenSize.height - inset*2);
    //Set up the GUI.
    desktop = new JDesktopPane(); //a specialized layered pane
    createFrame(); //create first "window"
    setContentPane(desktop);
    setJMenuBar(createMenuBar());
    //Make dragging a little faster but perhaps uglier.
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    protected JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    //Set up the lone menu.
    JMenu menu = new JMenu("Document");
    menu.setMnemonic(KeyEvent.VK_D);
    menuBar.add(menu);
    //Set up the first menu item.
    JMenuItem menuItem = new JMenuItem("New");
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(
    KeyEvent.VK_N, ActionEvent.ALT_MASK));
    menuItem.setActionCommand("new");
    menuItem.addActionListener(this);
    menu.add(menuItem);
    //Set up the second menu item.
    menuItem = new JMenuItem("Quit");
    menuItem.setMnemonic(KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(
    KeyEvent.VK_Q, ActionEvent.ALT_MASK));
    menuItem.setActionCommand("quit");
    menuItem.addActionListener(this);
    menu.add(menuItem);
    return menuBar;
    //React to menu selections.
    public void actionPerformed(ActionEvent e) {
    if ("new".equals(e.getActionCommand())) { //new
    createFrame();
    } else { //quit
    quit();
    //Create a new internal frame.
    protected void createFrame() {
    MyInternalFrame frame = new MyInternalFrame();
    frame.setVisible(true); //necessary as of 1.3
    desktop.add(frame);
    try {
    frame.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {}
    //Quit the application.
    protected void quit() {
    System.exit(0);
    * Create the GUI and show it. For thread safety,
    * this method should be invoked from the
    * event-dispatching thread.
    private static void createAndShowGUI() {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    InternalFrameDemo frame = new InternalFrameDemo();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Display the window.
    frame.setVisible(true);
    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    /* Used by InternalFrameDemo.java. */
    @SuppressWarnings("serial")
    class MyInternalFrame extends JInternalFrame {
    static int openFrameCount = 0;
    static final int xOffset = 30, yOffset = 30;
    public MyInternalFrame() {
    super("Document #" + (++openFrameCount),
    true, //resizable
    true, //closable
    true, //maximizable
    true);//iconifiable
    //...Create the GUI and put it in the window...
    //...Then set the window size or call pack...
    setSize(300,300);
    // Undecorating the internal frame
    BasicInternalFrameTitlePane titlePane =
    (BasicInternalFrameTitlePane) ((BasicInternalFrameUI) this.getUI()).
    getNorthPane();
    this.remove(titlePane);
    this.setBorder(null);
    //Set the window's location.
    setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
    }

    Thanks a lot for that lead Walter.
    Actually when I tried to override updateUI(), I got a NullPoinerException. Instead of that, I tried overriding the paintComponent() method, did the undecoration part in that method and, and called super.paintComponent(g) inside the method. Then the issue was resolved.
    Once again, thanks for the quick reply.

Maybe you are looking for

  • My plugin is not working when "out-of-process plugins" ("OOPP") is enabled

    Plugin is working fine with FF3.0 but it is not working with FF4.0 and above. The reason I found out is in about:config dom.ipc.enabled is set to true. This means it whitelists the plugins to run in a plugin container. When I disabled the dom.ipc.plu

  • Can not commit distributed transaction

    Hi We get error "can not commit distributed transaction" during commit the transaction in which we have create NEW entities. Update-transactions on existing enitites work correct. Our problem is probably due to seauences for object IDs: we are using

  • Elegant technique for cutting a music video

    Hi, I am editing a music video and need to make color and contrast adjustments to the clips. The video was shot in a few locations and each location requires different color correction, etc. For example, there are clips from an office under fluoresce

  • No audio with Quicktime 7.6

    The audio portion of Quicktime Player does not work at all. This problem began when I upgraded to Quicktime 7.6. Any help out there?

  • Keyboard's backspace keeps deleting text...

    I'm having this weird problem with my keyboard. When I'm typing in some text or a URL and make a mistake, I press the backspace key once. But for some reason, by pressing it once it continues to erase the text I typed. It doesn't allow me to type in