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

  • Home
  • SEARCH
  • 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 679333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:14:54+00:00 2026-05-14T01:14:54+00:00

I have a JInternalFrame painted with a BufferedImage and contained in the JDesktopPane of

  • 0

I have a JInternalFrame painted with a BufferedImage and contained in the JDesktopPane of a JFrame. I also have a JTextArea where I want to write some java code (function) that takes the current JInternalFrame’s painted BufferedImage as an input and after doing some manipulation on this input it returns another manipulated BufferedImage that paints the JInternalFrame with new manipulated Image again.

Manipulation java code of JTextArea:-

public BufferedImage customOperation(BufferedImage CurrentInputImg) 
{    
    Color colOld;
    Color colNew;

    BufferedImage manipulated=new BufferedImage(CurrentInputImg.getWidth(),CurrentInputImg.getHeight(),BufferedImage.TYPE_INT_ARGB);

    // make all Red pixels of current image black 
    for(int i=0;i< CurrentInputImg.getWidth();i++) {
        for(int j=0;j< CurrentInputImg.getHeight(),j++) { 
            colOld=new Color(CurrentInputImg.getRGB(i,j));
            colNew=new Color(0,colOld.getGreen(),colOld.getBlue(),colOld.getAlpha());
            manipulated.setRGB(i,j,colNew.getRGB());
        } 
    }

    return manipulated;
}

How can I run/compile this JTextArea java code at runtime and get a new
manipulated image for painting on JInternalFrame?

Here is my Main class:

(This class is not actual one but I have created it for you for basic interfacing containing JTextArea,JInternalFrame,Apply Button)

import java.awt.*;    
import java.awt.event.*;    
import javax.swing.*;    
import javax.swing.event.*;    
import javax.swing.JInternalFrame;    
import javax.swing.JDesktopPane;    
import java.awt.image.*;    
import javax.imageio.*;    
import java.io.*;    
import java.io.File;    
import java.util.*;

class MyCustomOperationSystem extends JFrame    
{

    public JInternalFrame ImageFrame;     
    public BufferedImage CurrenFrameImage;

    public MyCustomOperationSystem() {
        setTitle("My Custom Image Operations");
        setSize((int)Toolkit.getDefaultToolkit().getScreenSize().getWidth(), (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight());

        JDesktopPane desktop=new JDesktopPane();
        desktop.setPreferredSize(new Dimension((int)Toolkit.getDefaultToolkit().getScreenSize().getWidth(),(int)Toolkit.getDefaultToolkit().getScreenSize().getHeight()));

        try {
            CurrenFrameImage=ImageIO.read(new File("c:/Lokesh.png"));
        }catch(Exception exp) {
            System.out.println("Error in Loading Image");
        }

        ImageFrame=new JInternalFrame("Image Frame",true,true,false,true);
        ImageFrame.setMinimumSize(new Dimension(CurrenFrameImage.getWidth()+10,CurrenFrameImage.getHeight()+10));
        ImageFrame.getContentPane().add(CreateImagePanel());
        ImageFrame.setLayer(1);
        ImageFrame.setLocation(100,100);
        ImageFrame.setVisible(true);  
        desktop.setOpaque(true);
        desktop.setBackground(Color.darkGray);
        desktop.add(ImageFrame);
        this.getContentPane().setLayout(new BorderLayout());
        this.getContentPane().add("Center",desktop);
        this.getContentPane().add("South",ControlPanel());
        pack();
        setVisible(true);
    }

    public JPanel CreateImagePanel() {
        JPanel tempPanel=new JPanel() {
            public void paintComponent(Graphics g) {
                g.drawImage(CurrenFrameImage,0,0,this);
            }
        };

        tempPanel.setPreferredSize(new Dimension(CurrenFrameImage.getWidth(),CurrenFrameImage.getHeight()));
        return tempPanel;
    }

    public JPanel ControlPanel() {
        JPanel controlPan=new JPanel(new FlowLayout(FlowLayout.LEFT));
        JButton customOP=new JButton("Custom Operation");

        customOP.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evnt) {
                JFrame CodeFrame=new JFrame("Write your Code Here");
                JTextArea codeArea=new JTextArea("Your Java Code Here",100,70);
                JScrollPane codeScrollPan=new JScrollPane(codeArea,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
                CodeFrame.add(codeScrollPan);
                CodeFrame.setVisible(true);
            }
        });

        JButton Apply=new JButton("Apply Code");

        Apply.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent event){

             // What should I do!!! Here!!!!!!!!!!!!!!!

            }
        });

        controlPan.add(customOP);
        controlPan.add(Apply);
        return controlPan;
    }

    public static void main(String s[]) {
        new MyCustomOperationSystem();
    }
}

Note: in the above class JInternalFrame (ImageFrame) is not visible even though I have declared it visible. So, ImageFrame is not visible while compiling and running the above class. You have to identify this problem before running it.

  • 1 1 Answer
  • 2 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-05-14T01:14:54+00:00Added an answer on May 14, 2026 at 1:14 am

    Take a look at the Java 6 Compiler API

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JDesktopPane containing some JInternalFrames. I want some menus on the menubar
I have a JInternalFrame and I need to get some Information from user (a
I have a strange problem... I have a JFrame and added two JInternalFrame I
I am creating a Swing Application. I have one main JFrame and a JDesktopPane
Have some code: using (var ctx = new testDataContext()) { var options = new
So I have created some demo code, see below. What I am seeing is
have a php code like this,going to convert it in to C#. function isValid($n){
I have a JDesktopPane which contains a number of JInternalFrame s. I'd like to
I have a JDesktopPane and a JInternalFrame. I'd like the JInternalFrame to automatically maximize
I have a JFrame with the JDesktopPane and inside the JDesktopPane, I launch with

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.