31191

swing JTable with ScrollBar - color of square between headers and track

<img src="https://i.stack.imgur.com/zNXXh.png" alt="enter image description here">

I have a JTable with BasicScrollBarUI, I set the headers background color: table.getTableHeader().setBackground(GuiConstants.backgroundColor);

and the scrolbar background color: public class ScrollBarUI extends BasicScrollBarUI {

@Override protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) { c.setBackground(GuiConstants.backgroundColor); }

}

I still have a square between them that its color won't change. does anybody knows how to change it also to their color?

thanks

Answer1:

As shown in How to Use Scroll Panes: Providing Custom Decorations, you can use the scroll pane's setCorner() method to add a colored Component:

JPanel panel = new JPanel(); panel.setBackground(Color.gray); scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, panel);

You may have to set the panel's opacity to true, and you may want to select a suitable color from the the current Look & Feel using the UIMnager.

Recommend

  • How to write my own Sleep function using just time.After?
  • How can I extract URLs from HTML content with a Ruby regexp?
  • Checking channel length becomes unresponsive in `for{ len(c) }`
  • Go Concurrency: Chudnovky's algorithm, slower than sync
  • Converting int and long into string in Go
  • gocron creates multiple instances of task
  • Go constructor type
  • Clojure: log to console when code is being executed in a go block or thread
  • Go: fatal error: all goroutines are asleep - deadlock
  • When and where to check if channel won't get any more data?
  • Clojure core.async, what's the difference between putting (go… ) block inside (doseq ..) and pu
  • How to multiplex channel output in go
  • UIWebView: Disable copy/cut options for a rich text editor
  • Android in-app-billing. When to unregister the ResponseHandler?
  • Get highest value from a file using mSL and mIRC
  • How to display video after getting from json?
  • How do I include superscripts in NSString?
  • Problem glTexGen in Open GL ES 2.0
  • ClipperLib Clip multiple squares with rectangle produces 1 result
  • Get the clicked item in android list
  • WPF: Resize item size to have all items visible
  • How to add an item to a ListView with each Button click
  • How to process binary stream in Wicket like Servlet?
  • draw a B+ tree in latex
  • Winforms: Add a close “x” button in a UserControl
  • What's the name of this finding square root algorithm?
  • Using a canvas object in a thread to do simple animations - Java
  • Highlight and Bold text in JTextPane
  • how to do an event when i swipe from fragment to the other
  • Opengl-es onTouchEvents problem or a draw problem? [closed]
  • Akka Routing: Reply's send to router ends up as dead letters
  • Cannot Parse HTML Data Using Android / JSOUP
  • Java static initializers and reflection
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • Observable and ngFor in Angular 2
  • failed to connect to specific WiFi in android programmatically
  • Unable to use reactive element in my shiny app
  • How can I use threading to 'tick' a timer to be accessed by other threads?