Scrollbar on JTabbedPane

Hello friends,
Below is the code which i created in NetBeans.
I want to make this page scrollable since its text are too big. but scroll bars are not coming. need ur guidance.
* PDV_GUI.java
package pdv_gui;
* @author Rehmatullah
public class PDV_GUI extends javax.swing.JFrame {
/** Creates new form PDV_GUI */
public PDV_GUI() {
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() {
jTabbedPane1 = new javax.swing.JTabbedPane();
jTabbedPane1.setAutoscrolls(true);
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jTextField5 = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jTextField6 = new javax.swing.JTextField();
jTextField7 = new javax.swing.JTextField();
jComboBox1 = new javax.swing.JComboBox();
jComboBox2 = new javax.swing.JComboBox();
jComboBox3 = new javax.swing.JComboBox();
jLabel10 = new javax.swing.JLabel();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jLabel11 = new javax.swing.JLabel();
jTextField8 = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
jTextField9 = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jTextField10 = new javax.swing.JTextField();
jTextField11 = new javax.swing.JTextField();
jTextField12 = new javax.swing.JTextField();
jTextField13 = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTabbedPane1.setFont(new java.awt.Font("Arial", 0, 36));
jTabbedPane1.setName("Info");
jLabel1.setFont(new java.awt.Font("Arial", 0, 36));
jLabel1.setText("Title");
jLabel2.setFont(new java.awt.Font("Arial", 0, 36));
jLabel2.setText("ID");
jLabel3.setFont(new java.awt.Font("Arial", 0, 36));
jLabel3.setText("First Name");
jLabel4.setFont(new java.awt.Font("Arial", 0, 36));
jLabel4.setText("Last Name");
jLabel5.setFont(new java.awt.Font("Arial", 0, 36));
jLabel5.setText("Address");
jTextField1.setFont(new java.awt.Font("Arial", 0, 36));
jTextField1.setText("jTextField1");
jTextField2.setFont(new java.awt.Font("Arial", 0, 36));
jTextField2.setText("jTextField2");
jTextField3.setFont(new java.awt.Font("Arial", 0, 36));
jTextField3.setText("jTextField3");
jTextField4.setFont(new java.awt.Font("Arial", 0, 36));
jTextField4.setText("jTextField4");
jTextField4.setMaximumSize(new java.awt.Dimension(100, 100));
jTextField4.setMinimumSize(new java.awt.Dimension(100, 100));
jLabel6.setFont(new java.awt.Font("Arial", 0, 36));
jLabel6.setText("Phone");
jTextField5.setFont(new java.awt.Font("Arial", 0, 36));
jTextField5.setText("jTextField5");
jLabel7.setFont(new java.awt.Font("Arial", 0, 36));
jLabel7.setText("Fax");
jLabel8.setFont(new java.awt.Font("Arial", 0, 36));
jLabel8.setText("Email");
jLabel9.setFont(new java.awt.Font("Arial", 0, 36));
jLabel9.setText("Birth Date");
jTextField6.setFont(new java.awt.Font("Arial", 0, 36));
jTextField6.setText("jTextField6");
jTextField7.setFont(new java.awt.Font("Arial", 0, 36));
jTextField7.setText("jTextField7");
jComboBox1.setFont(new java.awt.Font("Arial", 0, 36));
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "23" }));
jComboBox2.setFont(new java.awt.Font("Arial", 0, 36));
jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }));
jComboBox3.setFont(new java.awt.Font("Arial", 0, 36));
jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1990", "2007" }));
jLabel10.setFont(new java.awt.Font("Arial", 0, 36));
jLabel10.setText("Sex");
jRadioButton1.setFont(new java.awt.Font("Arial", 0, 36));
jRadioButton1.setText("Male");
jRadioButton1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jRadioButton1.setMargin(new java.awt.Insets(0, 0, 0, 0));
jRadioButton2.setFont(new java.awt.Font("Arial", 0, 36));
jRadioButton2.setText("Female");
jRadioButton2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jRadioButton2.setMargin(new java.awt.Insets(0, 0, 0, 0));
jLabel11.setFont(new java.awt.Font("Arial", 0, 36));
jLabel11.setText("Height");
jTextField8.setFont(new java.awt.Font("Arial", 0, 36));
jTextField8.setText("jTextField8");
jLabel12.setFont(new java.awt.Font("Arial", 0, 36));
jLabel12.setText("Weight");
jTextField9.setFont(new java.awt.Font("Arial", 0, 36));
jTextField9.setText("jTextField9");
jLabel13.setFont(new java.awt.Font("Arial", 0, 36));
jLabel13.setText("Blood Type");
jLabel14.setFont(new java.awt.Font("Arial", 0, 36));
jLabel14.setText("Blood Donor");
jLabel15.setFont(new java.awt.Font("Arial", 0, 36));
jLabel15.setText("Organ Donor");
jLabel16.setFont(new java.awt.Font("Arial", 0, 36));
jLabel16.setText("Medulla Donor");
jTextField10.setFont(new java.awt.Font("Arial", 0, 36));
jTextField10.setText("jTextField10");
jTextField11.setFont(new java.awt.Font("Arial", 0, 36));
jTextField11.setText("jTextField11");
jTextField12.setFont(new java.awt.Font("Arial", 0, 36));
jTextField12.setText("jTextField12");
jTextField13.setFont(new java.awt.Font("Arial", 0, 36));
jTextField13.setText("jTextField13");
jTextPane1.setFont(new java.awt.Font("Arial", 0, 24));
jScrollPane1.setViewportView(jTextPane1);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1.setAutoscrolls(true);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel5)
.addComponent(jLabel7)
.addComponent(jLabel8)
.addComponent(jLabel9)
.addComponent(jLabel10)
.addComponent(jLabel11)
.addComponent(jLabel13)
.addComponent(jLabel14)
.addComponent(jLabel15)
.addComponent(jLabel3)
.addComponent(jLabel16)
.addComponent(jLabel6))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(38, 38, 38)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(16, 16, 16)
.addComponent(jLabel12)
.addGap(15, 15, 15)
.addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jRadioButton1)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(15, 15, 15)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jRadioButton2))))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextField7, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField6, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField5, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField2, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField3, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE)))))))
.addContainerGap(112, Short.MAX_VALUE))
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(25, 25, 25)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(15, 15, 15)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(17, 17, 17)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(19, 19, 19)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(jRadioButton1)
.addComponent(jRadioButton2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12)
.addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel13)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel14)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel15)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel16))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
jTabbedPane1.addTab("INFORMATION", jPanel1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1031, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
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 PDV_GUI().setVisible(true);
// Variables declaration - do not modify
private javax.swing.JComboBox jComboBox1;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JComboBox jComboBox3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField10;
private javax.swing.JTextField jTextField11;
private javax.swing.JTextField jTextField12;
private javax.swing.JTextField jTextField13;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField jTextField7;
private javax.swing.JTextField jTextField8;
private javax.swing.JTextField jTextField9;
private javax.swing.JTextPane jTextPane1;
// End of variables declaration
}

