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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:46:02+00:00 2026-05-31T13:46:02+00:00

I can seek the items randomly in Jlist with a next button. When I

  • 0

I can seek the items randomly in Jlist with a next button. When I press the next button fastly, I’m getting the exception: Exception in thread “Thread-7” java.lang.ClassCastException: sun.java2d.NullSurfaceData cannot be cast to sun.java2d.d3d.D3DSurfaceData
So since the frequency of clicking next triggers this problem can we say there’s something wrong with threads? As a note there is no update in jlist. Jlist is been initialized and filled with elements at start and then just seeking the items randomly with the next button.
If I remove ensureIndexIsVisible then there’s no trouble.

I hope below summary code helps:

public class B_Object {
    private NewJFrame njf = new NewJFrame();
    HandlePlay hPlay = new HandlePlay(njf);

    njf.nextButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            playNext();                
        }
    });
}

public class HandlePlay {
    private NewJFrame n_j_f;
    HandlePlay(NewJFrame njf){
        n_j_f = njf;
    }
    private void setDisplay(int i) {
        String str = "dummy";
        n_j_f.jList1.setSelectedIndex(i);
        n_j_f.setTitle(str);
        n_j_f.jTextArea1.setText(str);
        n_j_f.jList1.ensureIndexIsVisible(n_j_f.jList1.getSelectedIndex());
    }
}
  • 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-05-31T13:46:04+00:00Added an answer on May 31, 2026 at 1:46 pm

    After trying different threads and searching the event dispatch thread I found it’s related with EDT. To solve this issue following modification is enough:

    private void test(final int i) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                jList1.setSelectedIndex(i);
                System.out.println("javax.swing.SwingUtilities.isEventDispatchThread()=" + javax.swing.SwingUtilities.isEventDispatchThread());
                jList1.ensureIndexIsVisible(i);
            }
        });
    }
    

    So make sure that if you have such gui problems intermittenly occuring, check if you’re doing that operation within the EDT, checking by isEventDispatchThread().

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

Sidebar

Related Questions

This question is to seek out good examples of Hungarian Notation, so we can
Is there a way that I can seek to a certain line in a
<div id=myDIV> <div> <span> <a href=#>Seek me!</a> </span> </div> </div> How can I find
How can I get my video player to skip/seek to a certain time. I
I seek some full featured async http client (using NIO, not thread per connection),
How can I create a stepped seek bar for an android interface, one that
I cannot get James Taylor's excellent little seek-bzip2 to compile under Windows? It can
For some reason i can not seek my utf16 file. It produces 'UnicodeException: UTF-16
I've opened a file in ruby with the options a+. I can seek to
How can I seek those rows which contain some text and get a mark

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.