(Frame owner, boolean modal, Color initialColor,
String buttonName, ActionListener buttonListener)
| 65 | |
| 66 | |
| 67 | public ColorChooser(Frame owner, boolean modal, Color initialColor, |
| 68 | String buttonName, ActionListener buttonListener) { |
| 69 | //super("Color Selector"); |
| 70 | window = new JDialog(owner, Language.text("color_chooser"), modal); |
| 71 | window.getContentPane().setLayout(new BorderLayout()); |
| 72 | |
| 73 | Box box = Box.createHorizontalBox(); |
| 74 | box.setBorder(new EmptyBorder(12, 12, 12, 12)); |
| 75 | |
| 76 | range = new ColorRange(); |
| 77 | Box rangeBox = new Box(BoxLayout.Y_AXIS); |
| 78 | rangeBox.setAlignmentY(0); |
| 79 | //rangeBox.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); |
| 80 | rangeBox.add(range); |
| 81 | box.add(rangeBox); |
| 82 | box.add(Box.createHorizontalStrut(10)); |
| 83 | |
| 84 | slider = new ColorSlider(); |
| 85 | Box sliderBox = new Box(BoxLayout.Y_AXIS); |
| 86 | sliderBox.setAlignmentY(0); |
| 87 | //sliderBox.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); |
| 88 | sliderBox.add(slider); |
| 89 | box.add(sliderBox); |
| 90 | box.add(Box.createHorizontalStrut(10)); |
| 91 | |
| 92 | box.add(createColorFields(buttonName, buttonListener)); |
| 93 | |
| 94 | box.add(Box.createHorizontalStrut(10)); |
| 95 | |
| 96 | window.getContentPane().add(box, BorderLayout.CENTER); |
| 97 | |
| 98 | window.pack(); |
| 99 | window.setResizable(false); |
| 100 | |
| 101 | window.setLocationRelativeTo(null); |
| 102 | |
| 103 | window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
| 104 | window.addWindowListener(new WindowAdapter() { |
| 105 | public void windowClosing(WindowEvent e) { |
| 106 | hide(); |
| 107 | } |
| 108 | }); |
| 109 | Toolkit.registerWindowCloseKeys(window.getRootPane(), actionEvent -> hide()); |
| 110 | Toolkit.setIcon(window); |
| 111 | |
| 112 | colorListener = new ColorListener(); |
| 113 | hueField.getDocument().addDocumentListener(colorListener); |
| 114 | saturationField.getDocument().addDocumentListener(colorListener); |
| 115 | brightnessField.getDocument().addDocumentListener(colorListener); |
| 116 | redField.getDocument().addDocumentListener(colorListener); |
| 117 | greenField.getDocument().addDocumentListener(colorListener); |
| 118 | blueField.getDocument().addDocumentListener(colorListener); |
| 119 | hexField.getDocument().addDocumentListener(colorListener); |
| 120 | |
| 121 | setColor(initialColor); |
| 122 | } |
| 123 | |
| 124 |
nothing calls this directly
no test coverage detected