Results 1 to 6 of 6
  1. #1
    ravrajesh.ap is offline Member
    Join Date
    Jan 2009
    Posts
    4
    Rep Power
    0

    Default problem with Jscrollpane

    Hi,

    I have a problem with Jscrollpane.when i add the Jscrollpane to the panel first time it is working fine.when we refresh with next time components are not visible.

    JScrollPane paneReg = new JScrollPane(panel);
    frame.add(paneReg);


    Please help me on this.

    Thanks in advance.

    Thanks,
    Rajesh.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default

    All my crystal ball can tell me is that there's a bug in your code.

    To get better help sooner, post a SSCCE that clearly demonstrates your problem. Link: SSCCE : Java Glossary

    db

  3. #3
    Gudradain is offline Member
    Join Date
    Nov 2008
    Posts
    44
    Rep Power
    0

    Default

    I agree with Darryl.Burke

    But from what I read I think I had a similar problem before.

    I create a JFrame then call myFrame.setVisible(true)
    then I add a JComponent in it.

    What happens is that when the program start the JComponent I add didn't show right away. I had to select the JFrame and do an operation in it (anything : minimize or move work) then the JComponent appear.

    By calling myFrame.setVisible(true) after I add the JComponent fix the problem.

    N.B. Once the JComponent is add you can modify it's attribute and everything will work fine. The problem is just when you add it.

  4. #4
    ravrajesh.ap is offline Member
    Join Date
    Jan 2009
    Posts
    4
    Rep Power
    0

    Default problem with Jscrollpane

    Hi,

    below is my code.I have 5 links in home page west panel.when we click on each link data will display in center panel.now when we add a scrollpane to the center panel in one link all other links are not working.

    code for home page :
    ----------------------

    package com.ford.midas;

    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Container;
    import java.awt.GridBagLayout;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import javax.swing.Box;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import java.io.BufferedInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import java.awt.Image;
    import java.awt.Toolkit;
    /**
    * Utility class for creating one-column forms.
    */
    public class MidasHome {
    JFrame frame;
    JPanel center;
    JPanel west;
    JPanel east;
    JPanel north;

    JFrame frame1;
    JFrame frame2;
    JFrame frame3;
    /*JFrame initframe;
    JPanel initcenter;
    JPanel initwest;
    JPanel initeast;
    JPanel initnorth;*/

    JLabel audits;
    JLabel dealershipAudits;
    JLabel reports;
    JLabel dealerPullLists;
    JLabel stateScope;
    JLabel regionalManagers;
    JLabel programNumbers;
    boolean flag = false;
    public static void main(String[] args) {

    MidasHome form = new MidasHome();
    }

    public MidasHome()
    {
    try{
    frame = new JFrame("Swing layouts demo");
    center = new JPanel();
    //center.setLayout(new GridBagLayout());

    JLabel lb3=new JLabel();
    lb3.setText("Please select your screen or report by clicking the menu selections on the left.");
    JLabel lb4=new JLabel();
    lb4.setText(" A brief description appears here as you move the cursor over the menu selections.");
    lb4.setForeground(Color.RED);
    Container boxes = Box.createVerticalBox();
    boxes.add(lb3);
    JLabel lb5=new JLabel(" ");
    boxes.add(lb5);
    boxes.add(lb4);
    center.add(boxes);

    east = new JPanel();
    west = new JPanel();
    north = new JPanel();
    north.setLayout(new GridBagLayout());

    /*JLabel lb2=new JLabel();
    lb2.setText("<html>" + "<img src=\"file:oval_4_hdr.jpg\">&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;" +
    "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;" +"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;" +
    "" + "Marketing Incentives Dealer Audit System" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;<img src=\"file:f_l_m.jpg\">"+ "</html>");
    lb2.setForeground(Color.white);
    Container box = Box.createHorizontalBox();
    box.add(lb2);*/

    Container box = Box.createHorizontalBox();
    Image warnImage = ImageLoader.getImage(MidasHome.class, "oval_4_hdr.jpg");
    System.out.println("image "+warnImage);
    Icon warnIcon = new ImageIcon(warnImage);
    JLabel label1 = new JLabel(warnIcon);
    box.add(label1);
    JLabel label2 = new JLabel(" Marketing Incentives Dealer Audit System ");
    box.add(label2);
    label2.setForeground(Color.white);
    Image warnImage1 = ImageLoader.getImage(MidasHome.class, "f_l_m.jpg");
    Icon warnIcon1 = new ImageIcon(warnImage1);
    JLabel label3 = new JLabel(warnIcon1);
    box.add(label3);



    Container boxe = Box.createVerticalBox();
    boxe.add(box);


    JTextField jet = new JTextField(10);
    jet.setText("MIDAS Home");
    jet.setBackground(Color.LIGHT_GRAY);
    jet.setEditable(false);
    boxe.add(jet);
    north.add(boxe);
    north.setBackground(Color.BLACK);

    Container boxWest = Box.createVerticalBox();
    west.setBackground(Color.gray);

    audits = new JLabel("Audits");
    audits.setForeground(Color.BLUE);
    audits.setToolTipText("Audits");
    /*audits.addMouseListener(new MouseAdapter() {
    Audits au = new Audits();
    public void mouseEntered(MouseEvent me) {
    au.auditsMouseEnterd(frame,audits,center,east);
    }
    public void mouseExited(MouseEvent me) {
    au.auditsMouseExited(audits);
    }
    public void mouseClicked(MouseEvent me) {
    au.auditsMouseClicked(frame,audits,center,north,ea st);
    }
    }); */

    dealershipAudits = new JLabel(" Dealership Audits");
    dealershipAudits.setForeground(Color.BLACK);
    dealershipAudits.setToolTipText("Dealership Audits");

    dealershipAudits.addMouseListener(new MouseAdapter() {
    DealershipAudits dau = new DealershipAudits();
    public void mouseEntered(MouseEvent me) {
    dau.dealershipAuditsMouseEnterd(frame,dealershipAu dits,center,east,flag);
    }
    public void mouseExited(MouseEvent me) {
    dau.dealershipAuditsMouseExited(dealershipAudits);
    }
    public void mouseClicked(MouseEvent me) {
    dau.dealershipAuditsMouseClicked(frame,dealershipA udits,center,north,east);
    flag = true;
    }
    });

    reports = new JLabel("Reports");
    reports.setForeground(Color.BLUE);
    reports.setToolTipText("Reports");

    /* reports.addMouseListener(new MouseAdapter() {
    Reports rpt = new Reports();
    public void mouseEntered(MouseEvent me) {
    rpt.reportsMouseEnterd(frame,reports,center,east);
    }
    public void mouseExited(MouseEvent me) {
    rpt.reportsMouseExited(reports);
    }
    public void mouseClicked(MouseEvent me) {
    rpt.reportsMouseClicked(frame,reports,center,north ,east);
    }
    });*/


    dealerPullLists = new JLabel(" Dealer pull List");
    dealerPullLists.setForeground(Color.BLACK);
    dealerPullLists.setToolTipText("Dealer pull List");

    dealerPullLists.addMouseListener(new MouseAdapter() {
    DealerPullLists dpl = new DealerPullLists();
    public void mouseEntered(MouseEvent me) {
    dpl.dealerPullListsMouseEnterd(frame,dealerPullLis ts,center,east,flag);
    }
    public void mouseExited(MouseEvent me) {
    dpl.dealerPullListsMouseExited(dealerPullLists);
    }
    public void mouseClicked(MouseEvent me) {
    dpl.dealerPullListsMouseClicked(frame,dealerPullLi sts,center,north,east);
    flag = true;
    }
    });


    stateScope = new JLabel(" State Scope");
    stateScope.setForeground(Color.BLACK);
    stateScope.setToolTipText("State Scope");
    stateScope.addMouseListener(new MouseAdapter() {
    StateScope ss = new StateScope();
    public void mouseEntered(MouseEvent me) {
    ss.stateScopeMouseEnterd(frame,stateScope,center,e ast,flag);
    }
    public void mouseExited(MouseEvent me) {
    ss.stateScopeMouseExited(stateScope);
    }
    public void mouseClicked(MouseEvent me) {
    ss.stateScopeMouseClicked(frame,stateScope,center, north,east);
    flag = true;
    }
    });


    regionalManagers = new JLabel(" Regional Managers");
    regionalManagers.setForeground(Color.BLACK);
    regionalManagers.setToolTipText("Regional Managers");

    regionalManagers.addMouseListener(new MouseAdapter() {
    RegionalManagers rm = new RegionalManagers();
    public void mouseEntered(MouseEvent me) {
    rm.regionalManagersMouseEnterd(frame,regionalManag ers,center,east,flag);
    }
    public void mouseExited(MouseEvent me) {
    rm.regionalManagersMouseExited(regionalManagers);
    }
    public void mouseClicked(MouseEvent me) {
    rm.regionalManagersMouseClicked(frame,regionalMana gers,center,north,east);
    flag = true;
    }
    });


    programNumbers = new JLabel(" Program Numbers");
    programNumbers.setForeground(Color.BLACK);
    programNumbers.setToolTipText("Program Numbers");
    programNumbers.addMouseListener(new MouseAdapter() {
    ProgramNumbers pn = new ProgramNumbers();
    public void mouseEntered(MouseEvent me) {
    pn.programNumbersMouseEnterd(frame,programNumbers, center,east,flag);
    }
    public void mouseExited(MouseEvent me) {
    pn.programNumbersMouseExited(programNumbers);
    }
    public void mouseClicked(MouseEvent me) {
    pn.programNumbersMouseClicked(frame,programNumbers ,center,north,east);
    flag = true;
    }
    });


    boxWest.add(audits);
    boxWest.add(dealershipAudits);
    JLabel space = new JLabel(" ");
    boxWest.add(space);
    boxWest.add(reports);
    boxWest.add(dealerPullLists);
    boxWest.add(stateScope);
    boxWest.add(regionalManagers);
    boxWest.add(programNumbers);
    west.add(boxWest);
    frame.getContentPane().add(center,BorderLayout.CEN TER);
    frame.getContentPane().add(west, BorderLayout.WEST);
    frame.getContentPane().add(north, BorderLayout.NORTH);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
    frame.pack();
    frame.setSize(1100,700);
    frame.setVisible(true);

    /*initframe = frame;
    initcenter = center;
    initwest = west;
    initeast = east;
    initnorth = north;*/

    }catch (Exception e) {
    System.out.println("e.getmessage()"+e.toString());
    // TODO: handle exception
    }
    }



    }



    final class ImageLoader {

    private ImageLoader() {
    }

    public static Image getImage(Class relativeClass, String filename) {
    Image returnValue = null;
    InputStream is = relativeClass.getResourceAsStream(filename);
    System.out.println(relativeClass);
    if (is != null) {
    BufferedInputStream bis = new BufferedInputStream(is);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
    int ch;
    while ((ch = bis.read()) != -1) {
    baos.write(ch);
    }
    returnValue = Toolkit.getDefaultToolkit().createImage(
    baos.toByteArray());
    } catch (IOException exception) {
    System.err.println("Error loading: " + filename);
    }
    }
    return returnValue;
    }
    }




    code for RegionalManagers link :
    ------------------------------


    JScrollPane paneReg = new JScrollPane(center);
    frame.getContentPane().add(paneReg);


    then the problem is coming.

    instead of this if i use

    frame.getContentPane().add(center,BorderLayout.CEN TER);

    then data is coming without scroll bar.

    plz help me on this.

    thanks.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Maybe someone can help you, but I'm afraid that that is too much unformatted code for me. If you don't get some decent help soon, I recommend that you trim this code down to the smallest size that is still compilable and still shows your problem (this is called creating an SSCCE), and then post it using code tags so that the code is readable.

    To do this, you will need to paste already formatted code into the forum, highlight this code, and then press the "code" button at the top of the forum Message editor prior to posting the message. Another way is to place the tag &#91;code] at the top of your block of code and the tag &#91;/code] at the bottom, like so:

    Java Code:
    &#91;code]
      // your code block goes here.
      // note the differences between the tag at the top vs the bottom.
    &#91;/code]
    Best of luck!

  6. #6
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    I tried to compile your code:
    Java Code:
    C:\jexp>javac MH.java
    MH.java:136: ')' expected
                        dau.dealershipAuditsMouseEnterd(frame,dealershipAu dits,center,east,fl
    ag);
                                                                          ^
    ...
    MH.java:253: ';' expected
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
                                                                    ^
    65 errors
    
    C:\jexp>

Similar Threads

  1. JScrollPane updation Problem
    By goodwillwins in forum AWT / Swing
    Replies: 22
    Last Post: 09-28-2008, 09:11 AM
  2. [SOLVED] JScrollPane - HELP!
    By terox13 in forum AWT / Swing
    Replies: 8
    Last Post: 05-10-2008, 03:58 AM
  3. jscrollpane problem
    By monkey04 in forum AWT / Swing
    Replies: 2
    Last Post: 01-19-2008, 05:23 AM
  4. help with JScrollPane
    By tommy in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 07:58 PM
  5. JScrollPane not scrolling
    By Riftwalker in forum Advanced Java
    Replies: 2
    Last Post: 07-17-2007, 08:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •