Urgent : JMenuBar repaint problem

hello all,
i'm facing a problem with jmenubar. i have developed an applet which contains a jmenubar, toolbaar & a panel. i'm doing some operation on the panel like rotating it by different angles. these operations are given in the menu. i have given accelerator keys for these menuitems. when i operate with these accelerator keys everything works fine. but when i click on the menuitem then a part of the panel gets panited on the menubar. but when i minimize the window & open it again the extra portion on the menubar disappears. can u suggest me what might be the problem with this. what is happening when we click a menuitem?
any help is appreciated.
Thanks in advance

i solved it by changing repaint() into revalidate() & paintImmediately()
i didn't get the reason why this works instead of repaint but now the code is working perfectly.
This was the 1st time i did a cross posting. I had to deliver the solution that day itself that's why i posted it on different forms. i thought some experts will check the forms which they r interested. anyway learned a lesson from this. won't repeat it.

Similar Messages

  • Repaint problem while clicking the popup menuitem

    Hi all,
    iam facing repainting problem in my application. User can initiate a single action from different options such as JButton, double-click of mouse and clicking the menu item form the JPopupMenu.
    All these will execute the same code. But when iam using the first two ways, the repainting is properly working and aim getting the required UI and opening the JInternalFrame.
    When the last case is being used(ie., clicking the menu item form the JPopupMenu), then the repaint is not working and the window being opened is coming in pieces and then finally i could see the window after some time, which is not the case with the first two cases.
    Please help me how to solve and get the window at once. Iam attaching the code.
    MainFrame.java
    package com.swing;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.event.MouseWheelEvent;
    import java.awt.event.MouseWheelListener;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    public class MainFrame extends JFrame implements ActionListener{
         static final long serialVersionUID = 3345648L;
         public MainFrame() {
              setSize(1000,750);
              setLayout(null);
              setVisible(true);
              addMenuBar();
              invalidate();
         public void actionPerformed(ActionEvent actionEvent) {
              Object source = actionEvent.getSource();
              if( source == s_mnuItmFirstFrame ) {
                   FirstFrame s_frameFirst = new FirstFrame(this);
                   this.add(s_frameFirst);
          * @param args
         public static void main(String[] args) {
              MainFrame mFrame = new MainFrame();
         JMenuBar s_menuBar = null;
         JMenuItem s_mnuItmFirstFrame = new JMenuItem("Add Internal Frame");
         void addMenuBar(){
              Font fontNormal = new Font("Dialog", Font.PLAIN, 11);
              s_menuBar = new JMenuBar();
              s_menuBar.setDoubleBuffered(true);
              getRootPane().setJMenuBar(s_menuBar);
              s_mnuItmFirstFrame.setFont(fontNormal);
              s_mnuItmFirstFrame.addActionListener(this);
              JMenu s_menuFrames = new JMenu("Frames");
              s_menuFrames.setFont(fontNormal);
              s_menuFrames.add(s_mnuItmFirstFrame);
              s_menuBar.add(s_menuFrames);
    FirstFrame.java
    package com.swing;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.event.MouseWheelEvent;
    import java.util.Vector;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JInternalFrame;
    import javax.swing.JMenuItem;
    import javax.swing.JPopupMenu;
    import javax.swing.JTable;
    import javax.swing.event.InternalFrameAdapter;
    import javax.swing.event.InternalFrameEvent;
    import javax.swing.table.DefaultTableModel;
    public class FirstFrame extends JInternalFrame implements ActionListener
         static final long serialVersionUID = 2345657L;
         public FirstFrame(JFrame parentFrame) {
              super(" First Frame ", true, true, true, true);
              mainFrame = parentFrame;
              setSize(400, 400);
              setVisible(true);
              setLayout(new FlowLayout());
              try {
                   setMaximum(false);
              } catch (Exception e) {
                   e.printStackTrace();
              DefaultTableModel s_modelFirstTable = new DefaultTableModel();
              Vector tableData = new Vector();
              Vector namesVector = new Vector();
              namesVector.add("OneFirst");
              namesVector.add("OneMiddle");
              namesVector.add("OneLast");
              tableData.add(namesVector);
              namesVector = new Vector();
              namesVector.add("TwoFirst");
              namesVector.add("TwoMiddle");
              namesVector.add("TwoLast");
              tableData.add(namesVector);
              namesVector = new Vector();
              namesVector.add("ThreeFirst");
              namesVector.add("ThreeMiddle");
              namesVector.add("ThreeLast");
              tableData.add(namesVector);
              namesVector = new Vector();
              namesVector.add("FourFirst");
              namesVector.add("FourMiddle");
              namesVector.add("FourLast");
              tableData.add(namesVector);
              namesVector = new Vector();
              namesVector.add("FiveFirst");
              namesVector.add("FiveMiddle");
              namesVector.add("FiveLast");
              tableData.add(namesVector);
              Vector tableHeader = new Vector();
              tableHeader.add("First Name");
              tableHeader.add("Middle Name");
              tableHeader.add("Last Name");
              s_modelFirstTable.setDataVector(tableData, tableHeader);
              s_tblFirst.setModel(s_modelFirstTable);
              add(s_tblFirst);
              add(s_btnSecondButton);
              s_mnuPopupMenu.add(s_mnuItmSecondButton);
              s_mnuPopupMenu.add(s_mnuItmSecondButton1);
              s_mnuPopupMenu.add(s_mnuItmSecondButton2);
              s_mnuPopupMenu.add(s_mnuItmSecondButton3);
              s_mnuPopupMenu.add(s_mnuItmSecondButton4);
              s_tblFirst.addMouseListener(new MouseAdapter() {
                   public void mouseReleased(MouseEvent mouseEvent) {
                        s_mnuPopupMenu.setVisible(true);
                        // if (mouseEvent.isPopupTrigger()) {
                        s_mnuPopupMenu.show(mouseEvent.getComponent(), mouseEvent
                                  .getX(), mouseEvent.getY());
              s_btnSecondButton.addActionListener(this);
              s_mnuItmSecondButton.addActionListener(this);
              this.addInternalFrameListener(new InternalFrameAdapter() {
                   public void internalFrameClosing(InternalFrameEvent ifEvent) {
                        Object object = ifEvent.getSource();
                        if (object == FirstFrame.this) {
                             try {
                                  if (s_frameSecond != null)
                                       s_frameSecond.setClosed(true);
                             } catch (Exception e) {
                                  e.printStackTrace();
         public void actionPerformed(ActionEvent actionEvent) {
              if (s_frameSecond != null) {
                   try {
                        s_frameSecond.setClosed(true);
                   } catch (Exception e) {
                        e.printStackTrace();
              s_frameSecond = new SecondFrame();
              mainFrame.add(s_frameSecond);
              s_frameSecond.moveToFront();
              s_frameSecond.setVisible(true);
         JFrame mainFrame ;
         JTable s_tblFirst = new JTable();
         JButton s_btnSecondButton = new JButton("Second Frame");
         JMenuItem s_mnuItmSecondButton = new JMenuItem("Second Frame");
         JMenuItem s_mnuItmSecondButton1 = new JMenuItem("Second Frame1");
         JMenuItem s_mnuItmSecondButton2 = new JMenuItem("Second Frame2");
         JMenuItem s_mnuItmSecondButton3 = new JMenuItem("Second Frame3");
         JMenuItem s_mnuItmSecondButton4 = new JMenuItem("Second Frame4");
         JPopupMenu s_mnuPopupMenu = new JPopupMenu();
         SecondFrame s_frameSecond;
    SecondFrame.java
    package com.swing;
    import java.awt.GridLayout;
    import javax.swing.JButton;
    import javax.swing.JInternalFrame;
    public class SecondFrame extends JInternalFrame {
         static final long serialVersionUID = 1345648L;
         public SecondFrame() {
              super(" Second Frame ", true, true, true, true);
              try {
              setLayout(new GridLayout(4, 4));
              setSize(400,400);
              //setVisible(true);
              setMaximizable(true);
              for(int i=0; i<4; i++){
                   for(int j=0; j<4; j++){
                        add(new JButton(""+(i+1)+", "+(j+1)));
              catch(Exception e){
                   e.printStackTrace();
    }

    Don't post an IDE generated code as is. It's a torture for human eye. At least, you should rename
    all the identifiers to some meaningful names.
    You MUST use JDesktopPane when you use JInternalFrames.
    Here's a working code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    import java.util.*;
    public class MainFrame extends JFrame implements ActionListener{
      static final long serialVersionUID = 3345648;
      JFrame frame;
      JDesktopPane jdp;
      public MainFrame() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(1000,750);
        // setLayout(null); //you MUST use a real LayoutManager
        addMenuBar();
        frame = this;
        jdp = new JDesktopPane();
        frame.add(jdp);
        setVisible(true);
      public void actionPerformed(ActionEvent actionEvent) {
        Object source = actionEvent.getSource();
        if( source == s_mnuItmFirstFrame ) {
          FirstFrame s_frameFirst = new FirstFrame(this);
          jdp.add(s_frameFirst);
          s_frameFirst.setVisible(true);
      public static void main(String[] args) {
        MainFrame mFrame = new MainFrame();
      JMenuBar s_menuBar = null;
      JMenuItem s_mnuItmFirstFrame = new JMenuItem("Add Internal Frame");
      void addMenuBar(){
        Font fontNormal = new Font("Dialog", Font.PLAIN, 11);
        s_menuBar = new JMenuBar();
        s_menuBar.setDoubleBuffered(true);
        getRootPane().setJMenuBar(s_menuBar);
        s_mnuItmFirstFrame.setFont(fontNormal);
        s_mnuItmFirstFrame.addActionListener(this);
        JMenu s_menuFrames = new JMenu("Frames");
        s_menuFrames.setFont(fontNormal);
        s_menuFrames.add(s_mnuItmFirstFrame);
        s_menuBar.add(s_menuFrames);
        setJMenuBar(s_menuBar);
    class FirstFrame extends JInternalFrame implements ActionListener{
      static final long serialVersionUID = 2345657;
      public FirstFrame(MainFrame parentFrame) {
        super(" First Frame ", true, true, true, true);
        mainFrame = parentFrame;
        setSize(400, 400);
        setVisible(true);
        setLayout(new FlowLayout());
        try {
          setMaximum(false);
        } catch (Exception e) {
          e.printStackTrace();
        DefaultTableModel s_modelFirstTable = new DefaultTableModel();
        Vector<Vector> tableData = new Vector<Vector>();
        Vector<String> namesVector = new Vector<String>();
        namesVector.add("OneFirst");
        namesVector.add("OneMiddle");
        namesVector.add("OneLast");
        tableData.add(namesVector);
        namesVector = new Vector<String>();
        namesVector.add("TwoFirst");
        namesVector.add("TwoMiddle");
        namesVector.add("TwoLast");
        tableData.add(namesVector);
        namesVector = new Vector<String>();
        namesVector.add("ThreeFirst");
        namesVector.add("ThreeMiddle");
        namesVector.add("ThreeLast");
        tableData.add(namesVector);
        namesVector = new Vector<String>();
        namesVector.add("FourFirst");
        namesVector.add("FourMiddle");
        namesVector.add("FourLast");
        tableData.add(namesVector);
        namesVector = new Vector<String>();
        namesVector.add("FiveFirst");
        namesVector.add("FiveMiddle");
        namesVector.add("FiveLast");
        tableData.add(namesVector);
        Vector<String> tableHeader = new Vector<String>();
        tableHeader.add("First Name");
        tableHeader.add("Middle Name");
        tableHeader.add("Last Name");
        s_modelFirstTable.setDataVector(tableData, tableHeader);
        s_tblFirst.setModel(s_modelFirstTable);
        add(s_tblFirst);
        add(s_btnSecondButton);
        s_mnuPopupMenu.add(s_mnuItmSecondButton);
        s_mnuPopupMenu.add(s_mnuItmSecondButton1);
        s_mnuPopupMenu.add(s_mnuItmSecondButton2);
        s_mnuPopupMenu.add(s_mnuItmSecondButton3);
        s_mnuPopupMenu.add(s_mnuItmSecondButton4);
        s_tblFirst.addMouseListener(new MouseAdapter() {
          public void mousePressed(MouseEvent mouseEvent){
            if (mouseEvent.isPopupTrigger()) {
              s_mnuPopupMenu.show(mouseEvent.getComponent(),
               mouseEvent.getX(), mouseEvent.getY());
          public void mouseReleased(MouseEvent mouseEvent) {
            if (mouseEvent.isPopupTrigger()) {
              s_mnuPopupMenu.show(mouseEvent.getComponent(),
               mouseEvent.getX(), mouseEvent.getY());
        s_btnSecondButton.addActionListener(this);
        s_mnuItmSecondButton.addActionListener(this);
        addInternalFrameListener(new InternalFrameAdapter() {
          public void internalFrameClosing(InternalFrameEvent ifEvent) {
            Object object = ifEvent.getSource();
            if (object == this) {
              try {
                if (s_frameSecond != null){
                  s_frameSecond.setClosed(true);
              } catch (Exception e) {
                e.printStackTrace();
      } // FirstFrame constructor
      public void actionPerformed(ActionEvent actionEvent) {
        if (s_frameSecond != null) {
          try {
            s_frameSecond.setClosed(true);
          } catch (Exception e) {
            e.printStackTrace();
        s_frameSecond = new SecondFrame();
        mainFrame.jdp.add(s_frameSecond);
        s_frameSecond.moveToFront();
        s_frameSecond.setVisible(true);
      MainFrame mainFrame ;
      JTable s_tblFirst = new JTable();
      JButton s_btnSecondButton = new JButton("Second Frame");
      JMenuItem s_mnuItmSecondButton = new JMenuItem("Second Frame");
      JMenuItem s_mnuItmSecondButton1 = new JMenuItem("Second Frame1");
      JMenuItem s_mnuItmSecondButton2 = new JMenuItem("Second Frame2");
      JMenuItem s_mnuItmSecondButton3 = new JMenuItem("Second Frame3");
      JMenuItem s_mnuItmSecondButton4 = new JMenuItem("Second Frame4");
      JPopupMenu s_mnuPopupMenu = new JPopupMenu();
      SecondFrame s_frameSecond;
    class SecondFrame extends JInternalFrame {
      static final long serialVersionUID = 1345648;
      public SecondFrame() {
        super(" Second Frame ", true, true, true, true);
        try {
          setLayout(new GridLayout(4, 4));
          setSize(400, 400);
          setMaximizable(true);
          for(int i=0; i<4; i++){
            for(int j = 0; j < 4; ++j){
              add(new JButton("" + (i + 1) + ", " + (j + 1)));
        catch(Exception e){
          e.printStackTrace();
    }

  • Performance with repaint problem

    Hi,
    I have a performance and repaint problem.
    My problem is than I have a layer pane with about 500 JScrollPane, each JScrollPane has a JLabel, and each JLabel has an Icon. I can have to maintain this hierarchy.
    I have a thread that makes the icon change from a color state to a grey state; in fact it makes them all blink.
    My problem is that is takes 50% of the CPU when the blink thread is running. As well, they do not all blink at the same time. The thread changes the icon color and calls a repaint. They seem to repaint independently.
    What I would like is to collapse the paint calls into one without having to call repaint on the whole JFrame which does solve my problem but it is a hack.
    Swing should collapse all the repaints into one call to the parent but I think because of the JScrollPanes it is not. Can anyone shed any light into why it does not paint all in one call instead of 500 repaint calls.
    Thanks,
    Pat

    Well, I'd change the design first, but if you must play around with paint() then you can try using this setIgnoreRepaint(true) in the Component class.
    You could do the grouping yourself and then when you really want things repainted, flag all your components again with setIgnoreRepaint(false), and then call revlaidate() to the parent, and it should repaint everything at once. That is what's I'd try, anyway.

  • Initial repaint problem

    Hello all,
    Iam facing a repaint problem when i start my pgm. the display is distorted but when i minimize & maximize the window display is proper after that everything works fine. my pgm contains JApplet which in turn contains toobar, menubar scrollpane & a panel. the panel contaisn one more panel on which i'm drawing some data. when the pgm starts up the drawing is no in it's proper position i tried calling repaint, revalidate, paintAll .. all these commands in various places in various combination. i couldn't still solvemy problem. can anybody help me with this. the problem comes only when the window opens at first.
    Thanks in advance

    I also want to add one more thing if i run this as an application this problem doesn't comes. but i want to run this as an applet. is there anything special with the applet's paint method. please help me.

  • OHJ4.1.16 Repainting Problems and 100%CPU on java 1.4

    Hi
    We are considering using OHJ4.1.16 as our application help, I have it working such that when the help is invoked either from the toolbar or the menu OHJ is displayed, but there are major repainting problems when the OHJ window is closed by clicking on the X button and then the help is invoked again from the toolbar or the menu item.
    Please note that the first time it displays and paints fine only when the OHJ frame is closed and invoked again the problem occurs
    The problems encountered are repainting(really whacky), 100% CPU utilization
    Please have a look at the code below and tell me if i am not doing it right, Also is there anyway i can trap events on the OHJ frame so that i can dispose it everytime the window is closed by the user??
    The following code is executed when the help is invoked
         public void startHelp()
         helpObject.showNavigatorWindow();     
         helpObject.setVisible(true);
         public static void launchApplication()
              String helpset1 = "/resources/help/Test.hs";
              Vector booksVector = new Vector();
              booksVector.add(helpset1);
                   if(m_instance == null)
                        m_instance = new ApplicationHelp(booksVector);
                   else
                        m_instance.startHelp();                    
    we are using java 1.4, the above problem makes OHJ unusable!!

    Hi, John. We're trying to reproduce your problem. If you run any of the OHJ 4.1.16 demos in the bin directory of the installation, do you run into the 100% CPU utilization problem? If so, how? The cshDemo.bat file creates a dummy application that has an OHJ deployment, so please test that one in particular.
    Thanks,
    Ryan

  • JTextpane positioning repaint problems

    Hello all,
    I have encountered a bug with JTextpane which I haven't found a solution for. I am new to Java and am revising previously written code, but I think this is a Java-related issue and not particular to my source code.
    I am writing html into a JTextPane-based class, yet on occasion, not keen to any particular scenarios, my text loses its position and drops one line. This is fixed by closing the window, hiding it or doing other things which I assume forces a repaint.
    This is very hard to debug. Is there a way to force all events to be called whenever I display the html textpane (like a VB6 DoEvents)? Has anyone encountered these repaint problems with JTextPane?
    Thanks in advance
    Eyal

    Thanks for the reply
    Could you please xplain what you mean by "subbing"?
    Anyhow I tried adding your suggestion but I am still encountering similar problems, and I can't debug because the symptoms don't appear in a consistent fashion.
    If anyone has any suggestions I'd love to know.
    Best regards
    Eyal

  • MDI JTable Overlap Area Repaint Problem

    Hi all,
    I have a problem for my application in MDI mode.
    I open many windows (JInternalFrame contain JTable) under JDesktopPane. Some of the windows are overlapping and when they receive update in the table, it seems repaint all of the overlapping windows, not only itself. This make my application performance become poor, slow respond for drap & drop an existing window or open a new window.
    To prove this, i make a simple example for open many simple table and have a thread to update the table's value for every 200 mill second. After i open about 20 windows, the performance become poor again.
    If anyone face the same problem with me and any suggestions to solve the problem ?
    Please help !!!!!
    Following are my sources:
    public class TestMDI extends JFrame {
        private static final long serialVersionUID = 1L;
        private JPanel contentPanel;
        private JDesktopPane desktopPane;
        private JMenuBar menuBar;
        private List<TestPanel> allScreens = new ArrayList<TestPanel>();
        private List<JDialog> freeFloatDialogs = new ArrayList<JDialog>();
        private List<JInternalFrame> mdiInternalFrm = new ArrayList<JInternalFrame>();
        int x = 0;
        int y = 0;
        int index = 0;
        private static int MDI_MODE = 0;
        private static int FREE_FLOAT_MODE = 1;
        private int windowMode = MDI_MODE;
        public TestMDI() {
            init();
        public static void main(String[] args) {
            new TestMDI().show();
        public void init() {
            contentPanel = new JPanel();
            desktopPane = new JDesktopPane();
            desktopPane.setDragMode(JDesktopPane.LIVE_DRAG_MODE);
            desktopPane.setFocusTraversalKeysEnabled(false);
            desktopPane.setFocusTraversalPolicyProvider(false);
            desktopPane.setBorder(null);
            desktopPane.setIgnoreRepaint(true);
            desktopPane.setPreferredSize(new Dimension(1000, 800));
            this.setSize(new Dimension(1000, 800));
            menuBar = new JMenuBar();
            JMenu menu1 = new JMenu("Test");
            JMenuItem menuItem1 = new JMenuItem("Open Lable Screen");
            menuItem1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    for (int i = 1; i < 4; i++) {
                        final TestJLableScreen screen = new TestJLableScreen("Screen  " + (allScreens.size() + 1));
                        screen.startTime();
                        if (windowMode == MDI_MODE) {
                            JInternalFrame frame = createInternalFram(screen);
                            desktopPane.add(frame);
                            mdiInternalFrm.add(frame);
                            if (allScreens.size() * 60 + 100 < 1000) {
                                x = allScreens.size() * 60;
                                y = 60;
                            } else {
                                x = 60 * index;
                                y = 120;
                                index++;
                            frame.setLocation(x, y);
                            frame.setVisible(true);
                        } else {
                            JDialog dialog = createJDialog(screen);
                            freeFloatDialogs.add(dialog);
                            if (i * 60 + 100 < 1000) {
                                x = i * 60;
                                y = 60;
                            } else {
                                x = 60 * index;
                                y = 120;
                                index++;
                            dialog.setLocation(x, y);
                            dialog.setVisible(true);
                        allScreens.add(screen);
            JMenuItem menuItem2 = new JMenuItem("Open Table Screen");
            menuItem2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    for (int i = 1; i < 4; i++) {
                        TestTableScreen screen = new TestTableScreen("Screen  " + (allScreens.size() + 1));
                        screen.startTime();
                        if (windowMode == MDI_MODE) {
                            JInternalFrame frame = createInternalFram(screen);
                            desktopPane.add(frame);
                            mdiInternalFrm.add(frame);
                            if (allScreens.size() * 60 + 100 < 1000) {
                                x = allScreens.size() * 60;
                                y = 60;
                            } else {
                                x = 60 * index;
                                y = 120;
                                index++;
                            frame.setLocation(x, y);
                            frame.setVisible(true);
                        } else {
                            JDialog dialog = createJDialog(screen);
                            freeFloatDialogs.add(dialog);
                            if (i * 60 + 100 < 1000) {
                                x = i * 60;
                                y = 60;
                            } else {
                                x = 60 * index;
                                y = 120;
                                index++;
                            dialog.setLocation(x, y);
                            dialog.setVisible(true);
                        allScreens.add(screen);
            menu1.add(menuItem1);
            menu1.add(menuItem2);
            this.setJMenuBar(menuBar);
            this.getJMenuBar().add(menu1);
            this.getJMenuBar().add(createSwitchMenu());
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.add(desktopPane);
            desktopPane.setDesktopManager(null);
        public JInternalFrame createInternalFram(final TestPanel panel) {
            final CustomeInternalFrame internalFrame = new CustomeInternalFrame(panel.getTitle(), true, true, true, true) {
                public void doDefaultCloseAction() {
                    super.doDefaultCloseAction();
                    allScreens.remove(panel);
            internalFrame.setPanel(panel);
            // internalFrame.setOpaque(false);
            internalFrame.setSize(new Dimension(1010, 445));
            internalFrame.add(panel);
            internalFrame.setFocusTraversalKeysEnabled(false);
            internalFrame.setFocusTraversalPolicyProvider(false);
            desktopPane.getDesktopManager();
            // internalFrame.setFocusTraversalKeysEnabled(false);
            internalFrame.setIgnoreRepaint(true);
            return internalFrame;
        public JDialog createJDialog(final TestPanel panel) {
            JDialog dialog = new JDialog(this, panel.getTitle());
            dialog.setSize(new Dimension(1010, 445));
            dialog.add(panel);
            dialog.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    allScreens.remove(panel);
            return dialog;
        public JMenu createSwitchMenu() {
            JMenu menu = new JMenu("Test2");
            JMenuItem menuItem1 = new JMenuItem("Switch FreeFloat");
            menuItem1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    windowMode = FREE_FLOAT_MODE;
                    for (JInternalFrame frm : mdiInternalFrm) {
                        frm.setVisible(false);
                        frm.dispose();
                        frm = null;
                    mdiInternalFrm.clear();
                    remove(desktopPane);
                    desktopPane.removeAll();
    //                revalidate();
                    repaint();
                    add(contentPanel);
                    index = 0;
                    for (JDialog dialog : freeFloatDialogs) {
                        dialog.setVisible(false);
                        dialog.dispose();
                        dialog = null;
                    freeFloatDialogs.clear();
                    for (int i = 0; i < allScreens.size(); i++) {
                        JDialog dialog = createJDialog(allScreens.get(i));
                        freeFloatDialogs.add(dialog);
                        if (i * 60 + 100 < 1000) {
                            x = i * 60;
                            y = 60;
                        } else {
                            x = 60 * index;
                            y = 120;
                            index++;
                        dialog.setLocation(x, y);
                        dialog.setVisible(true);
            JMenuItem menuItem2 = new JMenuItem("Switch MDI");
            menuItem2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    windowMode = MDI_MODE;
                    remove(contentPanel);
                    add(desktopPane);
                    for (int i = 0; i < freeFloatDialogs.size(); i++) {
                        freeFloatDialogs.get(i).setVisible(false);
                        freeFloatDialogs.get(i).dispose();
                    freeFloatDialogs.clear();
    //                revalidate();
                    repaint();
                    for (JInternalFrame frm : mdiInternalFrm) {
                        frm.setVisible(false);
                        frm.dispose();
                        frm = null;
                    mdiInternalFrm.clear();
                    index = 0;
                    for (int i = 0; i < allScreens.size(); i++) {
                        JInternalFrame frame = createInternalFram(allScreens.get(i));
                        desktopPane.add(frame);
                        mdiInternalFrm.add(frame);
                        if (i * 60 + 100 < 1000) {
                            x = i * 60;
                            y = 60;
                        } else {
                            x = 60 * index;
                            y = 120;
                            index++;
                        frame.setLocation(x, y);
                        frame.setVisible(true);
            menu.add(menuItem1);
            menu.add(menuItem2);
            return menu;
    public class TestTableScreen extends TestPanel {
        private static final long serialVersionUID = 1L;
        JTable testTable = new JTable();
        MyTableModel tableModel1 = new MyTableModel(1);
        private boolean notRepaint = false;
        int start = 0;
        JScrollPane scrollPane = new JScrollPane();
        private Timer timmer = new Timer(200, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Random indexRandom = new Random();
                final int index = indexRandom.nextInt(50);
                Random valRandom = new Random();
                final int val = valRandom.nextInt(600);
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        notRepaint = false;
                        TestTableScreen.this.update(index + "|" + val);
        public TestTableScreen(String title) {
            this.title = title;
            init();
            tableModel1.setTabelName(title);
        public void startTime() {
            timmer.start();
        public String getTitle() {
            return title;
        public void update(String updateStr) {
            String[] val = updateStr.split("\\|");
            if (val.length == 2) {
                int index = Integer.valueOf(val[0]);
                List vals = tableModel1.getVector();
                if (vals.size() > index) {
                    vals.set(index, val[1]);
    //                 tableModel1.fireTableRowsUpdated(index, index);
                } else {
                    vals.add(val[1]);
    //                 tableModel1.fireTableRowsUpdated(vals.size() - 1, vals.size() - 1);
                tableModel1.fireTableDataChanged();
        public TableModel getTableModel() {
            return tableModel1;
        public void init() {
            testTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            testTable.setRowSelectionAllowed(true);
            this.testTable.setModel(tableModel1);
            int[] width = { 160, 80, 45, 98, 60, 88, 87, 88, 80, 70, 88, 80, 75, 87, 87, 41, 88, 82, 75, 68, 69 };
            TableColumnModel columnModel = testTable.getColumnModel();
            for (int i = 0; i < width.length; i++) {
                columnModel.getColumn(i).setPreferredWidth(width[i]);
            testTable.setRowHeight(20);
            tableModel1.fireTableDataChanged();
            this.setLayout(new BorderLayout());
            TableColumnModel columnMode2 = testTable.getColumnModel();
            int[] width2 = { 200 };
            for (int i = 0; i < width2.length; i++) {
                columnMode2.getColumn(i).setPreferredWidth(width2[i]);
            scrollPane.getViewport().add(testTable);
            scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            this.add(scrollPane, BorderLayout.CENTER);
        class MyTableModel extends DefaultTableModel {
            public List list = new ArrayList();
            String titles[] = new String[] { "袨怓1", "袨怓2", "袨怓3", "袨怓4", "袨怓5", "袨怓6", "袨怓7", "袨怓8", "袨怓9", "袨怓10", "袨怓11",
                    "袨怓12", "袨怓13", "袨怓14", "袨怓15", "袨怓16", "袨怓17", "袨怓18", "袨怓19", "袨怓20", "袨怓21" };
            String tabelName = "";
            int type_head = 0;
            int type_data = 1;
            int type = 1;
            public MyTableModel(int type) {
                super();
                this.type = type;
                for (int i = 0; i < 50; i++) {
                    list.add(i);
            public void setTabelName(String name) {
                this.tabelName = name;
            public int getRowCount() {
                if (list != null) {
                    return list.size();
                return 0;
            public List getVector() {
                return list;
            public int getColumnCount() {
                if (type == 0) {
                    return 1;
                } else {
                    return titles.length;
            public String getColumnName(int c) {
                if (type == 0) {
                    return "head";
                } else {
                    return titles[c];
            public boolean isCellEditable(int nRow, int nCol) {
                return false;
            public Object getValueAt(int r, int c) {
                if (list.size() == 0) {
                    return null;
                switch (c) {
                default:
                    if (type == 0) {
                        return r + " " + c + "  test ";
                    } else {
                        return list.get(r) + "   " + c;
        public boolean isNotRepaint() {
            return notRepaint;
        public void setNotRepaint(boolean notRepaint) {
            this.notRepaint = notRepaint;
    public class TestPanel extends JPanel {
        protected String title = "";
        protected boolean needRepaint = false;
        protected boolean isFirstOpen = true;
        public String getTitle() {
            return title;
        public void setNeedRepaint(boolean flag) {
            this.needRepaint = flag;
        public boolean isNeedRepaint() {
            return needRepaint;
        public boolean isFirstOpen() {
            return isFirstOpen;
        public void setFirstOpen(boolean isFirstOpen) {
            this.isFirstOpen = isFirstOpen;
    public class TestJLableScreen extends TestPanel {
        private static final long serialVersionUID = 1L;
        private JLabel[] allLables = new JLabel[20];
        private Timer timmer = new Timer(20, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Random indexRandom = new Random();
                final int index = indexRandom.nextInt(10);
                Random valRandom = new Random();
                final int val = valRandom.nextInt(600);
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        TestJLableScreen.this.setNeedRepaint(true);
                        TestJLableScreen.this.update(index + "|" + val);
        public TestJLableScreen(String title) {
            this.title = title;
            init();
        public void startTime() {
            timmer.start();
        public String getTitle() {
            return title;
        public void update(String updateStr) {
            String[] val = updateStr.split("\\|");
            if (val.length == 2) {
                int index = Integer.valueOf(val[0]);
                allLables[index * 2 + 1].setText(val[1]);
        public void init() {
            this.setLayout(new GridLayout(10, 2));
            boolean flag = true;
            for (int i = 0; i < allLables.length; i++) {
                allLables[i] = new JLabel() {
                    // public void setText(String text) {
                    // super.setText(text);
                    // // System.out.println("  setText " + getTitle() + "   ; " + this.getName());
                    public void paint(Graphics g) {
                        super.paint(g);
                        // System.out.println("  paint " + getTitle() + "   ; " + this.getName());
                    // public void repaint() {
                    // super.repaint();
                    // System.out.println("  repaint " + getTitle() + "   ; " + this.getName());
                allLables[i].setName("" + i);
                if (i % 2 == 0) {
                    allLables[i].setText("Name " + i + "  : ");
                } else {
                    allLables[i].setOpaque(true);
                    if (flag) {
                        allLables[i].setBackground(Color.YELLOW);
                        flag = false;
                    } else {
                        allLables[i].setBackground(Color.CYAN);
                        flag = true;
                    allLables[i].setText(i * 8 + "");
            for (int i = 0; i < allLables.length; i++) {
                this.add(allLables[i]);
    public class CustomeInternalFrame extends JInternalFrame {
        protected TestPanel panel;
        public CustomeInternalFrame() {
            this("", false, false, false, false);
        public CustomeInternalFrame(String title) {
            this(title, false, false, false, false);
        public CustomeInternalFrame(String title, boolean resizable) {
            this(title, resizable, false, false, false);
        public CustomeInternalFrame(String title, boolean resizable, boolean closable) {
            this(title, resizable, closable, false, false);
        public CustomeInternalFrame(String title, boolean resizable, boolean closable, boolean maximizable) {
            this(title, resizable, closable, maximizable, false);
        public CustomeInternalFrame(String title, boolean resizable, boolean closable, boolean maximizable,
                boolean iconifiable) {
            super(title, resizable, closable, maximizable, iconifiable);
        public TestPanel getPanel() {
            return panel;
        public void setPanel(TestPanel panel) {
            this.panel = panel;

    i had the same problem with buttons and it seemed that i overlayed my button with something else...
    so check that out first do you put something on that excact place???
    other problem i had was the VAJ one --> VisualAge for Java (terrible program)
    it does strange tricks even when you don't use the drawing tool...
    dunno 2 thoughts i had... check it out...
    SeJo

  • Repaint() problem

    this is the second thread im posting so if u reply in the first thx,
    but i still have a problem for example lets take this code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    import java.awt.event.MouseEvent;
    import javax.swing.event.MouseInputAdapter;
    /** An application that requires no other files. */
    public class GlassPaneDemo {
        static private MyGlassPane myGlassPane;
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("GlassPaneDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Start creating and adding components.
            JCheckBox changeButton =
                    new JCheckBox("Glass pane \"visible\"");
            changeButton.setSelected(false);
            //Set up the content pane, where the "main GUI" lives.
            Container contentPane = frame.getContentPane();
            contentPane.setLayout(new FlowLayout());
            contentPane.add(changeButton);
            contentPane.add(new JButton("Button 1"));
            contentPane.add(new JButton("Button 2"));
            //Set up the menu bar, which appears above the content pane.
            JMenuBar menuBar = new JMenuBar();
            JMenu menu = new JMenu("Menu");
            menu.add(new JMenuItem("Do nothing"));
            menuBar.add(menu);
            frame.setJMenuBar(menuBar);
            //Set up the glass pane, which appears over both menu bar
            //and content pane and is an item listener on the change
            //button.
            myGlassPane = new MyGlassPane(changeButton, menuBar,
                                          frame.getContentPane());
            changeButton.addItemListener(myGlassPane);
            frame.setGlassPane(myGlassPane);
            //Show the window.
            frame.pack();
            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();
    * We have to provide our own glass pane so that it can paint.
    class MyGlassPane extends JComponent
                      implements ItemListener {
        Point point;
        //React to change button clicks.
        public void itemStateChanged(ItemEvent e) {
            setVisible(e.getStateChange() == ItemEvent.SELECTED);
        protected void paintComponent(Graphics g) {
            if (point != null) {
                g.setColor(Color.red);
                g.fillOval(point.x - 10, point.y - 10, 20, 20);
        public void setPoint(Point p) {
            point = p;
        public MyGlassPane(AbstractButton aButton,
                           JMenuBar menuBar,
                           Container contentPane) {
            CBListener listener = new CBListener(aButton, menuBar,
                                                 this, contentPane);
            addMouseListener(listener);
            addMouseMotionListener(listener);
    * Listen for all events that our check box is likely to be
    * interested in.  Redispatch them to the check box.
    class CBListener extends MouseInputAdapter {
        Toolkit toolkit;
        Component liveButton;
        JMenuBar menuBar;
        MyGlassPane glassPane;
        Container contentPane;
        public CBListener(Component liveButton, JMenuBar menuBar,
                          MyGlassPane glassPane, Container contentPane) {
            toolkit = Toolkit.getDefaultToolkit();
            this.liveButton = liveButton;
            this.menuBar = menuBar;
            this.glassPane = glassPane;
            this.contentPane = contentPane;
        public void mouseMoved(MouseEvent e) {
            redispatchMouseEvent(e, false);
        public void mouseDragged(MouseEvent e) {
            redispatchMouseEvent(e, false);
        public void mouseClicked(MouseEvent e) {
            redispatchMouseEvent(e, false);
        public void mouseEntered(MouseEvent e) {
            redispatchMouseEvent(e, false);
        public void mouseExited(MouseEvent e) {
            redispatchMouseEvent(e, false);
        public void mousePressed(MouseEvent e) {
            redispatchMouseEvent(e, false);
        public void mouseReleased(MouseEvent e) {
            redispatchMouseEvent(e, true);
        //A basic implementation of redispatching events.
        private void redispatchMouseEvent(MouseEvent e,
                                          boolean repaint) {
            Point glassPanePoint = e.getPoint();
            Container container = contentPane;
            Point containerPoint = SwingUtilities.convertPoint(
                                            glassPane,
                                            glassPanePoint,
                                            contentPane);
            if (containerPoint.y < 0) { //we're not in the content pane
                if (containerPoint.y + menuBar.getHeight() >= 0) {
                    //The mouse event is over the menu bar.
                    //Could handle specially.
                } else {
                    //The mouse event is over non-system window
                    //decorations, such as the ones provided by
                    //the Java look and feel.
                    //Could handle specially.
            } else {
                //The mouse event is probably over the content pane.
                //Find out exactly which component it's over. 
                Component component =
                    SwingUtilities.getDeepestComponentAt(
                                            container,
                                            containerPoint.x,
                                            containerPoint.y);
                if ((component != null)
                    && (component.equals(liveButton))) {
                    //Forward events over the check box.
                    Point componentPoint = SwingUtilities.convertPoint(
                                                glassPane,
                                                glassPanePoint,
                                                component);
                    component.dispatchEvent(new MouseEvent(component,
                                                         e.getID(),
                                                         e.getWhen(),
                                                         e.getModifiers(),
                                                         componentPoint.x,
                                                         componentPoint.y,
                                                         e.getClickCount(),
                                                         e.isPopupTrigger()));
            //Update the glass pane if requested.
            if (repaint) {
                glassPane.setPoint(glassPanePoint);
                glassPane.repaint();
    }which is the glasspanedemo from the swing tutorial
    url: java.sun.com/docs/books/tutorialJWS/uiswing/components/example-1dot4/GlassPaneDemo.jnlp - 1k
    how can i make the dots not to disapear after i click again,meaning when i activate the glass pane i want all the dots i pressed to b shown and my problem is that the repaint function delete the earlier points every time,
    thx.

    first 1 was a few days ago and i cant find it so sry,So I did waste my time by responding to your posting. Good to know, I won't waste my time by responding in the future.
    Learn how to use the forum properly and add all postings you create to your watch list automatically.
    I can find it. I just click on your userid for you most recent postings. Now how difficult is that?
    anyway it wasn't very helpfull since i didn't post any code there,You where given two suggestions. You should be replying stating whether they where helpfull or not (at least if you want help from me in the future).

  • 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

  • InternalFrame repaint problem, pls help

    I am develop my final year project which is a drawing tool using the Model-View-Controller with Observer and internalFrame. When more than one document is create in the program, the content of activated internalFrame can display properly, but the problem is that other internalFrame also repaint the content become to the activated internalFrame content.
    How can i make other inernalFrame repaint the content properly??
    public class Sketcher
    public static void main(String[] args)
    theApp = new Sketcher();
    theApp.init();
    public void init()
    window = new SketchFrame("Sketcher", this); // Create the app window
         window.setBounds(0,0,500,500);
    window.addWindowListener(new WindowHandler() // Add window listener
    // Handler for window closing event
    public void windowClosing(WindowEvent e)
    {  window.checkForSave();  };
    desktop = new JDesktopPane(); //a specialized layered pane
    createFrame();
    window.getContentPane().add(desktop, BorderLayout.CENTER);
    window.setVisible(true);
    // Return a reference to the application window
    public SketchFrame getWindow()
    return window;
    // Return a reference to the model
    public SketchModel getModel()
    return sketch;
    // Return a reference to the view
    public SketchView getView()
    return view;
    // Handler class for window events
    class WindowHandler extends WindowAdapter
    // Handler for window closing event
    public void windowClosing(WindowEvent e)
    // Code to be added here later...
    public void insertModel(SketchModel newSketch)
         MyInternalFrame frame2 = new MyInternalFrame();
         frame2.setVisible(true); //necessary as of kestrel
         sketch2 = new SketchModel(); // Create the model
         view2 = new SketchView(this); // Create the view
    sketch.addObserver((Observer)view2); // Add the view as observer
    sketch.addObserver((Observer)window); // Add the app window as observer
         JComponent c = (JComponent) frame2.getContentPane();
         c.add(view, BorderLayout.CENTER);
         desktop.add(frame2);
         try {
         frame2.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {}
    protected void createFrame() {
    MyInternalFrame frame = new MyInternalFrame();
         frame.setVisible(true); //necessary as of kestrel
         sketch = new SketchModel(); // Create the model
         view = new SketchView(this); // Create the view
              JComponent c = (JComponent) frame.getContentPane();
         sketch.addObserver((Observer)view); // Register the view with the model
         sketch.addObserver((Observer)window); // Register window as observer
    c.add(view, BorderLayout.CENTER);
    desktop.add(frame);
    try {
    frame.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {}
    JDesktopPane desktop;
    private JTextArea JtextArea;
    private SketchModel sketch, sketch2; // The data model for the sketch
    private SketchView view, view2; // The view of the sketch
    private static SketchFrame window; // The application window
    private static Sketcher theApp; // The application object

    You should call frame2.setVisible(true) after the addition of view in the contentPane of the frame :
    public void insertModel(SketchModel newSketch) {
       MyInternalFrame frame2 = new MyInternalFrame();
       sketch2 = new SketchModel(); // Create the model
       view2 = new SketchView(this); // Create the view
       sketch.addObserver((Observer)view2); // Add the view as observer
       sketch.addObserver((Observer)window); // Add the app window as observer
       JComponent c = (JComponent) frame2.getContentPane();
       c.add(view, BorderLayout.CENTER);
       desktop.add(frame2);
       try {
           frame2.setSelected(true);
       catch (java.beans.PropertyVetoException e) {}
       frame2.setVisible(true); //necessary as of kestrel
    }I hope this helps,
    Denis

  • Urgent!!  Problems muxing .m2v files and audio!! MPEG Streamclip/Compressor

    Hello!
    I am under an urgent deadline to upload a short 6 min documentary clip for a client to review for screening this week. The footage was shot in 1080/60i HDV.
    Usually, I find the best quality and fastest way to do this is to export directly from my FCP sequence using the '150 min Best Quality' DVD settings in compressor to get an .m2v video file and .ac3 audio file. Then I open the .m2v files in MPEG Streamclip which links it with my .ac3 file, then do 'Export MPEG with MP-2 audio". This gives me a single, muxed file that I can then upload to YouTube or Vimeo.
    However, with this project, when I open up my .m2v file in MPEG Streamclip, it's recognizing the .ac3 file and I can see the info for it in the MPEG Streamclip window, but when I play the file in MPEG Streamclip or mux it, I don't hear any audio. Furthermore, after about 5 seconds into the clip, the playhead will continue moving, but the video will freeze, then maybe pick up again later. The .m2v video will play back smoothly in VLC player or Quicktime player, but not in MPEG Streamclip.
    I've tried exporting different little sections of the timeline to see if maybe I had some corrupted footage or whatnot. I even exported a small clip from an older HDV project to test. But no matter where I export from, I am running into the same problem. I can bring the .m2v file and .ac3 file into DVD Studio Pro and burn a DVD with no problem, but I can't mux them. If I build the DVD file in DVD SP and try to open the .VOB file with MPEG Streamclip, I get the same problem. I even tried using a different software to mux (ffmpegX) but to no avail. When I try with ffmpegX, it either tells me I'm dropping frames, or if it works and it muxes it, when I open the MPEG file, it'll stutter at about 5 seconds in as well and I can't hear any audio, even though there is supposed to be audio in the muxed file.
    I think I might have updated my Quicktime a few days ago with the system update, and maybe updated a few other things, so I don't know if this has any bearing on the problems I'm running into. But I was able just a few days ago to export HDV 1080/60i using this workflow without any problems.
    I realize I have other export options, but this always seems to me to be the best quality and fastest way of doing it vs. encoding an H.264 which, on my machine is RIDICULOUSLY slow...I need to be uploading multiple versions of the cut to the client, and really need help! Thanks so much in advance!
    J

    what you want is an m2v program file. Export a reference copy from FCP (uncheck Make Movie Self Contained") That's very fast. Bring it into Compressor. In the settings panel find the MPEG-2 settings folder. Select Program Stream. Adjust to your liking and run. The audio and video will already be "muxed" when it's done and using compressor 3 you can set it to upload to YouTube, Mobile or similar sites.

  • Repainting problems of the Menu items in Oracle Help Navigator

    All,
    I am facing a strange problem when using Oracle Help for my application which is developed in Java,Swings.
    Whenever, I open Help for any component through my application, the menu items in the Help screen are not visible. They are not getting repainted. Only when user drags the mouse over the items, they are getting repainted and visible to the user. This has been raised as a bug by our testing people. I couldn't get any help in aspects of any errors/exceptions being logged when the action takes place.
    Where can I have the log files for Help window?
    Can anyone help me and guide me to the right solution in this regards.
    My environ is like this:
    Windows NT, JRE1.4, Oracle Help - ohj-jewt-4_1_16.jar,
    Thanks in advance for all.
    regards,
    Kishore.

    iweb2 navbar is rendered by javascript widget, therefore you can change navbar font style with javascript; this is an efficient way to change navbar font style.
    Copy and paste the following into your pages using HTML Snippet:
    <script type = 'text/javascript'>
    function changeNavbar() {
    navCSS = parent.document.getElementById('widget0-navbar');
    navCSS.style.fontSize = '0.75em'; // font size, change to less than 1em to change font smaller;
    navCSSbg = parent.document.getElementById('widget0-bg');
    navCSSbg.style.textAlign = 'center'; // navbar list alignment;
    clearInterval(chkNavbar);
    chkNavbar = setInterval('changeNavbar()', 500);
    note: You won't see the changes in iweb, but you will see the change when view the pages online - after publishing.

  • Printing JTable after turning off double buffering causing repaint problems

    I've followed all the instructions to speed up a print job in java by turning off double buffering temporarily by using the following call before calling paint() on the component...
    RepaintManager.currentManager(printTable).setDoubleBufferingEnabled(false);
    ... and then turning it back on afterwards...
    RepaintManager.currentManager(printTable).setDoubleBufferingEnabled(true);
    but the problem is that if it is a long print job, then the rest of the application (including other JTables) isn't repainting properly at all. I have the printing going on in a separate thread since I don't think it's acceptable UI practices to force the user to wait until a print job finishes before they can proceed with using their application. I've tried controlling the double buffering at the JPanel level as well, but it always affects the entire application until the print spooling is complete.
    Does anyone have any suggestions to solve this annoying SWING printing problem?
    Thanks,
    - Tony

    When you post code, make sure and put it between code
    tags, so it looks good:
    public static void main(String[] args) {
    System.out.println("Doesn't this look great?");
        public int print(Graphics g, PageFormat pf, int pageIndex) {
            System.out.println( "Calling print(g,pf,pageIndex) method" );
            int response = NO_SUCH_PAGE;
            Graphics2D g2 = (Graphics2D) g;
    // for faster printing, turn off double buffering
            disableDoubleBuffering(componentToBePrinted);
            Dimension d = componentToBePrinted.getSize(); //get size of document
            double panelWidth = d.width; //width in pixels
            double panelHeight = d.height; //height in pixels
            double pageHeight = pf.getImageableHeight(); //height of printer page
            double pageWidth = pf.getImageableWidth(); //width of printer page
            double scale = pageWidth / panelWidth;
            int totalNumPages = (int) Math.ceil(scale * panelHeight / pageHeight);
    // make sure not print empty pages
            if (pageIndex >= totalNumPages) {
                response = NO_SUCH_PAGE;
            } else {
    // shift Graphic to line up with beginning of print-imageable region
                g2.translate(pf.getImageableX(), pf.getImageableY());
    // shift Graphic to line up with beginning of next page to print
                g2.translate(0f, -pageIndex * pageHeight);
    // scale the page so the width fits...
                g2.scale(scale, scale);
                componentToBePrinted.paint(g2); //repaint the page for printing
                enableDoubleBuffering(componentToBePrinted);
                response = Printable.PAGE_EXISTS;
            return response;
        }

  • Very Urgent?Facing Problems With Labels

    Hi All,
    It's Very Urgent,In My VC Application
    Label Have More Than 15 Characters
    I PUT Label Layout  To Long Label.
    My Label Name  online assignement date
    But Even Put Long Label, online ***.......
    Please Resolve The Problem ASAP.
    Thanks
    SubbaRao Chinta

    Hi Subbu,
    I told u already its an Know issue with Flex compiler ,Even u set the label to long label it will show u only short label.
    This issue is fixed with Flex2 compiler.
    Use Flex2 compiler for ur application then it will dispaly the total label u want display.
    Regards,
    Govindu

  • Urgent Sql Query Problem - -Very Urgent

    Hi Guys,
    I need a urgent solution for a problem.I am
    using the following query
    select ename from emp where deptno =10
    Now I will declare a bind variable and if user passes 'A'
    then the query will run as it is and if he passes B
    then it should run the above query with this additional clause -> birthdate - hiredate >15.
    Please can any one help its very urgent

    Assuming that you have a birthdate column in your emp table, the following will do what you are asking for:
    VARIABLE bind_var VARCHAR2(1)
    EXECUTE :bind_var := '&bind_variable'
    SELECT ename FROM
    (SELECT 'A' AS selection, ename FROM emp WHERE deptno = 10
    UNION ALL
    SELECT 'B' AS selection, ename FROM emp WHERE deptno = 10 AND birthdate - hiredate > 15)
    WHERE selection = :bind_var
    However, the clause "birthdate - hiredate > 15" will only retrieve rows for employees who were born more than 15 days after they were hired. I doubt that this is what you really want, since this is impossible.

Maybe you are looking for

  • VLAN between SFE2000P switches

    Dear friends, I've connected two sites with the following configuration: Site 1: Stack Linksys SFE2000P - Firmware version 1.0.0.X Port 1/g3 connected to a FO link to site 2 Oficina 2: Stack Linksys SFE2000P - Firmware version 3.0.0.X Port 1/g3 conne

  • Playing videos on ipod photo

    I have saved videos on my ipod (60GB) but can not play them ; i tried mp4 and m4v... can anybody help?

  • Downloaded TV Show Episode Doesn't play. Requesting a Redownload.

    I purchased a Season Pass for Season 12 of Top Gear, and downloaded episode 6 with relish. When i eagerly clicked on the episode there was only a grey screen with the audio playing over it. I deleted it expecting iTunes to allow me to re download the

  • AD Radius 802.1x Login Window Connection Problems

    Mac Mini/10.10.1 I'm using two profile manager profiles for testing: 1. AD Certificate     Installs certificate for AD Certificate Authority.      Requests Machine Certificate from CA 2. Network Settings      Network Payload:           Interface WIFI

  • Is it possible to make animated buttons in iWeb'08?

    Hello folks, I am just wondering, is there any way to make buttons little bit interactive? Maybe like changing color on rollover?