How to renable a closed Internal frame?

Hi Friends,
I got few intenal frames which can be closed at any point. I dont loose the Jinternalframe Object though. Can I again show the internal frame even if some closes the the internal frame window. Please let me know how ? I will be glad.
Regards,
Ravi.

rather than actually closing the JInternalFrames, use setVisible(false) on a frame to hide it from the user. If you want to bring the window back simply call setVisible(true) on the frame you want to reinstate. You can override the default window closing behaviour to do this fairly easily.

Similar Messages

  • Internal frame dragging perfermance problem in JDK1.4.1

    Hi there,
    When using internal frame with outline(not faster or LIVE_DRAG_MODE) property with JDK 1.4.1_01 (windows), the speed of internal frame dragging is terrible(very very slow).
    The same code runs fine with JDK1.3.X, and it's performance(dragging speed) is acceptable(not very good, so so) when using JDK 1.4.0_X.
    I've tried both motheds to set the property as follow, and got the same result:
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    desktop.putClientProperty("JDesktopPane.dragMode", "outline");
    But, after I commented the line: g.setXORMode(Color.white); //line Num: 279
    in the class javax.swing.DefaultDesktopManager.java, the speed of dragging is very well(as same as when running with JDK1.3.X).
    My qestions are:
    - How can I improve the internal frame dragging performance in JDK 1.4.1_01(windows)?
    - Does my testing mean to a bug in the implementation of the abstract method Graphics.setXORMode() in the JDK 1.4.1_01 windows version ?
    TIA
    In terms of the test case, we may just use the follows:
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/InternalFrameDemo.java
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/MyInternalFrame.java

    Anyone know if this is registered as a bug? I couldn't find it.

  • How do I only allow 1 internal frame to be added?

    Could you pls show me how can I do this, I need some code to learn how this code work.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class Test1a extends JFrame
         private JLabel label1;
    //     private JLabel label2;
         private JLabel label3;
         private JLabel label4;
         private JLabel label5;
         private JDesktopPane theDesktop;
         public Test1a()
              super("TESTING JLABEL");
              setLayout(new BorderLayout(5, 5));
            JMenuBar bar = new JMenuBar();
          JMenu addMenu = new JMenu( "Add" );
          JMenuItem newFrame = new JMenuItem( "Internal Frame" );
          addMenu.add( newFrame );
          bar.add( addMenu );
          setJMenuBar( bar );
           theDesktop = new JDesktopPane();
          add( theDesktop, BorderLayout.CENTER );
          newFrame.addActionListener(
             new ActionListener()
                // display new internal window
                public void actionPerformed( ActionEvent event )
                   // create internal frame
                   JInternalFrame frame = new JInternalFrame("Internal Frame", true, true, true, true);
                   MyJPanel panel = new MyJPanel();
                   frame.add( panel, BorderLayout.CENTER );
                   frame.pack(); // set internal frame to size of contents
                   theDesktop.add( frame );
                   frame.setVisible( true );
              label1= new JLabel ();
              label1.setText("Label 1");
              add(label1, BorderLayout.WEST);
         //     label2= new JLabel ("Label 2", SwingConstants.CENTER);
         //   add(label2, BorderLayout.CENTER);
              label3= new JLabel ();
              label3.setText("Label 3");
              add(label3, BorderLayout.EAST);
              label4= new JLabel ("Label 4", SwingConstants.CENTER);
              add(label4, BorderLayout.NORTH);
              label5= new JLabel ("Label 5", SwingConstants.CENTER);
              add(label5, BorderLayout.SOUTH);
    =============================================
    import java.awt.*;
    import javax.swing.*;
    // class to display an ImageIcon on a panel
    class MyJPanel extends JPanel
       private ImageIcon imageIcon;
       // load image
       public MyJPanel()
          imageIcon = new ImageIcon("yellowflowers.png");
       // display imageIcon on panel
       public void paintComponent( Graphics g )
          super.paintComponent( g );
          imageIcon.paintIcon( this, g, 0, 0 );
       public Dimension getPreferredSize()
          return new Dimension( imageIcon.getIconWidth(), imageIcon.getIconHeight() ); 
    ========================================
    import javax.swing.*;
    public class Test1b
         public static void main (String args[])
              Test1a test1a = new Test1a();
              test1a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              test1a.setSize(800, 600);
              test1a.setVisible(true);
    }

    You where given an answer in your original posting:
    http://forum.java.sun.com/thread.jspa?threadID=5146301

  • How to keep a image lways on top of internal frames?

    Hello.
    I have a main frame with sevral internal frames. I need to put a image on this
    window that can move this image remotely.
    How to keep this image always on top of these internal frames?
    Is there any panel that can put on top of these internal frame?
    Many thanks.

    Thanks for you reply and sorry for my break English.
    I mean I need a image that moving on a frame which has internal Frames.
    When the image meet a internal frame while it's moving, this image will go under of the internal frame , so that we can not see the image any more.
    What i want to do is that let the image always keep on top of the window,
    even if it meet a internal frame.
    Just imagine the windows cursor. A cursor is always visible no matter where is it.

  • How to display internal frame on click event from another internal frame

    hi me developing desktop application in netbean. i have some problem. plz reply me as soon as possible. feedback me on [email protected]
    1. I want to invoke an Internal Frame by click event that is in another internal frame. how i do it. I tried my best
    2. how can i call reports (ireports) from swing application

    Read the JInternalFrame API. You will find a link to the Swing tutorial on "How to Use Internal Frames" which contains a working example.

  • How to realize the internal frame as in Swing?

    How to realize the internal frame as in Swing? JavaFX has the similar function?

    For system tray in JavaFX 2.2, you need to use AWT, see =>
    Re: How to call Stage’s show/hide methods from AWT-thread
    http://docs.oracle.com/javase/tutorial/uiswing/misc/systemtray.html
    awt - JavaFX app in System Tray - Stack Overflow

  • How to get Internal frames as well as a background image in a JFrame?

    Hi All,
    Here's my problem. I have a JFrame with a background image that I got by overridding the paintComponent() method of a JPanel and setting as the contentPane of a JFrame. Works great.
    Now what I want is to use internal frames with this Frame a la JInternalFrame classes. But you need to create a JDesktopPane object and set this as the contentPane of the JFrame to get internal frames to work, right? Is there a way for me to have my cake and eat it so I get both internal frames and a background image? Thanks!

    Hmmm,
    so simple, why didn't I think of that? Damn Mondays!
    thanks very much!

  • How can I use internal frames with buttons to call others internal frames?

    Hello.
    I'm building a MDI-application using JFrames and several JInternalFrames, but I have problems.
    A JFrame has JMenuBar with JMenu and JMenuItem. One of these, call the first JInternal that has its interface. In this interface has a button that call other type (a class extension of JInternalFrame) JInternalFrame.
    When I clicked button happen a exception (java.lang.NullPointer).
    What happening?
    Help me, please.

    What i usually do is to give my desktop to my internal frames. So within the internalframe, you can use your desktop and add other internal frames to it.
    The code should look something like the following.
    desktop = your JDesktopPane
    MyInternalFrame = an InternalFrame
    AnotherMyInternalFrame = another InternalFrame
    public class MyInternalFrame extends JInternalFrame implements ActionListener
      private JButton jb = new JButton("Launch");
      private JLayeredPane desktop = null;
      public MyInternalFrame(JLayeredPane desktop)
        this.desktop = desktop;
        getContentPane().add(jb);
        jb.addActionListener(this);
      public void actionPerformed(ActionEvent ae)
        if (ae.getSource() == jb)
          desktop.add(new AnotherMyInternalFrame(desktop),JLayeredPane.DEFAULT_LAYER);
    }

  • How to make Internal Frame on Focus

    Hi All,
    i have an application where in i have a JInternalFrame within in A JFrame.
    Queries:
    1.I want to make JInternalFrame focused,(without clicking on any portoion of Internal Frame) once i run the apllication(java Demo)
    2.i want to fix the JInternal Frame.(Non movable)
    //Demo.java
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;     
    import javax.swing.event.*;     
    import javax.swing.border.*;          
    public class Demo extends JFrame implements ActionListener {
    static JDesktopPane desk;
    String labelstr="Test ";
    JPanel contentpane;
    JLabel titlelabel;
    public Demo() {
              setTitle("Swing Test");
                    contentpane=(JPanel)getContentPane();
                    contentpane.setLayout(new BorderLayout());
                    desk=new JDesktopPane();     
                    desk.setBackground(Color.gray);
                    contentpane.add("Center",desk);
                    titlelabel=new JLabel(labelstr);
                    titlelabel.setForeground(Color.black);
                    titlelabel.setBorder(new BevelBorder(BevelBorder.LOWERED));
                    getContentPane().add(titlelabel,BorderLayout.SOUTH);            
              public void actionPerformed(ActionEvent e) {
                 public static void main(String args[]) {     
                    try  {
                      UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
                      //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                     }catch(Exception e) {
                                               System.out.println("Error loading L&F:"+e);     
                                               JOptionPane.showMessageDialog(null,e);
                    JFrame frame=new Demo();
                    frame.setSize(800,600);
                    frame.setVisible(true);
                      InternalFr jif=new InternalFr();
                      jif.start();
                    frame.addWindowListener(new CloseWindow());
           class CloseWindow extends WindowAdapter {
             public void windowClosing(WindowEvent we) {
                 Window w=we.getWindow();
                 w.dispose();
                 System.exit(0);
          }//InternalFr.java
    import java.io.*;
         import java.net.*;
         import java.lang.*;
         import java.awt.*;
         import java.awt.event.*;
         import javax.swing.*;
         import javax.swing.border.*;
         import javax.swing.text.*;
         public class InternalFr extends JInternalFrame {
             JLabel jlName, jlPass;
             static JTextField jtName,jtPass;
                 JButton submit,cancel;
            public InternalFr() {  
              super( "InternalFr");
              Icon img=new ImageIcon("Neticon.gif");
              setFrameIcon(img);
              JPanel contentpane=(JPanel)getContentPane();
               contentpane.setLayout(null);
              JPanel mainpanel=new JPanel();
              mainpanel.setLayout(null);
              mainpanel.setBounds(0,0,290,180);
              jlName=new JLabel("Username   :");
              jlName.setBounds(20,20,180,20);
              jlName.setForeground(Color.black);
              jtName=new JTextField();
              jtName.setBounds(150,20,100,20);
              mainpanel.add(jtName);
              mainpanel.add(jlName);
              jlPass=new JLabel("Password   :");
              jlPass.setBounds(20,50,180,20);
              jlPass.setForeground(Color.black);
              jtPass=new JTextField();
              jtPass.setBounds(150,50,100,20);
              mainpanel.add(jlPass);
              mainpanel.add(jtPass);
              JPanel buttonpanel=new JPanel();
              buttonpanel.setLayout(null);
              buttonpanel.setBounds(30,90,215,30);
              buttonpanel.setBorder(new EtchedBorder(EtchedBorder.RAISED));
              submit=new JButton("Submit");
              submit.setMnemonic('O');
              submit.setBounds(5,5,100,20);
              buttonpanel.add(submit);
              submit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                 if(ae.getSource()==submit)  {
            cancel=new JButton("Cancel");
              cancel.setMnemonic('C');
              cancel.setBounds(110,5,100,20);
              buttonpanel.add(cancel);
              cancel.addActionListener(new ActionListener() {
                 public void actionPerformed(ActionEvent ae) {
                      Object obj=ae.getSource();
                     if(obj==cancel){
                          System.exit(0);
           contentpane.add(buttonpanel);
           contentpane.add(mainpanel);
        public void start()  {
             InternalFr at=new InternalFr();
             at.setSize(290,180);
            at.setLocation(220,150);
            at.setVisible(true);
            Demo.desk.add(at);
      }Thanks
    Mohan

    To give focus to an internal frame, do the following (where iFrame is your internal frame):try {
        iFrame.setIcon( false );  // In case it is minimized
        iFrame.moveToFront();     // Make sure it is in front
        iFrame.requestFocus();    // Ask for focus
        iFrame.setSelected( true );  // Select it
    } catch( java.beans.PropertyVetoException pve ) {
    }

  • Always On Top Internal Frames

    Dear Friends,
    How we set Always on Top option for Internal Frames.
    Or User can't Do anything without closing that dialog(frame).
    Thankx.

    no, an internal frame can not be on top of anything that doesn't exist inside that frame.
    Maybe they can be forced on top of other content of the same frame, but that's as far as it goes.

  • Checking status of an internal frame

    I am writting an application that uses seperate class file for internal frames. I want to use a Menu Bar that will open the internal frame if it is closed or bring it to the foreground if it is open but behind another internal frame or restore the internal frame if it is minimized.
    I can create the internal frame easy enough with the following (this is the code that I call when the Menu Item is clicked:
    // Create a "SETUP" internal frame
    MyinternalFrame if_Setup = new MyinternalFrame("SETUP");
    // Add it to the desktop
    myDesktop.add(if_Setup);How to I check the condition of my internal frame, if_Setup?

    there are many programmes available in globalleafs.com 's download. they helped me alot. try it.

  • Internal Frames problem

    Hi,
    I am writing a piece of code where I want to able to choose from a menu a screen that displays multiple graphs (using Internal frames.) I am using cardlayout to bring up the various options I choose from the menu. I have simplified my program as much as possible but I still seem to be getting the same error
    Exception in thread "main" java.lang.IllegalArgumentException: adding a window to a container .......
    I know I shouldn't be adding a window to a container but I can't see how I can change my code so it has the functionality I desire.
    Here is the code I am using
    import java.awt.*;
    import javax.swing.*;
    public class Test extends JFrame
         public Test()
             JPanel card1 = new JPanel();
             card1.add(new InternalFrameDemo());
              getContentPane().add(card1);
        public static void main(String[] args)
              Test frame = new Test();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.setSize(200, 200);
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class InternalFrameDemo extends JFrame
        JDesktopPane desktop;
        static final int xOffset = 30, yOffset = 30;
        private JLabel graph1;
        private String Graph1;
        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);
            //Make dragging a little faster but perhaps uglier.
            desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        //Create a new internal frame.
        protected void createFrame() {
            MyInternalFrame frame = new MyInternalFrame();
            frame.setVisible(true);
            desktop.add(frame);
            try {
                frame.setSelected(true);
            } catch (java.beans.PropertyVetoException e) {}
        //Quit the application.
        protected void quit() {
            System.exit(0);
       public void MyInternalFrame() {
         System.out.println("graph1");
         graph1 = new JLabel("", 
                       new ImageIcon("../images/Graph1.jpg"),
                       JLabel.CENTER);
         getContentPane().add(graph1);
         //...Then set the window size or call pack...
         setSize(500,550);
    }If anyone could point me in the right direction it would be great. Thanks in advance!

    But I actually do not understand what that card layout thing is all about. If you want to hide/show internal frames you can simply use setVisible() and setSelected() like examplified below (I did put all code in the same file for my convenince). I have put a text in the label so that you can see that it is replaced. Using aJLabel to show an image is however a little bit weird.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    class MyInternalFrame extends JInternalFrame
      private JLabel graph1;
      public MyInternalFrame(String text)
        graph1 = new JLabel(text, 
                            new ImageIcon("../images/Graph1.jpg"),
                            JLabel.CENTER);
        getContentPane().add(graph1);
        setSize(500,550);
    public class InternalFrameDemo extends JFrame
      private JDesktopPane desktop;
      private final MyInternalFrame[] frames;
      public InternalFrameDemo()
        super("InternalFrameDemo");
        frames = new MyInternalFrame[3];
        //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
        setContentPane(desktop);
        frames[0] = createFrame("Hello world!");
        frames[1] = createFrame("Hello again, world!");
        frames[2] = createFrame("Goodbye cruel world!");
        desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        setSize(500, 500);
        Thread animThread = new Thread()
            public void run()
              for (int i = 0; i < frames.length; ++i)
                final int frameId = i;
                SwingUtilities.invokeLater(new Runnable()
                    public void run()
                      // Hide frame that is showing.
                      if (frameId != 0)
                        frames[frameId - 1].setVisible(false);
                      System.out.println("Replacing image: " + frameId);
                      frames[frameId].setVisible(true);
                      try
                        frames[frameId].setSelected(true);
                      catch (java.beans.PropertyVetoException exc)
                        exc.printStackTrace();
                try
                  Thread.sleep(3000);
                catch (InterruptedException exc)
                  exc.printStackTrace();
        animThread.start();
      //Create a new internal frame.
      protected MyInternalFrame createFrame(String text)
        MyInternalFrame frame = new MyInternalFrame(text);
        desktop.add(frame);
        return frame;
      public static void main(String[] args)
        JFrame frame = new InternalFrameDemo();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }Using lazy initialization where you postpone the creation of an internal frame until it is actually shown would be an improvement.
    The setVisible/Selected() call can of course be triggered by something else in your application.
    Note that changes of swing components shall be made in the EDT.

  • Custom internal frames

    Hello,
    I have written some custom internal frames, along with their UI's, title panes, and desktop icons. Everything seems to work fine when I'm in JBuilder and I use the "run" command, but when I compile the program and run it as a batch file, my internal frames appear as gray boxes that can't be moved or resized.
    package KComponent;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import Theme.*;
    import java.io.*;
    import javax.swing.border.*;
    public class KInternalFrame extends JInternalFrame {
      private JLabel titleLabel;
      private String title;
      public static Color titleColor = Color.white;
      public static Color titleBarColor = Theme.DARK;
      private KButton maximize, minimize, normalize;
      private static final String PATH = "pics" + File.separator;
      public KInternalFrame(String title) {
        super(title, true, false, true, true);
        this.title = title;
        this.titleColor = titleColor;
        this.titleBarColor = titleBarColor;
        //getContentPane().add(content, BorderLayout.CENTER);
        //setContentPane(content);
        //LineBorder line = new LineBorder(titleBarColor, 2);
        //setBorder(line);
        setBorder(BorderFactory.createRaisedBevelBorder());
        this.getDesktopIcon().setUI(new KDesktopIconUI(title, titleBarColor, titleColor));
        setUI(new KInternalFrameUI(this));
    package KComponent;
    import javax.swing.plaf.basic.*;
    import javax.swing.*;
    import java.awt.*;
    import Theme.*;
    public class KInternalFrameUI extends BasicInternalFrameUI {
      public KInternalFrameUI(JInternalFrame frame) {
        super(frame);
      protected void installDefaults(){
          Icon frameIcon = frame.getFrameIcon();
          frame.setFrameIcon(null);
          /* enable the content pane to inherit background color from its
             parent by setting its background color to null. Fixes bug#
             4268949. */
          JComponent contentPane = (JComponent) frame.getContentPane();
          if (contentPane != null) {
            Color bg = contentPane.getBackground();
          else {
            Color bg = null;
          //LookAndFeel.installBorder(frame, "InternalFrame.border");
      protected JComponent createNorthPane(JInternalFrame w) {
        titlePane = new KInternalFrameTitlePane(w, w.getTitle(), Theme.DARK, Color.white);
        return titlePane;
    package KComponent;
    import javax.swing.plaf.basic.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.File;
    import Theme.*;
    public class KInternalFrameTitlePane extends BasicInternalFrameTitlePane implements ActionListener {
      private JInternalFrame frame;
      private final String PATH = "pics" + File.separator;
      private KButton maxButton;
      private KButton minButton;
      private KButton normButton;
      private JLabel titleLabel;
      private File maxIcon = new File(PATH, "maximize.gif");
      private File maxOver = new File(PATH, "maximize_rollover.gif");
      private File minIcon = new File(PATH, "minimize.gif");
      private File minOver = new File(PATH, "minimize_rollover.gif");
      private File norIcon = new File(PATH, "normal.gif");
      private File norOver = new File(PATH, "normal_rollover.gif");
      String title;
      Color activeTitle;
      Color activeTitleText;
      Color inactiveTitle;
      Color inactiveTitleText;
      public KInternalFrameTitlePane(JInternalFrame frame, String title, Color activeTitle, Color activeTitleText) {
        super(frame);
        this.frame = frame;
        this.title = title;
        this.activeTitle = activeTitle;
        this.activeTitleText = activeTitleText;
        //this.inactiveTitle = inactiveTitle;
        //this.inactiveTitleText = inactiveTitleText;
        installTitlePane();
      public void installTitlePane() {
        titleLabel = new JLabel(" " + title + " ");
        titleLabel.setFont(new Font("verdana", Font.PLAIN, 11));
        titleLabel.setForeground(activeTitleText);
        titleLabel.setBorder(null);
        titleLabel.setOpaque(false);
        File icon = new File(PATH, "maximize.gif");
        File rollover = new File(PATH, "maximize_rollover.gif");
        maxButton = new KButton(icon, rollover, rollover, false);
        maxButton.setOpaque(false);
        maxButton.setToolTipText("Maximize window");
        maxButton.setActionCommand("maximize");
        //maxButton.addActionListener(this);
        icon = new File(PATH, "minimize.gif");
        rollover = new File(PATH, "minimize_rollover.gif");
        minButton = new KButton(icon, rollover, rollover, false);
        minButton.setOpaque(false);
        minButton.setToolTipText("Minimize window");
        minButton.setActionCommand("minimize");
        //minButton.addActionListener(this);
        icon = new File(PATH, "normal.gif");
        rollover = new File(PATH, "normal_rollover.gif");
        normButton = new KButton(icon, rollover, rollover, false);
        normButton.setOpaque(false);
        normButton.setToolTipText("Normalize window");
        normButton.setActionCommand("normal");
        //normButton.addActionListener(this);
        JPanel buttonHeader = new JPanel(new GridLayout(1, 3, 0, 0));
        buttonHeader.setOpaque(false);
        buttonHeader.add(minButton);
        buttonHeader.add(normButton);
        buttonHeader.add(maxButton);
        JPanel titlePane = new JPanel(new BorderLayout());
        titlePane.setBackground(activeTitle);
        titlePane.add(titleLabel, BorderLayout.WEST);
        titlePane.add(buttonHeader, BorderLayout.EAST);
        setBackground(activeTitle);
        setLayout(new BorderLayout());
        //add(titleLabel, BorderLayout.WEST);
        //add(buttonHeader, BorderLayout.EAST);
        add(titlePane, BorderLayout.CENTER);
        //installDefaults();
        createActions();
        enableActions();
        //createActionMap();
        assembleSystemMenu();
        createButtons();
      protected void createButtons() {
          minButton.addActionListener(iconifyAction);
          minButton.setActionCommand("minimize");
          minButton.addActionListener(this);
          maxButton.addActionListener(maximizeAction);
          maxButton.setActionCommand("maximize");
          maxButton.addActionListener(this);
          normButton.addActionListener(restoreAction);
          normButton.setActionCommand("normal");
          normButton.addActionListener(this);
          //setButtonIcons();
      public void setButtonIcons() {}
      public void actionPerformed(ActionEvent e) {
        String command = e.getActionCommand();
        if (command.equals("maximize")) {
          maxButton.setEnabled(false);
          minButton.setEnabled(true);
        else if (command.equals("minimize")) {
          //maxButton.setEnabled(true);
          //minButton.setEnabled(false);
        else if (command.equals("normal")) {
          maxButton.setEnabled(true);
          minButton.setEnabled(true);
    package KComponent;
    import javax.swing.plaf.basic.BasicDesktopIconUI;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.File;
    import javax.swing.border.*;
    public class KDesktopIconUI extends BasicDesktopIconUI {
      private final String PATH = "pics" + File.separator;
      private File norIcon = new File(PATH, "normal.gif");
      private File norOver = new File(PATH, "normal_rollover.gif");
      JComponent iconPane;
      String title;
      Color activeTitle;
      Color activeTitleText;
      KButton norButton;
      MouseInputListener mouseInputListener;
      public KDesktopIconUI(String title, Color activeTitle, Color activeTitleText) {
        this.title = title;
        this.activeTitle = activeTitle;
        this.activeTitleText = activeTitleText;
      protected void installComponents() {
          frame = desktopIcon.getInternalFrame();
          norButton = new KButton(norIcon, norOver, norOver, false);
          norButton.setOpaque(true);
          norButton.setBackground(activeTitle);
          iconPane = new JPanel(new BorderLayout());
          JLabel jlTitle = new JLabel(" " + title + " ");
          jlTitle.setFont(new Font("verdana", Font.PLAIN, 11));
          jlTitle.setForeground(activeTitleText);
          jlTitle.setBackground(activeTitle);
          jlTitle.setOpaque(true);
          iconPane.add(jlTitle, BorderLayout.CENTER);
          iconPane.add(norButton, BorderLayout.EAST);
          desktopIcon.setLayout(new BorderLayout());
          desktopIcon.add(iconPane, BorderLayout.CENTER);
          desktopIcon.setBackground(activeTitle);
          desktopIcon.setForeground(activeTitleText);
          iconPane.setBorder(BorderFactory.createRaisedBevelBorder());
          desktopIcon.setBorder(null);
      protected void installListeners() {
          mouseInputListener = createMouseInputListener();
          desktopIcon.addMouseMotionListener(mouseInputListener);
          desktopIcon.addMouseListener(mouseInputListener);
          norButton.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
              deiconize();
      public Dimension getMinimumSize(JComponent c) {
          return iconPane.getMinimumSize();
      public Dimension getMaximumSize(JComponent c){
          return iconPane.getMaximumSize();
      public Dimension getPreferredSize(JComponent c) {
          JInternalFrame iframe = desktopIcon.getInternalFrame();
          Border border = iframe.getBorder();
          int w2 = 157;
          int h2 = 18;
          //if(border != null)
              //h2 += border.getBorderInsets(iframe).bottom +
                //    border.getBorderInsets(iframe).top;
          return new Dimension(w2, h2);
      protected void uninstallComponents() {
          desktopIcon.setLayout(null);
          desktopIcon.remove(iconPane);
    package KComponent;
    import javax.swing.*;
    import java.awt.*;
    import Theme.*;
    import javax.swing.plaf.metal.*;
    public class KDesktop extends JDesktopPane {
      ImageIcon icon;
      boolean isWatermark;
      JInternalFrame gb, proj, stat, cal;
      boolean gbOpen, projOpen, statOpen, calOpen;
      public KDesktop(boolean isWatermark) {
        this.isWatermark = isWatermark;
        icon = Theme.getBackground();
        setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
      public void setBackgroundImage(ImageIcon i) {
        icon = i;
      public ImageIcon getBackgroundImage() {
        return icon;
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (!isWatermark) {
          if (getWidth() > icon.getIconWidth() || getHeight() > icon.getIconHeight()){
            g.drawImage(icon.getImage(), 0,0, getWidth(), getHeight(), null);
          else {
            if (getProportionalHeight(getWidth()) < getHeight()) {
              g.drawImage(icon.getImage(), 0, 0,
                          getProportionalWidth(getHeight()), getHeight(), null);
            else
              g.drawImage(icon.getImage(), 0,0,
                          getWidth(), getProportionalHeight(getWidth()), null);
        else {
          int w = icon.getIconWidth();
          int h = icon.getIconHeight();
          if (w == '\u0000' || h == '\u0000') {
            super.paint(g);
          else {
            int currX = 0;
            int currY = 0;
            boolean keepPainting = true;
            while (keepPainting) {
              if (currX < (getWidth()+w/2)) {
                g.drawImage(icon.getImage(), currX, currY, null);
                currX += w;
              else if (currY < (getHeight()+h/2)) {
                currX = 0;
                currY += h;
                g.drawImage(icon.getImage(), currX, currY, null);
              else keepPainting = false;
      public int getProportionalHeight(int width) {
        double percentage = (double)width/icon.getIconWidth();
        return (int)(percentage*icon.getIconHeight());
      public int getProportionalWidth(int height) {
        double percentage = (double)height/icon.getIconHeight();
        return (int)(percentage*icon.getIconWidth());
    }Any ideas? I don't see how everything could work fine within the JBuilder environment and then screw up when I compile the code.
    Thanks for any help.

    And this is how I call up the UI from my main function:
    displayFrame.setUI(new MyInternalFrameUI(intFrame));Thanks!

  • Passing data from a Table in a Dialog to a Listbox in a Internal Frame

    Hi All,
    Currently I have 2 .java classes.
    In the first class, DisplayListBox.java, it would have listboxes in it and a textbox with a button, Find.
    Upon clicking on the "Find" button, it would create a dialog window and call the second class, TableSelection.java.
    Therefore now, the dialog window would contain a table with all the datas.
    Just in case you guys would like to know, the dialog window was created in the DisplayListBox.java class and the internal frame was being created in another cls upon clicking the menu btn.
    Upon selecting a cell in the table, i'd like to pass the value to the listbox in the internal frame, how can i go about doing it?
    I've got the coding for getting the value of a selected cells. However, i'm unsure of how i can pass the value retrieved to the listbox in the internal frame.
    Any help and advices are gladly appreciated! (:

    Thanks for your reply.
    However, I am quite new to java so is it possible for you to explain in details of how i should go about going it?
    To start off, could you tell me:
    1. Where do I create the ListSelectionListener? In the DisplayListBox.java or TableSelection.java?
    Sorry for the trouble but i just picked up java so I am pretty much unsure of all these stuff.
    Thanks for your help! (:

  • Closed Internal Orders

    Dear FI Gurus,
    Does anyone knows of a report that will give me all closed Internal orders.
    Also can someone tell me as how I can prevent for closed internal orders to keep depreciating when i run reports, for those Internal orders that were closed with residual balance. Do I need to do anything extra to closed the Internal Order all together when it has residual balance?
    Your help will be greatly appreciated,

    Try 'KOK5' . Create a variant and add the closed on date range. You will get the result.

Maybe you are looking for