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 8634375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:42:31+00:00 2026-06-12T09:42:31+00:00

I have a 9×9 panel, which is panel1[][] each panel has a JLabel, so

  • 0

I have a 9×9 panel, which is panel1[][]
each panel has a JLabel, so label1[][]

and I add each label to the panel in for loop:

for (int y = 0; y < 9; y++) {
        for (int x = 0; x < 9; x++) {
            label[y][x] = new Grid(x, y);
            panel1[y][x].add(label[y][x]);                
        }
    }

The main goal is to be able to add a addUndoableEditListener() to each of these JLabels.
Users will select a number(int) to place in the JLabel, I want them to be able to undo/redo their selection, by clicking the undo/redo button.

I tried:

UndoManager manager = new UndoManager();
label1.addUndoableEditListener(manager);

However I saw that apprently you cannot add “UndoableEditListener” to JLabels. (Right?)

I saw some examples where you could add “UndoableEditListener” to JTextPane, so I though maybe I could create a JTextPane pane [9][9], and add a textpane to each of the JLabels(which are added to the JPanel). So this would solve the problem of UndoableEditListener.

Does this seem logical? I would really appreciate an easier approach to this, all suggestions welcome : )

I’m just having some problem with adding the UndoableEditListener to the components.

(I would prefer to keep the JLabel, since I need to be able to change the background color feature, otherwise is there a better way??)

Thanks.

  • 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-12T09:42:32+00:00Added an answer on June 12, 2026 at 9:42 am

    It looks like you don’t really want a JLabel. If you want it to be editable (and undoable), why not a JTextField?

    A JTextField can have its background color changed as well as a JLabel:

    JTextField tf = new JTextField();
    tf.setColor(Color.RED);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIImageView which is in an animation loop. I want to detect
I have an .xml file which has an accompanying .xsl file. The output of
Have dict like: mydict= {'a':[],'b':[],'c':[],'d':[]} list like: log = [['a',917],['b', 312],['c',303],['d',212],['a',215],['b',212].['c',213],['d',202]] How do i
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
Have deployed numerous report parts which reference the same view however one of them
I have two user controls which needs to be loaded dynamically based on a
I have an xts object, the first column of which is date-time, followed by
I have a file which is space delimited which looks like this: probeset_id submitted_id
I have a table which extends AbstractTableModel. When data for it arrives, i delete

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.