Results 1 to 7 of 7
  1. #1
    AnteeN is offline Member
    Join Date
    Dec 2011
    Posts
    11
    Rep Power
    0

    Default Have Problems Implementing Grid View

    Hello all i have a problem implementing a code into my code.

    I need some guidance where i am doing it wrong?

    The code i am trying to implement is;

    setLayout(new GridLayout(2, 2));
    ScrollingImagePanel panel = new ScrollingImagePanel(image1, width, height);
    add(new ScrollingImagePanel(im1, width, height));
    add(new ScrollingImagePanel(im2, width, height));
    add(new ScrollingImagePanel(im3, width, height));
    add(new ScrollingImagePanel(im4, width, height));
    pack();
    show();

    The code that i am trying to implement in is;

    Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BIL INEAR);
    ParameterBlock params = new ParameterBlock();
    //System.out.println(ImPath[i]);
    RenderedImage image = (RenderedImage)JAI.create("fileload",ImPath[i]);
    params.addSource(image);
    params.add(0.5F); // x scale factor
    params.add(0.5F); // y scale factor
    params.add(0.0F); // x translate
    params.add(0.0F); // y translate
    params.add(interp); // interpolation method
    RenderedOp image1 = JAI.create("scale", params);
    int width = image1.getWidth();
    int height = image1.getHeight();
    Frame window = new Frame("Scrolling Image Panel Example");
    window.add(panel);
    window.pack();
    window.show();

    I need to show the images in a grid view.

    Does anyone has a clue?

    Kind Regards
    ömer kaya
    METU

  2. #2
    AnteeN is offline Member
    Join Date
    Dec 2011
    Posts
    11
    Rep Power
    0

    Default Re: Have Problems Implementing Grid View

    RenderedImage image = (RenderedImage)JAI.create("fileload",ImPath[i]);
    params.addSource(image);
    params.add(0.5F); // x scale factor
    params.add(0.5F); // y scale factor
    params.add(0.0F); // x translate
    params.add(0.0F); // y translate
    params.add(interp); // interpolation method
    RenderedOp image1 = JAI.create("scale", params);
    int width = image1.getWidth();
    int height = image1.getHeight();
    ScrollingImagePanel panel = new ScrollingImagePanel(image1, width, height);
    int ImCount = list.getItemCount();
    int DGridW = 0;
    int DGridH = 0;

    if ((ImCount % 2) == 0)
    {
    DGridW = ImCount / 2; //Display Grid Assignment Width
    DGridH = ImCount / 2; //Display Grid Assignment Height
    }
    else
    {
    int ImCountEven = (ImCount+1);
    DGridW = ImCountEven / 2; //Display Grid Assignment Width
    DGridH = ImCountEven / 2; //Display Grid Assignment Height
    }
    panel.setLayout(new GridLayout(DGridW,DGridH));
    panel.add(new ScrollingImagePanel(image1, width, height));
    Frame window = new Frame(" " + ImPath[i]);
    //window.add(panel);
    window.pack();
    window.show();

    This is what i can do so far but i get the exception of;

    Exception in thread "AWT-EventQueue-0" java.awt.AWTError: ScrollPane controls layout
    at java.awt.ScrollPane.setLayout(Unknown Source)
    at CamCalib$3.actionPerformed(CamCalib.java:143)

    143 = panel.setLayout(new GridLayout(DGridW,DGridH));

    Any clues?

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Have Problems Implementing Grid View

    What is the definition of the ScrollingImagePanel class?

  4. #4
    AnteeN is offline Member
    Join Date
    Dec 2011
    Posts
    11
    Rep Power
    0

    Default Re: Have Problems Implementing Grid View

    Thank you for the reply.

    Definition;

    Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.

    thanks.
    ökaya

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Have Problems Implementing Grid View

    If you can't say how the ScrollingImagePanel class is defined, then not much can be done

  6. #6
    AnteeN is offline Member
    Join Date
    Dec 2011
    Posts
    11
    Rep Power
    0

    Default Re: Have Problems Implementing Grid View

    hmmm...

    I have searched the web..

    setLayout

    public final void setLayout(LayoutManager mgr)
    Sets the layout manager for this container. This method is overridden to prevent the layout mgr from being set.
    Overrides:
    setLayout in class Container
    Parameters:
    mgr - the specified layout manager

    information came out but as i am a Newbie... I can not understand what it means.

    regards
    ömer kaya
    metu

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: Have Problems Implementing Grid View

    Presuming (from the error message) ScrollingImagePanel extends JScrollPane then, from the API for setLayout:
    "
    This method overrides setLayout in java.awt.Container to ensure that only LayoutManagers which are subclasses of ScrollPaneLayout can be used in a JScrollPane.
    "

Similar Threads

  1. How enter this mode-gui/design-view/code-view
    By lse123 in forum NetBeans
    Replies: 0
    Last Post: 02-28-2010, 09:09 PM
  2. Problems implementing Java string methods
    By everlast88az in forum New To Java
    Replies: 8
    Last Post: 11-06-2008, 04:17 AM
  3. Problems with JFrame losing the Design view
    By chris@gaiag.net in forum NetBeans
    Replies: 7
    Last Post: 07-23-2008, 07:35 AM
  4. Replies: 1
    Last Post: 07-18-2007, 11:20 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
  •