Results 1 to 3 of 3
  1. #1
    miladirooni is offline Member
    Join Date
    Sep 2009
    Posts
    9
    Rep Power
    0

    Default jscrollpane and jdescktoppane

    hi guys,

    i have problems with adding the jscrollpane to jdesktoppanel, here is my code if any spot a mistake really appreciate it if u could send a reply

    many tanx

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    /*
    * NewJFrame2.java
    *
    * Created on 02-Nov-2009, 18:05:56
    */

    package Frames;

    /**
    *
    * @author qyt21516
    */
    public class NewJFrame2 extends javax.swing.JFrame {

    /** Creates new form NewJFrame2 */
    public NewJFrame2() {
    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() {

    jSplitPane1 = new javax.swing.JSplitPane();
    jPanel1 = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jDesktopPane1 = new javax.swing.JDesktopPane();
    jInternalFrame1 = new javax.swing.JInternalFrame();
    jInternalFrame2 = new javax.swing.JInternalFrame();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenu2 = new javax.swing.JMenu();

    setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGap(0, 100, Short.MAX_VALUE)
    );
    jPanel1Layout.setVerticalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGap(0, 255, Short.MAX_VALUE)
    );

    jSplitPane1.setLeftComponent(jPanel1);

    jInternalFrame1.setVisible(true);

    javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContent Pane());
    jInternalFrame1.getContentPane().setLayout(jIntern alFrame1Layout);
    jInternalFrame1Layout.setHorizontalGroup(
    jInternalFrame1Layout.createParallelGroup(javax.sw ing.GroupLayout.Alignment.LEADING)
    .addGap(0, 90, Short.MAX_VALUE)
    );
    jInternalFrame1Layout.setVerticalGroup(
    jInternalFrame1Layout.createParallelGroup(javax.sw ing.GroupLayout.Alignment.LEADING)
    .addGap(0, 75, Short.MAX_VALUE)
    );

    jInternalFrame1.setBounds(60, 50, 100, 110);
    jDesktopPane1.add(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER);

    jInternalFrame2.setVisible(true);

    javax.swing.GroupLayout jInternalFrame2Layout = new javax.swing.GroupLayout(jInternalFrame2.getContent Pane());
    jInternalFrame2.getContentPane().setLayout(jIntern alFrame2Layout);
    jInternalFrame2Layout.setHorizontalGroup(
    jInternalFrame2Layout.createParallelGroup(javax.sw ing.GroupLayout.Alignment.LEADING)
    .addGap(0, 80, Short.MAX_VALUE)
    );
    jInternalFrame2Layout.setVerticalGroup(
    jInternalFrame2Layout.createParallelGroup(javax.sw ing.GroupLayout.Alignment.LEADING)
    .addGap(0, 75, Short.MAX_VALUE)
    );

    jInternalFrame2.setBounds(170, 100, 90, 110);
    jDesktopPane1.add(jInternalFrame2, javax.swing.JLayeredPane.DEFAULT_LAYER);

    jScrollPane1.setViewportView(jDesktopPane1);

    jSplitPane1.setRightComponent(jScrollPane1);

    jMenu1.setText("File");
    jMenuBar1.add(jMenu1);

    jMenu2.setText("Edit");
    jMenuBar1.add(jMenu2);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
    .addContainerGap())
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE)
    .addContainerGap())
    );

    pack();
    }// </editor-fold>

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new NewJFrame2().setVisible(true);
    }
    });
    }

    // Variables declaration - do not modify
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JInternalFrame jInternalFrame1;
    private javax.swing.JInternalFrame jInternalFrame2;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSplitPane jSplitPane1;
    // End of variables declaration

    }

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,233
    Rep Power
    7

    Default

    Use the "Code" button when posting code so the code retains its original formatting.

    The basics should be:

    Java Code:
    JScrollPane scrollPane = new JScrollPane( desktopPane );
    frame.add( scrollPane );
    I never use IDE and am not about to try and debug the awfull generated GroupLayout code. Learn to create and code your GUI's by hand and don't rely on an IDE to generate the code.

  3. #3
    miladirooni is offline Member
    Join Date
    Sep 2009
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by camickr View Post
    Use the "Code" button when posting code so the code retains its original formatting.

    The basics should be:

    Java Code:
    JScrollPane scrollPane = new JScrollPane( desktopPane );
    frame.add( scrollPane );
    I never use IDE and am not about to try and debug the awfull generated GroupLayout code. Learn to create and code your GUI's by hand and don't rely on an IDE to generate the code.
    hi tanx for replying, but how can i add jscrollpane to the frame since in my class i have extended the jframe (frame.add(jscrollpane)).

Similar Threads

  1. JTextArea with JScrollPane
    By AndrewM16921 in forum AWT / Swing
    Replies: 8
    Last Post: 10-30-2009, 12:06 AM
  2. JScrollPane problem
    By KArelVH in forum AWT / Swing
    Replies: 6
    Last Post: 04-27-2009, 09:40 PM
  3. jscrollpane
    By kaemonsaionji in forum New To Java
    Replies: 3
    Last Post: 02-25-2009, 08:39 AM
  4. problem with Jscrollpane
    By ravrajesh.ap in forum AWT / Swing
    Replies: 5
    Last Post: 01-03-2009, 10:38 PM
  5. help with JScrollPane
    By tommy in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 07:58 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
  •