-3

I'm trying to make a tool that visually steps through the sorting of an array.

In short, despite threading and forced redraws my GUI does not update. I've read what I can find suggesting everything from threading and adding the drawing to a timer, to forcing redraws, to further separating logic and visual but the behaviour remains the same.

All the code is at https://github.com/anadon/Sorting-Visualization

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
Josh
  • 295
  • 1
  • 9
  • 2
    Please don't force volunteers to slog through all the code. Instead, your job is to first isolate the problem, and then create and post a small but simple complete program that illustrates your problem, an [MCVE](http://stackoverflow.com/help/mcve). Please check the link for the details of this very useful tool. – Hovercraft Full Of Eels Sep 07 '14 at 01:44
  • 1
    Possible [duplicate](http://stackoverflow.com/a/24586106/2587435) – Paul Samsotha Sep 07 '14 at 01:46
  • HFOE: if I knew where to look, I wouldn't be having this problem. – Josh Sep 07 '14 at 01:55
  • Peeskillet: That looks pretty close! Let me try it before I continue. – Josh Sep 07 '14 at 01:55
  • @Josh: but you still have to see how your question as written is not appropriate for an all-volunteer help site. You must do some debugging -- there's no way around this. Else your question risks being closed for not being answerable as presented. – Hovercraft Full Of Eels Sep 07 '14 at 01:57
  • HFOE: Please give me credit, as I've passed this by several people and been trying different things for the last 2 weeks. – Josh Sep 07 '14 at 01:58
  • 1
    Josh, Please don't misinterpret my posts. I'm not saying you haven't tried, not even close. I'm just saying that your question as presented is not appropriate for this site. Do I have to re-iterate that you're asking volunteers to go through mountains of code? You're asking why your code isn't working, but there's little most of us can do to help unless we can see a reasonable amount of compilable and runnable code. – Hovercraft Full Of Eels Sep 07 '14 at 02:02
  • HFOE: I ran out of options. There's nothing more I know of that I could do to trim it down since I lack the experience with java GUIs. If this were a standard C++ program, that'd be no problem. This however, is no C. – Josh Sep 07 '14 at 02:06

1 Answers1

2

I'm not going to read your entire code base (@see Hovercraft Full of Eels comments).

However, it looks like the problem is that you're not trying to update on the GUI thread. You need to rejoin the thread via SwingUtilities.invokeLater(thingThatUpdates)

Some other quick notes, you're not following Java conventions. Class names should be CamelCase not lowerCamelCase. Basically if you work on another thread Swing won't know to update as that thread is "just chillin'" until you tell it to draw.

I'd highly recommend doing something SMALL and TESTABLE so that we can help you out, linking to a non-standard GitHub project is really annoying.

(I think you're probably a student and students who ask should get some help. As with anything, try to clean it up before you come and this community will be infinitely more useful to you.)

Daniel B. Chapman
  • 4,647
  • 32
  • 42
  • I found that the logic did actually get coupled with the model under SwingUtilities.invokeLater. Thanks for being patient. – Josh Sep 07 '14 at 02:33