Results 1 to 6 of 6
  1. #1
    ki_ha1984 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    118
    Rep Power
    0

    Default Problem with adding dynamically JinternalFrame and dragging problem

    Hi,

    I have built the following application, with the Pallete of Netbeans.

    Problem with adding dynamically JinternalFrame and dragging problem-untitled-1.jpg

    Mainly i have a tabed panel with several tabs, but my problem is the most right tab "New ..", where i tray to add dynamically JinternalFrame.
    Actually like you can see in that tab inside of it i have a JScrollPanel inside of it i have JDesktoPanel and inside of it i have a JinternalFrane. All these components are created with the Palette of the netbeans.

    The first problem: i have enabled the dragMode(OUTINE_DRAG_MODE) of the JDesktopPanel but in order to drag the JInternalFrame, once i have to first minimized it and then i can drag it, else i can not. Any solution ?

    The Second Problem: By clicking the button with the red square and with the following code i try to add dynamically additional JInternalFrames, by having inside a JPanel and some components, but does not appear. Any solution ?

    Java Code:
    jDesktopPaneIn.revalidate();
    jScrollPaneIn.revalidate();
            
    JInternalFrame jf = new JInternalFrame("test",true,true,true,true);
            
    ChartPanel p = new ChartPanel(createChart(createDataset4In(jTextAreaInpIDs.getText(),jTextAreaInNames.getText())));
    
    p.setVisible(true);
    jf.add(p);
    jf.repaint();
    jDesktopPaneIn.add(jf);
    jDesktopPaneIn.repaint();
    jScrollPaneIn.repaint();
    I would appreciate if i have any solution.

    Thank you in advance

  2. #2
    ki_ha1984 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    118
    Rep Power
    0

    Default Re: Problem with adding dynamically JinternalFrame and dragging problem

    Any idea ?

  3. #3
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,995
    Rep Power
    9

    Default Re: Problem with adding dynamically JinternalFrame and dragging problem

    Some code that compiles, demonstrating the problem would be of great help
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  4. #4
    ki_ha1984 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    118
    Rep Power
    0

    Default Re: Problem with adding dynamically JinternalFrame and dragging problem

    ok, here is example of my code


    Java Code:
    import javax.swing.JInternalFrame;
    
    
    public class NewJFrame extends javax.swing.JFrame {
    
        /**
         * Creates new form NewJFrame
         */
        public NewJFrame() {
            initComponents();
        }
    
        /**
         * This method is called from within the constructor to initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is always
         * regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
    
            jTabbedPane1 = new javax.swing.JTabbedPane();
            jScrollPane1 = new javax.swing.JScrollPane();
            jScrollPane3 = new javax.swing.JScrollPane();
            jDesktopPane1 = new javax.swing.JDesktopPane();
            jInternalFrame1 = new javax.swing.JInternalFrame();
            jButton1 = new javax.swing.JButton();
    
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    
            jTabbedPane1.addTab("tab1", jScrollPane1);
    
            jDesktopPane1.setDragMode(javax.swing.JDesktopPane.OUTLINE_DRAG_MODE);
    
            jInternalFrame1.setIconifiable(true);
            jInternalFrame1.setVisible(true);
    
            jButton1.setText("jButton1");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });
    
            javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
            jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
            jInternalFrame1Layout.setHorizontalGroup(
                jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jInternalFrame1Layout.createSequentialGroup()
                    .addGap(57, 57, 57)
                    .addComponent(jButton1)
                    .addContainerGap(191, Short.MAX_VALUE))
            );
            jInternalFrame1Layout.setVerticalGroup(
                jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jInternalFrame1Layout.createSequentialGroup()
                    .addContainerGap(197, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addGap(46, 46, 46))
            );
    
            javax.swing.GroupLayout jDesktopPane1Layout = new javax.swing.GroupLayout(jDesktopPane1);
            jDesktopPane1.setLayout(jDesktopPane1Layout);
            jDesktopPane1Layout.setHorizontalGroup(
                jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jDesktopPane1Layout.createSequentialGroup()
                    .addGap(81, 81, 81)
                    .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(397, Short.MAX_VALUE))
            );
            jDesktopPane1Layout.setVerticalGroup(
                jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jDesktopPane1Layout.createSequentialGroup()
                    .addGap(104, 104, 104)
                    .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(243, Short.MAX_VALUE))
            );
            jDesktopPane1.setLayer(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER);
    
            jScrollPane3.setViewportView(jDesktopPane1);
    
            jTabbedPane1.addTab("tab2", jScrollPane3);
    
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(102, 102, 102)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 872, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(17, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(77, 77, 77)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 715, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(64, Short.MAX_VALUE))
            );
    
            pack();
        }// </editor-fold>                        
    
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            // TODO add your handling code here:
            
             JInternalFrame jf = new JInternalFrame("Test",true,true,true,true);
             jf.setSize(500, 500);
             jDesktopPane1.add(jf);
             jDesktopPane1.revalidate();
            jDesktopPane1.validate();
            jDesktopPane1.setVisible(true);
            jScrollPane1.revalidate();
            jDesktopPane1.repaint();
        }                                        
    
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
             */
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            //</editor-fold>
    
            /* Create and display the form */
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new NewJFrame().setVisible(true);
                }
            });
        }
    
        // Variables declaration - do not modify                     
        private javax.swing.JButton jButton1;
        public static javax.swing.JDesktopPane jDesktopPane1;
        private javax.swing.JInternalFrame jInternalFrame1;
        private javax.swing.JScrollPane jScrollPane1;
        public static javax.swing.JScrollPane jScrollPane3;
        private javax.swing.JTabbedPane jTabbedPane1;
        // End of variables declaration                   
    }

  5. #5
    ki_ha1984 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    118
    Rep Power
    0

    Default Re: Problem with adding dynamically JinternalFrame and dragging problem

    ok, i find a solution for the appearance of the new jinternalframe.
    it should be added this

    jf.show();

    But for the dragging i stιλl have the problem.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Problem with adding dynamically JinternalFrame and dragging problem

    I really, really, really don't recommend using the GUI builder...
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Multiple instance jinternalframe problem
    By gghgc in forum AWT / Swing
    Replies: 3
    Last Post: 06-20-2014, 02:54 AM
  2. Replies: 1
    Last Post: 11-30-2011, 08:24 AM
  3. Replies: 4
    Last Post: 09-27-2011, 09:20 AM
  4. Problem with JTable inside JInternalFrame
    By JerryAgin in forum AWT / Swing
    Replies: 2
    Last Post: 01-21-2011, 05:44 PM
  5. Problem with JInternalFrame
    By hameem in forum AWT / Swing
    Replies: 1
    Last Post: 12-11-2008, 04:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •