jcolorchooser

How do I show only the HSV box of a JColorChooser?

佐手、 提交于 2021-02-19 03:35:10
问题 In this image you can see a default Java Swing color chooser, JColorChooser : What I want is just the color square and vertical slider as outlined in red: I was able to remove all the tabs (Swatches, HSL, etc) and the preview, but I was unable to remove all the sliders. How can I do this? 回答1: OK, just for grins, I decided to create your desired JPanel from scratch, wiring it up in a kind of View-Controller set up, since the model here is trivial -- a Color field within the controller. To use

Java 7 JColorChooser: Disable Transparency Slider

无人久伴 提交于 2019-12-29 07:35:19
问题 JDK 7 added a new transparency slider to the JColorChooser: The problem is that I do not want to allow my users to pick transparent colors. Unfortunately, there doesn't seem to be an easy way to disable the slider. One way to get rid of the transparency is to just create a new color based on the selected one but removing the alpha value. However, this gives a false impression to the user as the slider now effectively does nothing and I would hate to have a useless UI element around. So my

JColorChooser: hide all default panels and show HSB panel only

烈酒焚心 提交于 2019-12-23 12:04:19
问题 How can I hide all default panels at JColorChooser except HSB ? And is it possible to show just HSB without JTabbedPane, just plain panel Thank you! 回答1: import javax.swing.*; import javax.swing.colorchooser.*; class ColorChooserTest { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JColorChooser cc = new JColorChooser(); AbstractColorChooserPanel[] panels = cc.getChooserPanels(); for (AbstractColorChooserPanel accp : panels) { if (accp

JColorChooser: Save/restore recent colors in Swatches panel

十年热恋 提交于 2019-12-19 10:21:53
问题 I am using a JColorchooser at various places in an application. There can be multiple instances of the panel that can invoke a JColorChooser. The "Swatches" panel in the chooser has an area of "recent" colors , which only persists within each instance of JColorChooser. I would like to (a) have the same "recent" colors in all my choosers in my application, and (b) to save the colors to disk so that these colors survive close and restart of the application. (At least (a) could be solved by

Modifying a color chooser panel

情到浓时终转凉″ 提交于 2019-12-01 23:06:06
问题 I am creating a colour chooser and need to modify one of the colour chooser panels. What I wanted was, I want to enter input values via the RGB fields to set the colour,The problem is the RGB values seem to be disabled is there a method within the api to turn on the RGB inputs to take a value? 回答1: Seems fine here. import javax.swing.*; class ColorChooserTest { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane

Changing a color chooser button's background color in Java

China☆狼群 提交于 2019-11-30 06:01:26
问题 I have a Java button that opens a JColorChooser dialog. I would like for the color of the button to change according to the color selected in the dialog. I have tried calling the setBackgroundColor() method of the button, but in my case it has no effect (the button is on a JToolBar in Winsows 7). Also, this question suggests that changing a button's background is not platform independent. Maybe the answer to this problem is not to use a button in the first place. So, my question is: is there

Java 7 JColorChooser: Disable Transparency Slider

天涯浪子 提交于 2019-11-29 10:31:28
JDK 7 added a new transparency slider to the JColorChooser : The problem is that I do not want to allow my users to pick transparent colors. Unfortunately, there doesn't seem to be an easy way to disable the slider. One way to get rid of the transparency is to just create a new color based on the selected one but removing the alpha value. However, this gives a false impression to the user as the slider now effectively does nothing and I would hate to have a useless UI element around. So my question is, what's the best way to get rid of the transparency slider? P.S.: IMO, it's weird that they

Changing a color chooser button's background color in Java

雨燕双飞 提交于 2019-11-28 13:57:49
I have a Java button that opens a JColorChooser dialog. I would like for the color of the button to change according to the color selected in the dialog. I have tried calling the setBackgroundColor() method of the button, but in my case it has no effect (the button is on a JToolBar in Winsows 7). Also, this question suggests that changing a button's background is not platform independent. Maybe the answer to this problem is not to use a button in the first place. So, my question is: is there a method of showing a "color picker" control in Java that reflects the picked color? Kind of like how

Getting pixel RGB from a bufferedImage from the mouses X and Y position

末鹿安然 提交于 2019-11-28 11:51:36
I am making a color chooser program with an image. The program first loads in the image and then when you hover over the image, it will get the current pixels RGB value off of the mouses X and Y position. I have set up the frame and loaded them image, can someone help me get it working with the pixels? package net.ogpc.settings; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import java.awt

Getting pixel RGB from a bufferedImage from the mouses X and Y position

久未见 提交于 2019-11-27 19:21:53
问题 I am making a color chooser program with an image. The program first loads in the image and then when you hover over the image, it will get the current pixels RGB value off of the mouses X and Y position. I have set up the frame and loaded them image, can someone help me get it working with the pixels? package net.ogpc.settings; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; import javax.swing.ImageIcon