Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7804825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:03:00+00:00 2026-06-02T02:03:00+00:00

I m making App in netbeans platform using java swing Technology.I want to do

  • 0

I m making App in netbeans platform using java swing Technology.I want to do image processing oncaptured image.This image is capture by X-Ray Gun.after that i want to increase/decrease brightness of image using JSlider.I done this using paintComponent(Graphics g) method. but i want to do direct effect of increased/decreased brightnees of image without using paintComponenet(Graphics g) method.so how can i do that? My code is shown below. In my code i use PlanarImage and BufferedImage class of JAI library for load .tiff imge and after that i use statechange event of JSlider object for increase/decrease brightness of image.

enter code here

 import java.awt.BorderLayout;
 import java.awt.Graphics;
 import java.awt.image.BufferedImage;
 import java.awt.image.RescaleOp;
 import javax.media.jai.JAI;
 import javax.media.jai.PlanarImage;
 import javax.swing.*;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;

 public class Main extends JPanel implements ChangeListener {

 RescaleOp op;
 PlanarImage image = JAI.create("fileload", "F:\\java\\aimages\\teeth1.tiff");
 BufferedImage bufferedImage = image.getAsBufferedImage();
 BufferedImage bImage;

 int x1 = bufferedImage.getWidth();
 int y1 = bufferedImage.getHeight();

 JSlider slider = new JSlider(-10, 10);

 public Main() {
     bImage=bufferedImage; 
     slider.addChangeListener(this);
    this.add(slider, BorderLayout.class);
    // this.add(new JLabel(new ImageIcon(bufferedImage)), BorderLayout.NORTH);

 }

 @Override
 protected void paintComponent(Graphics g) {
    g.drawImage(bufferedImage, 0, 0, x1, y1, null);
 }

 public static void main(String[] argv) throws Exception {

    JFrame jFrame = new JFrame();
    jFrame.add(new Main());
    jFrame.setVisible(true);
    jFrame.setSize(200, 200);
    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

 }

 @Override
 public void stateChanged(ChangeEvent e) {
    JSlider slid = (JSlider) e.getSource();
    float value = (float) slid.getValue();
    setValue(value);
 }

 private void setValue(float value) {

    bufferedImage=bImage;
    float scaleFactor = (float) (1.0 + (value / 10.0));
    op = new RescaleOp(scaleFactor, 0, null);
    bufferedImage = op.filter(bufferedImage, null);
    repaint();

 }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:03:01+00:00Added an answer on June 2, 2026 at 2:03 am

    It’s not clear why you want to avoid paintComponent(), but you can always alter the BufferedImage in a JLabel‘s ImageIcon using RescaleOp.

    Addendum: I sounds like you don’t want to overwrite the original image, so naturally it makes sense to alter a copy. Unfortunately, your example merely copies a reference to the original. Instead, use two copies, passing the original as src and the copy as dst, as shown the example below. See also AlphaTest.

    import java.awt.BorderLayout;
    import java.awt.EventQueue;
    import java.awt.image.BufferedImage;
    import java.awt.image.RescaleOp;
    import javax.media.jai.JAI;
    import javax.media.jai.PlanarImage;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JSlider;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    
    /**
     * @see https://stackoverflow.com/q/10208255/230513
     * @see https://stackoverflow.com/questions/5838842
     * @see https://stackoverflow.com/questions/5864490
     */
    public class RescaleTest extends JPanel implements ChangeListener {
    
        private static final String NAME = "image.jpg";
        private BufferedImage image, copy;
        private JSlider slider = new JSlider();
    
        public RescaleTest() {
            PlanarImage pi = JAI.create("fileload", NAME);
            image = pi.getAsBufferedImage();
            copy = pi.getAsBufferedImage();
            this.setLayout(new BorderLayout());
            this.add(new JLabel(new ImageIcon(copy)));
            this.add(slider, BorderLayout.SOUTH);
            slider.setValue(slider.getMaximum() / 2);
            slider.addChangeListener(this);
        }
    
        @Override
        public void stateChanged(ChangeEvent e) {
            float value = (float) slider.getValue();
            float scaleFactor = 2 * value / slider.getMaximum();
            RescaleOp op = new RescaleOp(scaleFactor, 0, null);
            copy = op.filter(image, copy);
            repaint();
        }
    
        private void display() {
            JFrame f = new JFrame("RescaleTest");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(this);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        }
    
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    new RescaleTest().display();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m making app in netbeans platform in java using Swing technology for dentist.
I am making an app in Netbeans using Java Swing. I want to achieve
i m making APP which do image proceesing using java SE.i want to check
I making App in Netbeans Platform using Java SE for Dentist.In my App i
Im making a portion of my app using the netbeans gui editor. Great so
I'm making this app with a tableview and stuff. I want to make a
I'm making an app for Mac OS X using Xcode, and I want it
I'm making an app with interface builder using storyboarding. I want to have a
I am making an app in which i am stuck in this exception -
I am making an app in which i have to draw image in canvas

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.