Adding a jPane to a jScrollPane

i have a mainframe with 3 scrollpanes 1 scroll pane for diff stuff..

i have another class call TestPane which contains some stuffies,

so in my button, i did

TestPane tp =new TestPane();

jScrollPane1.setViewPortView(tp);

jScrollPane1.validate();

however my testpane doesnt show up in the scroll pane in my main application, can anyone tell me why?

[424 byte] By [Alandera] at [2007-11-27 1:56:47]
# 1
What are you expecting to see? The panel is empty, and therefore takes up no space.
TimRyanNZa at 2007-7-12 1:31:35 > top of Java-index,Desktop,Core GUI APIs...
# 2

my jPane has stuff in it, its just that i didnt post my jPane codes here

/*

* ParsePanel.java

*

* Created on April 23, 2007, 11:53 AM

*/

package org.nyp.eai.gui;

/**

* @author 054094f <3 052613h

*/

public class ParsePanel extends javax.swing.JPanel {

/** Creates new form ParsePanel */

public ParsePanel() {

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.

*/

// <editor-fold defaultstate="collapsed" desc=" Generated Code ">

private void initComponents() {

recordList = new javax.swing.JList();

tabbedFileViewer = new javax.swing.JTabbedPane();

jScrollPane1 = new javax.swing.JScrollPane();

txtAreaSource = new javax.swing.JTextArea();

cboEndRec = new javax.swing.JComboBox();

jLabel2 = new javax.swing.JLabel();

jLabel1 = new javax.swing.JLabel();

cboDel = new javax.swing.JComboBox();

chkHeader = new javax.swing.JCheckBox();

jLabel3 = new javax.swing.JLabel();

jTextField1 = new javax.swing.JTextField();

jPanel1 = new javax.swing.JPanel();

btnParse = new javax.swing.JButton();

btnIgnoreRec = new javax.swing.JButton();

btnConfirm = new javax.swing.JButton();

tabbedFileViewer.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);

tabbedFileViewer.setAutoscrolls(true);

tabbedFileViewer.setFont(new java.awt.Font("Tahoma", 1, 12));

txtAreaSource.setColumns(20);

txtAreaSource.setRows(5);

jScrollPane1.setViewportView(txtAreaSource);

tabbedFileViewer.addTab("Source File", jScrollPane1);

cboEndRec.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Line Separator", "//", "/", "-", ",", ".", "|", "Tab Separator", ";", ":" }));

jLabel2.setText("End Of Record Indicator:");

jLabel1.setText("Select Delimiter:");

cboDel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { ",", "/", "-", ".", "|", "Tab Seperator", ":", ";" }));

chkHeader.setText("Header Present");

chkHeader.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));

chkHeader.setMargin(new java.awt.Insets(0, 0, 0, 0));

jLabel3.setText("Line Of Header:");

btnParse.setText("Parse");

btnIgnoreRec.setText("Ignore Record");

btnConfirm.setText("Preview Output");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(btnParse, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)

.addComponent(btnIgnoreRec, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)

.addComponent(btnConfirm, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addContainerGap())

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addComponent(btnParse, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(btnIgnoreRec)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(btnConfirm)

.addContainerGap())

);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);

this.setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addComponent(recordList, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(tabbedFileViewer, javax.swing.GroupLayout.DEFAULT_SIZE, 539, Short.MAX_VALUE))

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(cboEndRec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(cboDel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addComponent(jLabel3)

.addComponent(chkHeader))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 253, Short.MAX_VALUE)

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addGap(26, 26, 26))

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(recordList, javax.swing.GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE)

.addComponent(tabbedFileViewer, javax.swing.GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE))

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(12, 12, 12)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 22, Short.MAX_VALUE)

.addComponent(cboDel))

.addGap(12, 12, 12)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(cboEndRec))

.addGap(12, 12, 12)

.addComponent(chkHeader)

.addGap(12, 12, 12)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel3)

.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addGroup(layout.createSequentialGroup()

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addContainerGap())

);

}// </editor-fold>

// Variables declaration - do not modify

private javax.swing.JButton btnConfirm;

private javax.swing.JButton btnIgnoreRec;

private javax.swing.JButton btnParse;

private javax.swing.JComboBox cboDel;

private javax.swing.JComboBox cboEndRec;

private javax.swing.JCheckBox chkHeader;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JPanel jPanel1;

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JTextField jTextField1;

private javax.swing.JList recordList;

private javax.swing.JTabbedPane tabbedFileViewer;

private javax.swing.JTextArea txtAreaSource;

// End of variables declaration

}

this is my jPane codes, i suppose it got nth to do with adding it into the jScrollPane

and so i got a button on my main frame,

private void jMuParsingActionPerformed(java.awt.event.ActionEvent evt) {

ParsePanel p = new ParsePanel();

jScrollPane1.setViewPortView(p);

jScrollPane1.Validate();

}

Alandera at 2007-7-12 1:31:35 > top of Java-index,Desktop,Core GUI APIs...
# 3
Blimey - well maybe the best thing to do is to try displaying the panel directly in a JFrame and see if that works okay.Once you've proved the panel has visible content then go back to putting it into a JScrollPane.
TimRyanNZa at 2007-7-12 1:31:35 > top of Java-index,Desktop,Core GUI APIs...
# 4
the panel has no visible content x.x how do i show the contents i created =s
Alandera at 2007-7-12 1:31:35 > top of Java-index,Desktop,Core GUI APIs...
# 5
nvm i realised i have to setbounds for the pane to show out all its content, ty for the help
Alandera at 2007-7-12 1:31:36 > top of Java-index,Desktop,Core GUI APIs...