Hi Grueneklee
u r right, i can assign. but its only for that datablock. i have more than one datablocks on one tab page and all the datablock are not viewable within the current window size. so i need to scroll down.
thanks

Similar Messages

  • Need Help with scrollbars

    hu..
    i have this JFrane that has a table which has scrollbars...
    i have included in my code setResizable(false) so the user will not be able to maximize the page..
    i have a function AdScroll()[that adds scrollbars] that will be called every time i add ,delete ,update a user ..
    my problem is when i click on the delete and update buttons the user will not be deleted or updated from the table, but when i remove AddScroll() the user will be deleted and updated from the table but the scroll bars will not be added..
    so can some one help me with this problem.
    thankx
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.sql.*;
    import java.io.*;
    import javax.swing.JPanel;
    import java.applet.*;
    import sun.audio.*;
    import java.net.*;
    import java.text.*;
    class UtilityMethods extends JFrame implements ActionListener
      private boolean tabsVisible=false;
      private File fileName;
      private RandomAccessFile output;
      AudioStream voice;
      UtilityMethods utilities;
      Connection conn;
      Statement stat;
      String dsnName, userStatus;
      String appTable = "CUSTOMER";
      Container c = getContentPane();
       JTabbedPane tabs;
        //JScrollPane scrollpane;
      JTable dataTable, addataTable;
      static String[][] tableData, adtableData;
      JScrollPane scrollpane, adscrollpane,vscrollpane;
      JTextField id, name, address, phone, sex, dob, photo,audio,template;
      JTextArea comments;
      JButton search, update, clear, add, delete, close,audio1,faceBrowse,voiceBrowse,voice1;
      JPanel customerPanel, adminPanel;
      JPanel backPanel, inputPanel, middlePanel, buttonPanel1, buttonPanel2, photoHolder;
      JTextField adname, adusername, adpassword;
      JPanel adbackPanel, adinputPanel, admiddlePanel, adbuttonPanel1, adbuttonPanel2, radioPanel;
      JButton adsearch, adupdate, adclear, adadd, addelete, adclose;
      JRadioButton userStat, adminStat, cleared;
      ButtonGroup statusGroup;
      //===================================================================================================
      /*public UtilityMethods()
        makeGUI();
      //Create the GUI:
      void makeGUI()
        c.setLayout(new BorderLayout());
        tabs = new JTabbedPane();
        customerPanel = new JPanel(new BorderLayout());
        adminPanel = new JPanel(new BorderLayout());
    //    voicePanel= new JPanel(new BorderLayout());
        //1. Construct customers tab:
          //The data input section:
        inputPanel      = new JPanel(new GridLayout(4, 4));
         id = new JTextField(20);
                 name = new JTextField(20);
                 address = new JTextField(20);
                 phone = new JTextField(20);
                 sex = new JTextField(20);
                 dob = new JTextField(20);
                 photo = new JTextField(20);
                 audio = new JTextField(20);
                 template = new JTextField(20);
                 faceBrowse = new JButton("...");
                 faceBrowse.setBounds(210, 150, 25, 25);
        inputPanel.add(new JLabel("CPR", JLabel.CENTER));
        inputPanel.add(id);
        inputPanel.add(new JLabel("Name", JLabel.CENTER));
        inputPanel.add(name);
        inputPanel.add(new JLabel("Address", JLabel.CENTER));
        inputPanel.add(address);
        inputPanel.add(new JLabel("Phone", JLabel.CENTER));
        inputPanel.add(phone);
        inputPanel.add(new JLabel("Sex", JLabel.CENTER));
        inputPanel.add(sex);
        inputPanel.add(new JLabel("Date Of Birth", JLabel.CENTER));
        inputPanel.add(dob);
        inputPanel.add(new JLabel("Customer Photo ", JLabel.CENTER));
        inputPanel.add(photo);
        inputPanel.add(new JLabel("Voice ", JLabel.CENTER));
        inputPanel.add(audio);
    customerPanel.add(inputPanel, BorderLayout.NORTH);
          //The buttons section:
        backPanel = new JPanel();
        middlePanel = new JPanel(new BorderLayout());
        buttonPanel1 = new JPanel();
        buttonPanel2 = new JPanel();
        search   = new JButton("SEARCH");
        update   = new JButton("UPDATE");
        clear    = new JButton("CLEAR");
        add      = new JButton("ADD");
        delete   = new JButton("DELETE");
        close    = new JButton("EXIT");
        audio1    =new JButton("Voice");
        //faceBrowse    = new JButton("...");
        //voiceBrowse    =new JButton("...");
        search.setPreferredSize(new Dimension(102, 26));
        update.setPreferredSize(new Dimension(102, 26));
        clear.setPreferredSize(new Dimension(102, 26));
        add.setPreferredSize(new Dimension(102, 26));
        delete.setPreferredSize(new Dimension(102, 26));
        close.setPreferredSize(new Dimension(102, 26));
        audio1.setPreferredSize(new Dimension(102, 26));
        faceBrowse.setPreferredSize(new Dimension(26, 26));
        //voiceBrowse.setPreferredSize(new Dimension(26, 26));
        search.addActionListener(this);
        update.addActionListener(this);
        clear.addActionListener(this);
        add.addActionListener(this);
        delete.addActionListener(this);
        close.addActionListener(this);
        audio1.addActionListener(this);
        //faceBrowse.addActionListener(this);
        //voiceBrowse.addActionListener(this);
        buttonPanel1.add(search);
        //buttonPanel1.add(faceBrowse);
        buttonPanel1.add(update);
        buttonPanel1.add(clear);
        buttonPanel2.add(add);
        buttonPanel2.add(delete);
        buttonPanel2.add(close);
        buttonPanel2.add(audio1);
        //buttonPanel1.add(voiceBrowse);
        middlePanel.add(buttonPanel1, BorderLayout.NORTH);
        middlePanel.add(buttonPanel2, BorderLayout.CENTER);
        photoHolder = new JPanel();
        Icon curPhoto = new ImageIcon("");
        Icon[] custPhotos = {curPhoto};
        JList photosList = new JList(custPhotos);
        photosList.setFixedCellHeight(100);
        photosList.setFixedCellWidth(80);
        photoHolder.add(photosList);
        makeComments();
        backPanel.add(middlePanel);
        backPanel.add(photoHolder);
        backPanel.add(comments);
        customerPanel.add(backPanel, BorderLayout.CENTER);
      pack();
        setVisible(true);
        setSize(500,700);
      } //makeGUI
    void updateTable()
          ResultSet results = null;
          ResultSet results1 = null;
          try
            //Get the number of rows in the table so we know how big to make the data array..
            int rowNumbers  = 0;
            int columnCount = 6;
            results = stat.executeQuery("SELECT COUNT(*) FROM CUSTOMER ");
            if(results.next())
              rowNumbers = results.getInt(1);
            } //if
            if(rowNumbers == 0)
            rowNumbers = 1;
            tableData = new String[rowNumbers][columnCount];
            //Initialize the data array with "" so we avoid possibly having nulls in it later..
            for(int i =0;i<tableData.length;i++)
              for(int j=0;j<tableData[0].length;j++)
              tableData[i][j] = "";
            //Populate the data array with results of the query on the database..
            int currentRow = 0;
            results1 = stat.executeQuery("SELECT * FROM CUSTOMER ORDER BY ID");
            while (results1.next())
              for(int i = 0; i < columnCount; i++)
              tableData[currentRow] = results1.getString(i + 1);
    currentRow++;
    } //while
    //Create the table model:
    final String[] colName = { "CPR", "Name", "Address", "Phone", "Sex", "Date OF Birth" };
    TableModel pageModel = new AbstractTableModel()
    public int getColumnCount()
    return tableData[0].length;
    } //getColumnCount
    public int getRowCount()
    return tableData.length;
    } //getRowCount
    public Object getValueAt(int row, int col)
    return tableData[row][col];
    } //getValueAt
    public String getColumnName(int column)
    return colName[column];
    } //getcolName
    public Class getColumnClass(int col)
    return getValueAt(0, col).getClass();
    } //getColumnClass
    public boolean isCellEditable(int row, int col)
    return false;
    } //isCellEditable
    public void setValueAt(String aValue, int row, int column)
    tableData[row][column] = aValue;
    } //setValueAt
    //dataTable.setValue( new JScrollBar(JScrollBar.HORIZONTAL), 2,1 );
    }; //pageModel
    //Create the JTable from the table model:
    JTable dataTable = new JTable(pageModel);
    // dataTable.setModel();
    /*if (scrollpane != null)
    scrollpane.setVisible(false);
    scrollpane = null;
    } //if*/
    //scrollpane = new JScrollPane(dataTable);
    //scrollpane.setVisible(true);
    if (inputPanel == null)
    makeGUI();
    JScrollPane scrollpane =new JScrollPane(dataTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    // Create vertical box for second tab
    Box box = Box.createVerticalBox();
    // Create component for top
    box.add(customerPanel);
    // Place glue between components
    box.add(Box.createVerticalGlue());
    // Create component for middle
    box.add(middlePanel);
    // Place glue between components
    box.add(Box.createVerticalGlue());
    // Create component for middle
    box.add(backPanel);
    // Place glue between components
    box.add(Box.createVerticalGlue());
    // Create component for bottom
    box.add(scrollpane);
    // Add box to JTabbedPane
    tabs.add(box, "Customer");
              setResizable(false);
    id.grabFocus();
    pack();
    repaint();
    adupdateTable();
    } //try
    catch (Exception e)
    System.out.println("Caught updateTable exception: " + e);
    e.printStackTrace();
    } //catch
    } //updatetable
    //===================================================================================================
    //===================================================================================================
    //Update the customer table from the database:
    void updateTable(String userStatus)
    this.userStatus = userStatus;
         updateTable();
         if(userStatus.equals("user"))
         delete.setEnabled(false);
         tabs.setEnabledAt(1, false);
    public void actionPerformed(ActionEvent e)
    FileInputStream fis = null;
    if (e.getSource() == add) //The ADD button.
    //User has not populated all the input fields.
    if(name.getText().equals("")|| address.getText().equals("")|| phone.getText().equals("")|| sex.getText().equals("")|| dob.getText().equals("")|| photo.getText().equals(""))
    JOptionPane.showMessageDialog(null, "Please fill in all the fields","Missing Fields",JOptionPane.INFORMATION_MESSAGE);
    else
    // save the new customer:
    try
    //1. take the customer's data and photo:
    int userId          = Integer.parseInt(id.getText());
    String userName      = name.getText();
    String userAddress      = address.getText();
    String userPhone      = phone.getText();
    String userSex      = sex.getText();
    String userDateBirth      = dob.getText();
    String photoName      = photo.getText();
    String audioName= audio.getText();
    File file           = new File(photoName);
    int fileLength      = (int)file.length();
    //2. Set the user's photo into the photoHolder:
    photoHolder.setVisible(false);
    photoHolder = null;
    comments.setVisible(false);
    comments = null;
    Icon[] custPhotos = {new ImageIcon(photoName)};
    JList photosList = new JList(custPhotos);
    photosList.setFixedCellHeight(100);
    photosList.setFixedCellWidth(80);
    photoHolder = new JPanel();
    photoHolder.add(photosList);
    makeComments();
    //3. Insert the data and photo into the database:
    if(fileLength > 0)
    fis = new FileInputStream(file);
    String query = " INSERT INTO CUSTOMER VALUES('"+userId+"', '"+ userName+ "', '"+ userAddress+ "', " +" '"+ userPhone+ "', '"+ userSex+ "', '"+ userDateBirth+ "', ?,?,? ) ";
    PreparedStatement pstmt = conn.prepareStatement(query);
    pstmt.setBinaryStream(1, fis, fileLength);
              pstmt.setString(2,photoName);
              pstmt.setString(3,audioName);
    pstmt.executeUpdate();
    comments.setText(userName+", added.");
    else
    String query = " INSERT INTO CUSTOMER (id, name, address, phone, sex, dob) VALUES('"+userId+"', '"+userName+"', '"+userAddress+"', '"+userPhone+"', '"+userSex+"', '"+userDateBirth+"') ";
    stat.executeUpdate(query);
    comments.setText("Customer saved without a photo.");
    backPanel.add(photoHolder);
    backPanel.add(comments);
    //updateTable();
    AddScroll();
    } //try
    catch (Exception ee)
    //The danger of putting creating the JOptionPane in here is that it will show the same message regardless of the error.
              JOptionPane.showMessageDialog(null, "Customers CPR already exits!!Please enter another CPR","Invalid",JOptionPane.INFORMATION_MESSAGE);
    System.out.println("Caught exception in add action: " + ee);
    } //catch
    } //if
    }//add button
    void AddScroll()
         JScrollPane scrollpane =new JScrollPane(dataTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollpane.getViewport().add(dataTable);

    hi i tryed the JTable.revalidate() but i still did't work...
    i did this :
    public void actionPerformed(ActionEvent e)
        FileInputStream fis = null;
        if (e.getSource() == add) //The ADD button.
          //User has not populated all the input fields.
          if(name.getText().equals("")|| address.getText().equals("")|| phone.getText().equals("")|| sex.getText().equals("")|| dob.getText().equals("")|| photo.getText().equals(""))
            JOptionPane.showMessageDialog(null, "Please fill in all the fields","Missing Fields",JOptionPane.INFORMATION_MESSAGE);
          else
            // save the new customer:
            try
              //1. take the customer's data and photo:
              int    userId          = Integer.parseInt(id.getText());
              String userName      = name.getText();
              String userAddress      = address.getText();
              String userPhone      = phone.getText();
              String userSex      = sex.getText();
              String userDateBirth      = dob.getText();
              String photoName      = photo.getText();
              String audioName=   audio.getText();
              File   file           = new File(photoName);
              int    fileLength      = (int)file.length();
              //2. Set the user's photo into the photoHolder:
              photoHolder.setVisible(false);
              photoHolder = null;
              comments.setVisible(false);
              comments = null;
              Icon[] custPhotos = {new ImageIcon(photoName)};
              JList photosList = new JList(custPhotos);
              photosList.setFixedCellHeight(100);
              photosList.setFixedCellWidth(80);
              photoHolder = new JPanel();
              photoHolder.add(photosList);
              makeComments();
              //3. Insert the data and photo into the database:
              if(fileLength > 0)
                fis = new FileInputStream(file);
                String query = " INSERT INTO CUSTOMER VALUES('"+userId+"', '"+ userName+ "', '"+ userAddress+ "', " +" '"+ userPhone+ "', '"+ userSex+ "', '"+ userDateBirth+ "', ?,?,? ) ";
                PreparedStatement pstmt = conn.prepareStatement(query);
                pstmt.setBinaryStream(1, fis, fileLength);
                  pstmt.setString(2,photoName);
                  pstmt.setString(3,audioName);
                pstmt.executeUpdate();
                comments.setText(userName+", added.");
              else
                String query = " INSERT INTO CUSTOMER (id, name, address, phone, sex, dob) VALUES('"+userId+"', '"+userName+"', '"+userAddress+"', '"+userPhone+"', '"+userSex+"', '"+userDateBirth+"') ";
                stat.executeUpdate(query);
                comments.setText("Customer saved without a photo.");
              backPanel.add(photoHolder);
              backPanel.add(comments);
              //updateTable();
              dataTable.revalidate();
               AddScroll();
            } //try
            catch (Exception ee)
               //The danger of putting creating the JOptionPane in here is that it will show the same message regardless of the error.
                JOptionPane.showMessageDialog(null, "Customers CPR already exits!!Please enter another CPR","Invalid",JOptionPane.INFORMATION_MESSAGE);
              System.out.println("Caught exception in add action: " + ee);
                ee.printStackTrace();
            } //catch
          } //if
        }//add buttonand i included this function AddScroll() that i will add the scroll bars :
    void AddScroll()
          JScrollPane scrollpane =new JScrollPane(dataTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollpane.getViewport().add(dataTable);
    // AbstractTableModel pageModel  = (AbstractTableModel)dataTable.getModel();
    //            pageModel .fireTableDataChanged();
    //dataTable.updateUI();
    }thankx

  • Thumbnail view of  tabs in JTabbedPane

    Hi all,
    I am doing a desktop app . In my app i am using JTabbedPane . In order to view the contents of all tabs in one shot,i need to bring the JPanel in each tab into a single frame,that contains a scrollbar.i.e,something like a thumbnail view of all the tabs.Is it possible to do so? Since i have several components like button, textbox,images,etc in each tab,and have set the layout property of the panel to null,i cannot reduce the size of the panel to thumbnail size.I have set layout property of jpanel in each tab to null,because i have enabled dragging of objects like buttons,textarea,images,etc.Can anyone help me to sort out this problem.
    Thanks in advance
    Ravisenan

    Ok - you only gave iPhoto '11 - I assumed up to date
    Glad you found it anyway
    You are welcome
    LN

  • How to know if a scrollbar is been drawn if the JScrollPane is not visible.

    I have a JTabbedPane with one JPanel in each tab. Each of these panels contains one JLabel with a JTextBox on the top and under it the rest is filled with a JScrollPane containing a JTable. I am using a GridBagLayout.
    Now, the requirement is that the JTextBox must have the same length as the content of the JScrollPane; it means that if the JScrollPane has a vertical scroll, the JText has to be shorter on the right side by whatever the scroll width is, but if there's no vertical scroll then the JTextBox must be extended to the top of the right side.
    Now, this that looks so simple is becoming a nightmare...
    The main problem here is that this check to look if the JScrollPane has a scroll or not is done in tabs that are not visible, so i cannot use just a simple isVerticalScrollVisible() because the answer is always NO. I have been trying to catch all the events i could think may help but no luck and sometimes a refresh in one of the tabs produces the JTextField in another tab gets a wrong width.
    One posible approach is the length of the total rows of the JTable, multiply it by the row height and compare it with... with what because the scroll is not visible and the heigh is 0.
    Any ideas? Any one knows how can i know if the the silly scrollbar is visible or not in a non visible tab?
    Thanks in advance.

    Note: This thread was originally posted in the [Java Programming|http://forums.sun.com/forum.jspa?forumID=31] forum, but moved to this forum for closer topic alignment.

  • Ctrl PgUp / CtrlPgDown in JTables vs JTabbedPanes

    Hi there, another wee JTable problem.
    I want Ctrl PageUp and Ctrl PageDown to move between JTabbedPanes. This normally works, except when the focus is currently in a JTable. I want it to also work if the focus is in a JTable.
    I have tried to stop the JTable from handling the keys by setting the inputmap to "none" but this has no effect (you can see my code for this below).
    Here is a test program that shows the bad behaviourimport java.awt.event.InputEvent;
    import java.awt.event.KeyEvent;
    import javax.swing.InputMap;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTabbedPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.KeyStroke;
    public class TestTable extends JTable {
         public TestTable(Object[][] data, Object[] headings) {
              super(data, headings);
              setFocusTraversalPolicyProvider(true);
              // Turn off Ctrl PgUp and Ctrl PgDown handling so tab navigation works.
              InputMap inputs = getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
              KeyStroke ctrlPgUpKey = KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_DOWN_MASK);
              inputs.put(ctrlPgUpKey, "None");
              KeyStroke ctrlPgDownKey = KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, InputEvent.CTRL_DOWN_MASK);
              inputs.put(ctrlPgDownKey, "None");
         public boolean isCellEditable(int row, int column) {
              return false;
         public static void main(String[] args) {
              JFrame frame = new JFrame("Test table");
              JTabbedPane pane = new JTabbedPane();
              frame.add(pane);
              JPanel panel = new JPanel();
              JTextField field = new JTextField("Key Ctrl PgDown or Ctrl PgUp");
              panel.add(field);
              pane.add("test1", panel);
              pane.add("test2", new JScrollPane(new TestTable(new String[][] {{"hello", "me"}}, new String[]{"H1", "H2"})));
              pane.add("test3", new JPanel());
              frame.setBounds(100, 100, 300, 300);
              frame.setVisible(true);
    }Thanks,
    Tim

    i had a similiar problem, had some UIs that had a Tabbed pane and
    ScrollBars, and some tabs had JTables in them, anyhow, I just wanted
    Control-Page_up/Down to work for the JTabbedPane all the the time so
    I did this in my windows look and feel applications and all was well, just posting so maybe this will help someone down the road
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    UIDefaults uiDefaults = UIManager.getDefaults();
    // ginny wants Control-Page-Up and Control-Page-Down to work for tabbed
    // panes, which it does by default, however, it also works for JTable
    // and JScrollPane, and those components grab the keystroke 1st if they are
    // all in the same screen, so disabling it for JTable and JScrollPane
    // see WindowsLookAndFeel.java
    uiDefaults.remove("ScrollPane.ancestorInputMap");
    uiDefaults.put("ScrollPane.ancestorInputMap",
    new UIDefaults.LazyInputMap(new Object[] {
    "RIGHT", "unitScrollRight",
    "KP_RIGHT", "unitScrollRight",
    "DOWN", "unitScrollDown",
    "KP_DOWN", "unitScrollDown",
    "LEFT", "unitScrollLeft",
    "KP_LEFT", "unitScrollLeft",
    "UP", "unitScrollUp",
    "KP_UP", "unitScrollUp",
    "PAGE_UP", "scrollUp",
    "PAGE_DOWN", "scrollDown",
    "ctrl PAGE_UP", "None", //"scrollLeft",
    "ctrl PAGE_DOWN", "None",//"scrollRight",
    "ctrl HOME", "scrollHome",
    "ctrl END", "scrollEnd"
    uiDefaults.remove("Table.ancestorInputMap");
    uiDefaults.put("Table.ancestorInputMap",
    new UIDefaults.LazyInputMap(new Object[] {
    "ctrl C", "copy",
    "ctrl V", "paste",
    "ctrl X", "cut",
    "COPY", "copy",
    "PASTE", "paste",
    "CUT", "cut",
    "RIGHT", "selectNextColumn",
    "KP_RIGHT", "selectNextColumn",
    "LEFT", "selectPreviousColumn",
    "KP_LEFT", "selectPreviousColumn",
    "DOWN", "selectNextRow",
    "KP_DOWN", "selectNextRow",
    "UP", "selectPreviousRow",
    "KP_UP", "selectPreviousRow",
    "shift RIGHT", "selectNextColumnExtendSelection",
    "shift KP_RIGHT", "selectNextColumnExtendSelection",
    "shift LEFT", "selectPreviousColumnExtendSelection",
    "shift KP_LEFT", "selectPreviousColumnExtendSelection",
    "shift DOWN", "selectNextRowExtendSelection",
    "shift KP_DOWN", "selectNextRowExtendSelection",
    "shift UP", "selectPreviousRowExtendSelection",
    "shift KP_UP", "selectPreviousRowExtendSelection",
    "PAGE_UP", "scrollUpChangeSelection",
    "PAGE_DOWN", "scrollDownChangeSelection",
    "HOME", "selectFirstColumn",
    "END", "selectLastColumn",
    "shift PAGE_UP", "scrollUpExtendSelection",
    "shift PAGE_DOWN", "scrollDownExtendSelection",
    "shift HOME", "selectFirstColumnExtendSelection",
    "shift END", "selectLastColumnExtendSelection",
    "ctrl PAGE_UP", "None", //"scrollLeftChangeSelection",
    "ctrl PAGE_DOWN", "None", //"scrollRightChangeSelection",
    "ctrl HOME", "selectFirstRow",
    "ctrl END", "selectLastRow",
    "ctrl shift PAGE_UP", "scrollRightExtendSelection",
    "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
    "ctrl shift HOME", "selectFirstRowExtendSelection",
    "ctrl shift END", "selectLastRowExtendSelection",
    "TAB", "selectNextColumnCell",
    "shift TAB", "selectPreviousColumnCell",
    "ENTER", "selectNextRowCell",
    "shift ENTER", "selectPreviousRowCell",
    "ctrl A", "selectAll",
    "ESCAPE", "cancel",
    "F2", "startEditing"
    }));

  • Jscrollpane without scrollbar

    adf bc swing appilcation, jdeveloper 10.1.3
    this is my form structure
    this (gridbag layout)
    jscrollpane(default layout)
    jpane (null layout)
    jpane2
    jtabbedpane
    jscrollpane size < jpane size
    why the scroll bar of the jscrollpane doesn't appear ??

    Hi,
    it only appears if there are components that are placed outside of the viewport. Add a table and if this is big enough it will cause the scrollbar to show.
    You can however set the vertical scrollbar property to always show the scroll bar. By default it only shows it when needed
    Frank

  • JScrollPane for pane and JTabbedPane and Graphics

    Sort of have two topics with same problem.
    I have a set of Panels. I get a stream of jpegs which I have to decode to the fly.
    There are seperate video feeds in the stream and I have to read jpeg data to see which image goes where.
    I was trying to see if I could have a larger image in smaller area. this is why I tried to draw to panel inside a scrollpane.
    One: I tried to put a JPanel into JScrollPane and tried to draw an image to panel with Graphics g. No Scrollability and even when scroll bars are made to stay on permanently, they get overwritten.
    g=panel.getGraphics();
    if(isVisible()) g.drawImage(image,0,0,320,240,Color.BLUE,null);
    two: When putting the pane with the drawn images into toplevel pane into JtabbedPane. I can turn off the drawing of images with a check to isVisible(). When they are not in top level pane isVisible() does not work and the images get drawn over the other tabbed panes.
    BTW everything is swing. JPanel,JScrollPane,JTabbedPane.

    No Scrollability and even when scroll bars are made to stay on permanently,First of all the scrollbars will only appear when the preferred size of the panel is greater than the size of the scrollpane.
    A think a better design for updating the image is to extend JPanel and create a setImage method. The set image method would set the preferred size of the panel and then invoke repaint() on the panel. You would then also need to override the paintComponent(..) method to do the actual drawing of the image. Then when the image changes you just use the new setImage(..) method.

  • Drag JTabbedPane out of the main Frame and set scroll bars for the tabs

    hi ,
    Iam working on a Swing application . In it i have Six Tabs added to a single JTabbedPane. all the tabs are different class files . is it possible to drag any of the tabs out of the frame.
    how to add scroll bars for the tabs individually. i have tried adding JScrollPane to the main frame and add the JTabbedPane to the Scrollpane . the scroll bar was not visible and i have tried adding
    all the six tabs to the individual JScrollPanes and add the six scrollpanes to the TabbedPane .
    only the scroll arrows are visible , when i minimised or resized the application the scrollbars were not appearing .
    could any one help me to solve the above two problems.

    just trying.....
    public void mouseDragged(MouseMotionEvent e){
    // this event should be activated only when the Drag goes out of scope of the parent JFrame which i dont know how
    Component c=JTab.getComponentAt(JTab.getSelectedIndex());
    JFrameobj.getContentPane().add(c,"Center");
    }

  • Why the vertical scrollbar bar is automatically scrolled to the bottom pos.

    I created a JScrollpane to contain a JTabbedPane. The JTabbedPane has two JPanel and each of them has a number of GUI components such as JCheckbox and JTextField. They have different size because their GUI components are different. The 2nd panel is about twice the size of the first panel.
    When the JScrollpane is shown, its vertical scroll bar is automatically scrolled to the bottom position. However, it is the first panel that is initially visible to the user. So, the user will see no GUI components of the first panel because the auto scrolling of the vertical scroll bar.
    Can anyone tell me how to disable the auto scrolling?
    I just want to let the scrollbar knob stay at the top so that the GUI components of the first panel (the smaller one) can be seen initially!

    Works fine for me:
    import javax.swing.*;
    import java.awt.*;
    public class TabbedPaneScroll extends JFrame
         private JTabbedPane tabbedPane;
         public TabbedPaneScroll()
              tabbedPane = new JTabbedPane();
              tabbedPane.setPreferredSize( new Dimension(300, 200) );
              getContentPane().add(tabbedPane);
              addNewTab( 10 );
              addNewTab( 5 );
              addNewTab( 20 );
         private void addNewTab(int fields)
              JPanel panel = new JPanel();
              panel.setLayout( new GridLayout(0, 1) );
              for (int i = 0; i < fields; i++)
                   panel.add( new JTextField("" + i) );
              JScrollPane scrollPane = new JScrollPane( panel );
              tabbedPane.add(scrollPane, "" + fields);
         public static void main(String args[])
              TabbedPaneScroll frame = new TabbedPaneScroll();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }If you need further help then you need to create a [url http://www.physci.org/codes/sscce.jsp]Short, Self Contained, Compilable and Executable, Example Program that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • Multiple JTabbedPane focussing

    I have a Swing GUI (applet) that has 2 JTabbedPanes side-by-side. The tabbed panes can contain JPanels that have many different types of components (JTable, JButtons, etc. ) on them.
    Depending on which tabbed pane has focus, other components have to be enabled/disabled. This is easily accomplished by registering the appropriate listeners with the tabbed panes themselves and clicking on the tab when I want to change focus.
    However, with focus currently on the left tabbed pane, I want to be able to just click within a JPanel on the right tabbed pane and have focus change. Since my JPanels contain many components, this involves addiing a MouseListener to every visible component. This can be quite cumbersome since a listener must be added to a table header as well as to the table and to the vertical and horizontal scrollbars as well as to the scrollpane.
    Does anyone know a better way to do this?
    I was hoping to utilize something like the glasspane, but that's only available from the applet level or JDialogs.
    Thanks.

    I may have used the term "focus" when I should have said something like "active."
    And in my attempt to simplify the question I may have described the workings of my GUI inaccurately, too.
    My GUI can "open" many different types of "documents." These documents (which basically consist of JPanels that contain many different types of components) open as tabs in a JTabbedPane. Similar to many IDEs nowadays, this group of tabs can be split into a second tab group (JTabbedPane) to view 2 docs at once. Open documents can be moved between these 2 groups.
    To be more user friendly, I make sure the currently active tab title (there can be only one) is rendered uniquely.
    Depending on which type of document is currently active (or in focus), toolbar buttons, menu actions and the such are enabled/disabled.
    I need notification when a user is selecting the other tab group so it can be made active. As I said previously, this is quite easy if the user just clicks on the tab itself, but if the user clicks within the already open document it seems I need a mouse listener on every component. I tried focus listeners, at one time, but they only work when components are enabled, and some of the components I use could be disabled.
    It seems that there is no shortcut, and listeners have to be added to every component in a document. I was hoping someone would know a technique similar to a glass pane where I could just add one listener and then pass on the event when I handled it.

  • JTabbedPane display problems

    Can someone help me with this? I have a JTabbedPane in an applet with two tabs. Lately I have noticed that when I move the mouse pointer around on one tab, some components from the other tab start to show through and I can even click on them, resulting in other components showing through and a jumbled mess. Can anyone help me?
    Here is how I set up the layout in the init method:
    jPanelUI = new MyUIPanel();
    getContentPane().setLayout(new GridLayout(1,1,0,0));
    jPanelUI.setLayout(new GridLayout(1,1,0,0));
    // add look & feel panel to content pane
    getContentPane().add(jPanelUI);
    // add main panel to look & feel panel
    jPanelUI.add(administrationPanel);
    Here is MyUIPanel:
    public class MyUIPanel extends javax.swing.JPanel implements my.data.MyConstants
         public MyUIPanel()
         super();
         UIManager.put("TabbedPane.selected", CONTROL);
         UIManager.put("TableHeader.background", CONTROL);
         UIManager.put("ScrollBar.arrowColor", Color.green);
         UIManager.put("ScrollPane.background", CONTROL);
         UIManager.put("ScrollPane.foreground", CONTROL);
    I add the JTabbedPane to Administration panel like this...
    jTabbedPaneAdministration.setRequestFocusEnabled(false);
    jTabbedPaneAdministration.setOpaque(true);
    add(jTabbedPaneAdministration, new com.symantec.itools.awt.GridBagConstraintsD(0,2,6,10,0.5,0.5,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.BOTH,new Insets(15,20,20,20),0,0));
    jTabbedPaneAdministration.setBackground(new java.awt.Color(204,204,153));
    jTabbedPaneAdministration.setFont(new Font("Dialog", Font.PLAIN, 12));
    I add my two panels to administration panel like this...
    jTabbedPaneAdministration.add(jPanel1);
    jTabbedPaneAdministration.add(jPanel2);
    Any ideas?
    Thanks a bunch

    Found the problem. On the invisible tab, I was setting visibilities, depending on what components the user had permission to see. I assumed that those visibilities would only take effect on the tab that they were on, but instead they showed right through the selected tab. So it wasnt the resizing but your idea made me look to what I was doing with those panels after adding them, and I found it. Enjoy your duke $s
    Thanks

  • Scrollbar for a frame

    hi all,
    iam doing a project in swing . in it there are 6 tabs, is it possible to add a scrollbar for the tabs . i have tried this by adding the tabbed pane to the scrollpane but the scroll bars are not visible.
    could u pls tell me how to add a scroll bar for the tabs.

    have you tried:
    JFrame f = new JFrame();
    JTabbedPane t = new JTabbedPane();
    /* add your tabs */
    JScrollPane p = new JScrollPane(t);
    f.getContentPane().add(p);thomas

  • All JComponents in the JTabbedPane got shrink when I click for a particular

    When I click a particular tab in a JTabbedPane, all the JComponents (like JTextboxes, JListbox ) are getting shrink. Because of this I am not able to enter or choose any data for these JComponents.
    Moreover the problem is seen only when the window is in a default size. If I restore the window size from the default to the maximum the problem goes away (I.e I am able to see and enter the data�s for JComponents).
    Also this is happening only with windows platform (Windows XP), I checked in Solaris platform with the same code and it works fine (with default window size).
    While testing the code, I found one difference. When I use Solaris I am able to see the scrollbar on a window, whereas the scroll bar in WindowsXp is not appeared.
    Can you please clarify me why the JComponents are getting shrink? And also why it is happening only on WindowsXP?

    Can you please clarify me why the JComponents are getting shrink?You have a program bug.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • JTabbedPane/JSplitPane/JScrollPane problem

    Hi
    I'm making a simple webbrowser with the JDesktop (jdic) parser (using your standard browser as parser)...
    The problem I have :
    I have a "JTabbedPane" containing a "JSpitPane". This JSplitPane contains a "JCombobox" (as URL field) and a "JScrollPane".
    The "JScrollPane" contains the jdic WebBrowser...
    When I resize the JFrame of my application bigger, everything will resize okay. When I'm making my JFrame smaller, the JScrollPane doesn't resize correctly , so the scrollbars are gone !
    I tried already a lot of things like putting the jdic WebBrowser directly in the JSplitPane, using a JPanel instead of the JSplitPane, ...
    It only works correctly if I add the jdic Webbrowser directly to the JTabbedPane...
    I know it's difficult to understand but I hope somebody can help me !
    If you know another solution to add a JCombobox and a jdic Webbrowser together, let me know !"
    Thx in advance!
    grtz
    Unzip

    Hi,
    The JPanels which you have inside each tab of the JTabbedPanes should have BorderLayout and the JScrollPanes which hold the JTables should be added with the BorderLayout.CENTER constraint. This will make sure that the JScrollPanes that contain the JTables occupy as much space as possible.
    Hope this helps,
    Ranga.

  • How to enable a scrollbar in a JPanel

    Hi
    I am adding some components in a JPanel and I am adding the JPanel to a JScrollPane.The JScrollPane is finally added to the container.Now I could manage to get only the scrollbars added but it does not work!How should I use the scrollbars to view all the components that are added inside the JPanel.
    Here is my source code:
    tagPanel = new JPanel();
    tagPanel.setLayout(new FlowLayout());
    tagPanel.setPreferredSize(new Dimension(100,100));
    tagPanel.setBackground(Color.white);
    tagPanel.setAutoscrolls(true);
    for(int i = 0; i<=20; i++)
    tempButton = new JButton("Testing");
    tagPanel.add(tempButton);
    container.add(forbiddenscroll= new JScrollPane
    (tagPanel),BorderLayout.WEST);
    forbiddenscroll.setHorizontalScrollBarPolicy
    (ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    forbiddenscroll.setVerticalScrollBarPolicy
    (ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    Thank you for your reply!
    Your help is very much appreciated.

    don't set prefered size of the tag panel.
    run this code pasted below. it work fine.
    regards,
    Pratap
    import java.awt.*;
    import javax.swing.*;
    public class Frame1 extends JFrame {
         JScrollPane forbiddenscroll;
         JPanel tagPanel;
         JButton tempButton;
         public Frame1() {
              tagPanel = new JPanel();
              tagPanel.setLayout(new FlowLayout());
              tagPanel.setBackground(Color.white);
              tagPanel.setAutoscrolls(true);
              for(int i = 0; i<=20; i++)
                   tempButton = new JButton("Testing");
                   tagPanel.add(tempButton);
              forbiddenscroll = new JScrollPane();
              forbiddenscroll.getViewport().setView(tagPanel);
              getContentPane().add(forbiddenscroll, BorderLayout.CENTER);
              forbiddenscroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
              forbiddenscroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
         public static void main(String[] args) {
              Frame1 f = new Frame1();
              f.pack();
              f.setLocation(200,200);
              f.show();
    }

Maybe you are looking for

  • Can't select plain paper on HP Officejet Pro L7600

    Hi, I have an HP Officejet Pro L7600, and when I try to select the paper type/quality, I can only select photo papers. All the other selections are greyed out. I don't have photo paper, I just want to print on regular paper. Anyone know how to fix th

  • Recording from sub and an aux channel

    How can you record from a sub or an aux? Fresh_oil

  • Access database dynamic query output...

    Dear CF Colleagues: I need to run a loop for 4 times, to access four seperate values out of a data row in a test results table (tbl_results), where all four are in the row of the student (WHERE studentid = etc). It looks like this...   <cfset variabl

  • Counting words, lines and char

    i want a program which counts the number of lines,words and characters in a file..................... please help me

  • Unable to view properties in DRM

    I created a property named 'Status' of localnode with 'Defined' property type. I added this to Essbase Property category. I was unable to view this property in DRM UI. Where as I can view this property in DRM database. Anyone can help me on this?