I am writing a custom Swing component with my own painting. I would like to ask if the current appearance components are opaque or not, and if so, what is their background color so that my component can use it. I find it hard to find this on Google. Somebody knows? Thank!
It is pretty simple:
public class MyComponent extends JComponent { public void paintComponent(Graphics g) { if (this.isOpaque()) { // Paint background g.setColor(this.getBackground()); g.fillRect(0,0,this.getWidth(), this.getHeight()); } g.setColor(this.getForeground()); // Continue painting } }
I do not understand this question. Each component can have a different background color, and what background color do you want to use your custom component?
, LAF JPanel, , , JPanel, .
backgroud , UIManager . . UIManager .
Source: https://habr.com/ru/post/1742724/More articles:Android ACTION_SEND Attached file - androidusing document () function in .NET XSLT generates an error - c #Ошибки функции Document ('') при вызове метода .NET Transform - xmlSaving in HTTP headers using Ruby Net: HTTP - httpИспользование Custom Generic Collection быстрее с объектами, чем List - optimizationhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1742725/redirecting-multiple-stdouts-to-single-file&usg=ALkJrhg1owtJWTy0E9sV5hgy6-O28DOfNQHow to save case with http.get? - ruby | fooobar.cominitialization of structures using user information - c ++call transferFocus or requestFocus? - javaHow can I prevent a user from going to the previous page - asp.netAll Articles