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

The Archive Base Latest Questions

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

I’m working on simple UI that has a scala.swing.Table component. I’d like to sort

  • 0

I’m working on simple UI that has a scala.swing.Table component. I’d like to sort the table rows using java.swing.table.TableRowSorter. The Table class doesn’t provide any API for using a row sorter so I tried setting it directly on the peer

val table = new Table(height, width) {
  import javax.swing.table._
  rowHeight = 25
  autoResizeMode = Table.AutoResizeMode.NextColumn
  showGrid = true
  gridColor = new java.awt.Color(150, 150, 150)
  model = myModel

  peer.setRowSorter(new TableRowSorter(model))
}

Now when I click on the column headings I get the little up/down arrows but the table contents don’t update with the new sort order. If there’s a row selected when I click on the column heading the selection moves to the row where the selected should be in based on the sort order. I’ve added custom comparators that they get called as expected so the sorting is really happening but the table isn’t being updated.

Am I missing something to get the table to update? Is it legitimate to access the underlying JTable peer object?

  • 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-31T01:02:31+00:00Added an answer on May 31, 2026 at 1:02 am

    Answering my own question.

    The scala.swing.Table class doesn’t support the row sorting features added in Java 6. See the Table.scala source file at line 277:

    def apply(row: Int, column: Int): Any = model.getValueAt(row, viewToModelColumn(column))
    
    // TODO: this is Java 6 stuff
    // def apply(row: Int, column: Int): Any = model.getValueAt(viewToModelRow(row), viewToModelColumn(column))
    //def viewToModelRow(idx: Int) = peer.convertRowIndexToModel(idx)
    //def modelToViewRow(idx: Int) = peer.convertRowIndexToView(idx)
    

    I moved the scala.swing files into a different package and built it into my project, then uncommented out the Java 6 stuff and commented out the old apply() method and now table sorting works.

    Here’s a link to the bug report on this. The Java 6 code was added back in August and then removed until the Scala library build switches to Java 6.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am doing a simple coin flipping experiment for class that involves flipping a
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.