Results 1 to 4 of 4
  1. #1
    koko20 is offline Member
    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0

    Default I need help with GUI using java?

    hey

    I have a project called ImageViewer and within this project I have these classes: DarkerFilter, EdgeFilter, Filter, FishEyeFilter, GrayScaleFilter, ImageDriver, ImageFileManager, ImagePanel, ImageViewer, InvertFilter, LighterFilter, MirrorFilter, OFImage, PixelizeFilter,SmoothFilter, SolarizeFilter and ThresholdFilter.

    Task: is to add my own features to the ImageViewer, which is a scrollbar (V and H) and a next Image button. Problem: i don't know how to write an ActionListener for a scrollbar (vertical and horizontal) and a next Image button (to show the next image that is in the file or folder)??? Also do you need to create the ActionListener in a new class for the scrollbar and the next button or is it okay to be in the ImageViewer class (the ImageViewer class includes: JFrame, ImagePanel, JLabel, OFImage, JButton). I have also done a flip image button but what it does is, is that it only flips half of the image, if you can help me with this one as well, i would really appreciate it. thank you

    <deleted by mod>

    this is what i have so far

    private JButton FlipButton;
    private JButton nextButton;
    private JScrollBar scrollBar1;
    private JScrollBar scrollBar2

    public void flipImage(OFImage image){
    int height = image.getHeight();
    int width = image.getWidth();
    OFImage copy = image;
    for(int x = 0; x < width; x++){
    for(int y = 0; y < height; y++) {
    image.setPixel(x, y, copy.getPixel(width-x-1,y));
    }

    currentImage = image;
    imagePanel.setImage(currentImage);
    frame.pack(); } }

    public void nextButton(){
    ArrayList<ImagePanel> nextImage = new ArrayList<ImagePanel>(); char newIm = ' ';
    for(ImagePanel s: nextImage){
    newIm = s.getClearImage(); } }

    private void setButtonsEnabled(boolean status) { FlipButton.setEnabled(status);
    nextButton.setEnabled(status);
    scrollBar1.setEnabled(status);
    scrollBar2.setEnabled(status); }

    private void makeFrame() {
    FlipButton = new JButton("Flip Image");
    FlipButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { flipImage(currentImage); } });
    toolbar.add(FlipButton);

    nextButton = new JButton("Next Image");
    nextButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { nextButton(); }
    });
    toolbar.add(nextButton);

    scrollBar1 = new JScrollBar (JScrollBar.VERTICAL, 0, 5, 0, 100); frame.add(scrollBar1, BorderLayout.EAST);
    scrollBar2 = new JScrollBar (JScrollBar.HORIZONTAL, 0, 5, 0, 100); frame.add(scrollBar2, BorderLayout.SOUTH); }
    Last edited by Fubarable; 04-04-2011 at 11:02 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,247
    Rep Power
    19

    Default

    Quote Originally Posted by koko20 View Post
    hey

    I have a project called ImageViewer and within this project I have these classes: DarkerFilter, EdgeFilter, Filter, FishEyeFilter, GrayScaleFilter, ImageDriver, ImageFileManager, ImagePanel, ImageViewer, InvertFilter, LighterFilter, MirrorFilter, OFImage, PixelizeFilter,SmoothFilter, SolarizeFilter and ThresholdFilter.

    Task: is to add my own features to the ImageViewer, which is a scrollbar (V and H) and a next Image button. Problem: i don't know how to write an ActionListener for a scrollbar (vertical and horizontal) and a next Image button (to show the next image that is in the file or folder)??? Also do you need to create the ActionListener in a new class for the scrollbar and the next button or is it okay to be in the ImageViewer class (the ImageViewer class includes: JFrame, ImagePanel, JLabel, OFImage, JButton). I have also done a flip image button but what it does is, is that it only flips half of the image, if you can help me with this one as well, i would really appreciate it. thank you

    <deleted by mod>

    this is what i have so far

    private JButton FlipButton;
    private JButton nextButton;
    private JScrollBar scrollBar1;
    private JScrollBar scrollBar2

    public void flipImage(OFImage image){
    int height = image.getHeight();
    int width = image.getWidth();
    OFImage copy = image;
    for(int x = 0; x < width; x++){
    for(int y = 0; y < height; y++) {
    image.setPixel(x, y, copy.getPixel(width-x-1,y));
    }

    currentImage = image;
    imagePanel.setImage(currentImage);
    frame.pack(); } }

    public void nextButton(){
    ArrayList<ImagePanel> nextImage = new ArrayList<ImagePanel>(); char newIm = ' ';
    for(ImagePanel s: nextImage){
    newIm = s.getClearImage(); } }

    private void setButtonsEnabled(boolean status) { FlipButton.setEnabled(status);
    nextButton.setEnabled(status);
    scrollBar1.setEnabled(status);
    scrollBar2.setEnabled(status); }

    private void makeFrame() {
    FlipButton = new JButton("Flip Image");
    FlipButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { flipImage(currentImage); } });
    toolbar.add(FlipButton);

    nextButton = new JButton("Next Image");
    nextButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { nextButton(); }
    });
    toolbar.add(nextButton);

    scrollBar1 = new JScrollBar (JScrollBar.VERTICAL, 0, 5, 0, 100); frame.add(scrollBar1, BorderLayout.EAST);
    scrollBar2 = new JScrollBar (JScrollBar.HORIZONTAL, 0, 5, 0, 100); frame.add(scrollBar2, BorderLayout.SOUTH); }
    Post quoted for posterity.

    Abuse reported for soliciting off forum communication by email.

    db
    Last edited by Fubarable; 04-04-2011 at 11:02 PM.

  3. #3
    koko20 is offline Member
    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0

    Default

    Darryl.Burke I'm not sure what you are saying, but just cuz i'm asking to communicate by e-mail doesn't mean that this is a scam or something. i'm just asking for help thats all.

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

Posting Permissions

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