Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-02-2009, 07:52 PM
Member
 
Join Date: Sep 2009
Posts: 9
Rep Power: 0
miladirooni is on a distinguished road
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

}
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-02-2009, 08:52 PM
Senior Member
 
Join Date: Jul 2009
Posts: 293
Rep Power: 1
camickr is on a distinguished road
Default
Use the "Code" button when posting code so the code retains its original formatting.

The basics should be:

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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-03-2009, 10:42 AM
Member
 
Join Date: Sep 2009
Posts: 9
Rep Power: 0
miladirooni is on a distinguished road
Default
Originally Posted by camickr View Post
Use the "Code" button when posting code so the code retains its original formatting.

The basics should be:

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)).
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] JTextArea with JScrollPane AndrewM16921 AWT / Swing 8 10-30-2009 01:06 AM
JScrollPane problem KArelVH AWT / Swing 6 04-27-2009 10:40 PM
jscrollpane kaemonsaionji New To Java 3 02-25-2009 09:39 AM
problem with Jscrollpane ravrajesh.ap AWT / Swing 5 01-03-2009 11:38 PM
help with JScrollPane tommy AWT / Swing 1 08-06-2007 08:58 PM


All times are GMT +2. The time now is 04:51 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org