Add Scrollbar

Hello Friends,
Is it possible to add an scrollbar on form?
Thanks & Regards.
Mithun.

Hi
Adding scrollbars is not possible in business one
Regards
Vishnu

Similar Messages

  • How To Add scrollbar in Spark list which will work on mouse movement ?

    Hi,
    I want to add scrollbar in Spark list which will work on mouse movement, i.e instead scrolling down it will sense mouse position and scroll automatically. I could not find a way to handle this with horizontalLayout.
    I tried hovering on list and setting ensureIndexIsVisible(index) but hovering element index is not present in the Spark List.
    Any idea on this will be highly appreciated.
    Thanks in advance
    Avishek

    Hi,
    I want to add scrollbar in Spark list which will work on mouse movement, i.e instead scrolling down it will sense mouse position and scroll automatically. I could not find a way to handle this with horizontalLayout.
    I tried hovering on list and setting ensureIndexIsVisible(index) but hovering element index is not present in the Spark List.
    Any idea on this will be highly appreciated.
    Thanks in advance
    Avishek

  • How to add scrollbar to the JInternal Frame

    How to add scrollbar to JInternal Frame?
    I have One JInternal frame i want it should have a scrollbar when we reduces its size.

    [url http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html]How to Use Scroll Panes

  • Add Scrollbars to Jframe

    I want to add ScrollBars to the JFrame(Parent screen), when the internal frame(child scereen) size is greater than the size of the JFrame. and those scroll bars should have the control over the child screen.
    For example, when the height of the child screen is greater than the parent screen, then Vertical scroll bar should be added to the parent screen. So, In this case i couldn't view the bottom of the child screen without moving the scroll bar. when I move the scroll bar, I should be able to view the lower portion of the child screen.
    Child screen size is fixed and it can be bigger than the parent screen in some cases. If it is bigger, then it should be within the boundary of the parent screen and all the components should be viewable to the user. In this scenarioo, I can think of only adding scrollbars to the parent screen and using that to view the entire child screen.
    Is there anyway to do this?
    Thanks,

    Come on don't recreate threads! Your thread has been moved to the correct forum:
    [http://forums.sun.com/thread.jspa?threadID=5362257&messageID=10581863#10581863]
    Use your posting history to find your threads.

  • Add Scrollbar to Array

    Does anyone know if it is possible to add a scrollbar to an array? I want to replace the index display with a scrollbar.
    My first thought to do this leads me to believe that I would need to fix the size of the arrayl. Can the size of an array be fixed?
    Thank you,
    -Ron Synakowski

    you can definitely attach a scroll bar control and an array, there you just have to attach the index to the scroll value and update it on the scroll value change event.  Also you should update the maximum scroll value property to be the size of the array (this can be done periodically or as a user defined event), so you don't have to fix the array size,  I have done this in the past without too much work, but it would have been nice to allow the array control to have this option built in (maybe LV8).
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

  • Can we add scrollbar to JOptionPane.showConfirmDialog()

    Hi,
    Can we add a scroll bar to JOptionPane.showConfirmDialog() so that the contents(messages) which are to be displayed are present in scrollbar so that the buttons will be visible to the user like OK, CANCEL.
    Currently when the message is large the buttons will not be visble in the screen.
    So, it is possible ? Or there is any other alternative for the same.
    Thanks.

    Is there another library that I have to import? I recieve this error when I try to compile...
    isPrime.java:53: cannot find symbol
    symbol : variable sb
    location: class isPrime
         JTextArea area = new JTextArea(sb.toString() );
    I have javax.swing.* imported as of right now...
         JTextArea area = new JTextArea(sb.toString());
          area.setRows(25);
          area.setColumns(100);
          area.setLineWrap(true);
          JScrollPane pane = new JScrollPane(area);
           JOptionPane.showConfirmDialog(null,
         pane,
           "Test", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    /*         JOptionPane.showMessageDialog(null,
               printArray(array),
         "Thanks for using Reverse Array", JOptionPane.INFORMATION_MESSAGE);
    */       the comment text is what I eventually wish to print((I simply hid it from the compiler so I could play w/ the code you provided)... it is the first 'n' number of primes up to which I'd like to be able to scroll through for large prints over 100 primes.
    thx for the help

  • How to add scrollbar to jpanel

    i created a jpanel with images & related text to images, which repaints dynamically according to width,now i wann to add a vertical scrollbar to it.
    plz..help me

    iam getting scrollbar but iam unable to get scrolling when i change the size
    my code like this....
    //here iam using jpanel to get images and text
    public class ImgNtext extends JPanel {
       public ImgNtext(){
           //to intialize values
           init_values();
      public void init_values{
       //In these init_values iam decalaring imageFile name & text using hashtable
       public void paintComponent(Graphics g) {
             super.paintComponent(g);
             //getting width of screen
             int gw = getWidth();
             //then iam retriving all the values using while loop
             while(i.hasMoreElements())
                        //accroding to width iam painting the components
                          if(gw<100){
                               g.drawImage(image,x,y,null);
                               g.drawString(string,x,y+80);
                               gw -=100;
                               x += 100;
                         else{
                               y += 100;
                               gw = getWidth();
    public class ImagePanel
           ImgNtext it = new ImgNtext();
           JScrollPane sp;
           public ImagePanel() {
                     JFrame jf = new JFrame();
                     jf.setSize(1000,1000);
                     scp = new                JScrollPane(it,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
                     jf.getContentPane().add(scp);
                     jf.setVisible(true);
              public static void main(String s[]){
                   ImagePanel img = new ImagePanel();
    }

  • How to add scrollbar to jpopup menu

    Hi everyone,
    Do u know how to add a scrollbar to jpopup menu ?

    Menus don't scroll, and shouldn't scroll. Given that, you shouldn't try and use JPopupMenu at all... rather, create your own component that implements the look and behavior you want. It will be far easier and less frustrating.
    Either that... or you should re-think what functionality you are trying to provide, and how you are trying to implement it. A scrolling menu just seems like a counterintuitive wacky UI design to me.

  • Add scrollbar to JTextArea

    Hello!
    I dont understand why this is not working:
    When I have added the scrollbar I can not print out anything on the JTextArea, if I just add the JTextArea I can print out to it.
    part of my view
              //Display (Do not forget to make the scrollbar after logic is implemented)
              JScrollPane scroll = new JScrollPane(display, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
              JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
              scroll.setLayout(null);
              scroll.setLocation(10, 10);
              scroll.setSize(320, 270);
              //display.setLocation(10, 10);
              //display.setSize(320, 270);
              display.setEditable(false);
              display.setLineWrap(true); //Start a new line instead of making display area bigger
              display.setWrapStyleWord(true); //Words will not split in the middle, the full word will instead show on the next line
              middle_left.add(scroll); //Add to holderThis is how I take inputs that will go into the JTextArea
         // Sets the text displayed on the display area
         public void setDisplayArea(String message){
              display.setText(""+message);
         I must defently be missing something, can you please help me figure out what it is.
    This is part of an assignment, please do not spoonfeed me with code.
    Regards
    Martin

    onslow77 wrote:
    Yes the problem went away when I comment out this line //scroll.setLayout(null);
    Why is it so?
    Can you please explain or guide me to a webpage with an explonation if it is alot to explain.Like abillconsl said, a JScrollPane already has a perfectly good layout manager. So instead it's up to you to explain why you decided to make it have a null layout manager instead.
    If the explanation is "I don't know anything about layout managers so I can't explain that, it just seemed like a good idea at the time" then you should read the [Layout Managers tutorial|http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html].

  • Add scrollbars to OOB SharePoint Blog site

    All:
    I created an OOB SharePoint 2013 Blog site used for news updates.  The problem is that on smaller device form factors (e.g. tablets) or when I shrink browser window on the desktop, no horizontal or vertical scrollbars are visible.  My users
    cannot read or access the blog post info (especially on the right hand side). 
    How can I enable scrollbars in an OOB Blog site so that viewers can access all of the content?
    Thanks,
    Bill
    Bill Davidson

    Hi,
    According to your description, when you shrink the browser window or using a tablet, the scrollbars don’t appear.
    Is this issue only occur to Blog site but the other site templates?
    What version of the browser do you use?
    It would be better if you can provide more details about your browser or if there any customization has been made on your Blog site.
    Feel free to reply if there any progress.
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they
    help and unmark them if they provide no help. If you have feedback for TechNet
    Subscriber Support, contact [email protected]
    Patrick Liang
    TechNet Community Support

  • Vertical scrollbar does not work in a nested dialog

    In Adobe Illustrator CC 2014 Win 7 and Mac OS X 10.8
    function dropdown2(win_location, win_width, h50, list2) {
        var ww = new Window ("dialog");
        var g = ww.add ("group");
        var panel = g.add("panel", [0, 0, 300, 200]);
        var sbar = g.add ("scrollbar", [0, 0, 20, 200]);
        ww.show();
    var w = new Window ("dialog");
    w.add("button", undefined, "asdads").onClick = function () {
      dropdown2([200, 200], 200, 50, ["asdaf", "asdaf", "asdaf", "asdaf" ]); };
    w.show();

    function dropdown2(win_location, win_width, h50, list2) {
        var ww = new Window ("dialog");
        var g = ww.add ("group");
        var panel = g.add("panel", [0, 0, 300, 200]);
        var sbar = g.add ("scrollbar", [0, 0, 20, 200], list2);
        ww.show();
    dropdown2([200, 200], 200, 50, ["asdaf", "asdaf", "asdaf", "asdaf" ]);
    var w = new Window ("dialog");
    w.add("button", undefined, "asdads").onClick = function () {
      dropdown2([200, 200], 200, 50, ["asdaf", "asdaf", "asdaf", "asdaf" ]); };
    w.show();
    Illustrator CC 2014
    Ctrl+F12
    first scrollbar its ok
    press button
    scrollbar arrows -> gray

  • CS6 ScriptUI Scrollbar issues

    We're working on building a palette with a scrollbar. However, we're running into an issue with the display in CS6. We've gotten it to display correctly on Windows and Macs in previous versions of Bridge, but CS6 seems to have a bug even after the most recent update (version 5.0.1.21).
    The scroll bar appears as below.
    When we changed the dimensions of the scrollbar, we found that not only was the scrollbar distorted but it's actually oriented horizontally to control the vertical position.
    We've tried nesting the scrollbar in a group or giving it a separate panel, as well as giving those panels and groups a specific column orientation, but nearly all of those results give us something like the following:
    The following code was our last iteration that gives the above output:
    #target bridge
    if (BridgeTalk.appName == 'bridge')
        // dimension and font variables
       var fF = ['fill', 'fill'];
       var fT = ['fill', 'top'];
       var lblSize = [60, 15];
       var lblBounds = [5, 10, 60, 27];
       var etFont = ScriptUI.newFont ("Arial", 11);
       var etBounds = [10, 10, 200, 27];
        // Create the TabbedPalette object, of type "script"
        var tbPalette = new TabbedPalette( app.document, "CSU Metadata", "CSU_Metadata", "script", "right", "bottom");
        // Create a ScriptUI panel to be displayed as the tab contents.
        var panel = tbPalette.content.add('panel', "x:0, y:0, width:300, height:500", "");
        var tbPanelSbGrp = tbPalette.content.add('panel', "x:302, y:0, width:200, height:500", 0, 0, 20, 500);
        tbPanelSbGrp.orientation = 'column';
        var tbPanelSb = panel.add('scrollbar', "x:302, y:0, width:40, height:500");
        tbPanelSb.stepdelta = 10;
        tbPanelSb.jumpdelta = 40;
        tbPanelSb.onChanging = function() {
         var scrollVal = Math.round(this.value);
        this.value = scrollVal
    Has anyone found a work around for this problem? I've seen the same problem mentioned elsewhere but without a solution:
    http://www.ps-scripts.com/bb/viewtopic.php?f=9&t=4915
    http://feedback.photoshop.com/photoshop_family/topics/extendscript_ui_not_drawing_correctl y_in_bridge?from_gsfn=true

    I have given up on this.  More than a year has passed and the Bridge ScriptUI is still non-functional.  I am looking for another solution for my workflow so I can ditch Bridge/Photoshop and find a vendor that supports their products.

  • 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

  • Scrollbars and Mouse monitoring in a JFrame

    class Akim extends JFrame
         public Akim()
              super("Drawing lines");
              pack();
              setSize(640,640);
              setVisible(true);
         public void paint(Graphics g)
              super.paint(g);
              g.setColor(new Color(200,200,250));
              g.fillRect(40,40,400,400);
              g.setColor(new Color(255,255,255));
              for(int i = 2; i<=22; i++)
                   g.drawLine(20*i,40,20*i,440);
              for (int i=1;i<=22;i++)
                   g.drawLine(40,20*i,440,20*i);
    class blah
         public static void main(String[] args)
              Akim me = new Akim();
              me.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }I am keeping the size down because if it gets bigger it goes off the screen. I would like to know how to add scrollbars.
    I would also like to display something whenever someone clicks in one of the squares. How do I get the location where the mouse was pressed?
    I only started working with JFrames yesterday so please keep it simple(if possible).
    Thanks for any help.

    Here is an example with a little of everything I mentioned:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.net.URL;
    import javax.imageio.*;
    import java.io.IOException;
    public class SwingExample extends JFrame implements MouseListener {
        public SwingExample() {
            super("This is an example");
            try {
                Image largeImage = ImageIO.read(new URL("http://today.java.net/jag/bio/JagHeadshot.jpg"));
                // ImagePanel is a JComponent subclass (see below)
                ImagePanel displayPanel = new ImagePanel(largeImage);
                // by addint a mouse listener to it, we can listen for clicks on the image
                displayPanel.addMouseListener(this);
                // content pane is the main container for the frame
                Container cp = getContentPane();
                // wraps the image panel in a scroll pane
                JScrollPane scroller = new JScrollPane(displayPanel);
                // tell the scrollbar what size you would like it to be, otherwise
                // it will try to be as large as the viewport component
                scroller.setPreferredSize(new Dimension(100, 100));
                // add the scrollpane to our frame here
                cp.add(scroller);
            catch (IOException ioe) {
                ioe.printStackTrace();
            // swing components use layout managers to help with resizing frames.
            // pack() tries to resize all components to their preferred size using
            // the layout managers. By setting the layout of a component to null,
            // you can use setBounds or setSize to explicitly tell components how
            // big they should be, but they won't automatically resize.
            pack();
            setDefaultCloseOperation(EXIT_ON_CLOSE);
        // since we said we implement the MouseListener interface, we must include
        // all the methods. Of course, you can leave the body blank if you are not
        // interested in an event
        public void mousePressed(MouseEvent evt) {
            System.out.println("Pressed at " + evt.getX() + "," + evt.getY());
        public void mouseReleased(MouseEvent evt) {
            System.out.println("Released at " + evt.getX() + "," + evt.getY());
        public void mouseClicked(MouseEvent evt) {
            System.out.println("Clicked at " + evt.getX() + "," + evt.getY());
        public void mouseEntered(MouseEvent evt) {
            System.out.println("Entered at " + evt.getX() + "," + evt.getY());
        public void mouseExited(MouseEvent evt) {
            System.out.println("Exited at " + evt.getX() + "," + evt.getY());
        // simple overwritten component to display an image
       class ImagePanel extends JComponent {
           private Image drawImage;
           public ImagePanel(Image image) {
              setImage(image);
           public void setImage(Image image) {
              if (image == null) {
                 this.drawImage = null;
                 return;
              int width = image.getWidth(this);
              // if the image is not fully loaded, it's width will
              // return 0
              if (width <= 0) {
                 MediaTracker tracker = new MediaTracker(this);
                 tracker.addImage(image, 0);
                 try {
                    tracker.waitForID(0);
                 catch (InterruptedException ie) {}
                 width = image.getWidth(this);
              int height = image.getHeight(this);
              this.setPreferredSize(new Dimension(width, height));
              this.drawImage = image;
           // overwrite paintComponent here instead of paint
           public void paintComponent(Graphics g) {
              g.drawImage(drawImage, 0, 0, this);
        public static void main(String[] args) {
            JFrame frame = new SwingExample();
            frame.setVisible(true);
    }

  • JScrollPane in a JFrame scrollbars visible but not functional no thumbtabs

    Here is the code that I compiled and run on J2SE v. 1.4.2 (runtime b28). I looked through the various related articles and nothing seems to help with this issue. The scrollbars appear along with the panel but the thumbtabs are not present. Any help would be appreciated.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Test {
      public static void main(String[] args){
        Test rce = new Test();
        JFrame frame = new JFrame("Test Scroll");
        JScrollPane scrollBar = new JScrollPane();
        scrollBar.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        scrollBar.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        Component  rcePage = rce.createComponents();
        scrollBar.getViewport().add(rcePage, null);
        frame.getContentPane().add(scrollBar, null);
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        frame.pack();
        frame.setSize(400, 400);
        frame.setVisible(true);
      public Component createComponents() {
        JPanel pan = new JPanel();
        JLabel label = new JLabel("This is a Test!");
        pan.setBorder(BorderFactory.createEmptyBorder(
            0, //top
            0, //left
            0, //bottom
            0) //right
        pan.setLayout(null);
        label.setBounds(100, 100, 80, 20);
        pan.add(label);
        return pan;
    }

    This is a very common mistake. When you put a JPanel in a scrollpane, the scrollpane will use the panel's preferred size to determine if scrolling is needed or not. If the panel is using a LayoutManager this is generally done for you automatically. But in your case you set the layout to null, and then it is your responsibility to make sure that the getPreferredSize() method of the panel returns the correct size.
    One way to fix this in the code you posted would be to override the getPreferredSize() of the panel, like so:
        public Component createComponents() {
            JPanel pan = new JPanel() {
                public Dimension getPreferredSize() {
                    return getSize();
        }Then the scrollbars will appear if you make the frame smaller.
    But what I really suggest is that you use a LayoutManager.

Maybe you are looking for

  • Problems with flash photos

    I have a problem with my iphone 5s flash. Everytime I shoot a photo without flash, it works properly. However, when I use flash photos appear with a white mist( no case on). What's the problem?

  • Mail not working after change of password

    Yesterday I changed my emai password (using my ISPs web site). All my other email clients can log in and download new mails using the new password. But Snow Leopard's 'Mail' client refuses to log in - telling me that my ISP has rejected the password.

  • Calling a VI as ActiveXObject using Javascript

    Hello, I would like to control a Labview-VI (Version 7.1) from a Javascript-program by using the ActiveXObject-model. It looks like that:     lvapp = new ActiveXObject("Labview.Application");     viPath = "C:\\test.vi";     vi = lvapp.GetVIReference(

  • Tree in oracle 10g

    i want a tree node at run time i have this query select 1, level, e.ename , null, e.empno from emp e connect by prior e.empno = e.mgr start with mgr is null in this query the king is first node after that jones under the jones node the scott node lay

  • Ola apareceu uma mini bolha no aparelho novo

    Apareceu uma mini bolha no meu aparelho novo ???