Import from internal git
This commit is contained in:
122
src/main/java/ui/implementation/dialogs/GreyScalePicker.java
Normal file
122
src/main/java/ui/implementation/dialogs/GreyScalePicker.java
Normal file
@@ -0,0 +1,122 @@
|
||||
package ui.implementation.dialogs;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class GreyScalePicker extends javax.swing.JDialog
|
||||
{
|
||||
private int couleur;
|
||||
|
||||
/** Creates new form JDialogChoixCouleurNG */
|
||||
public GreyScalePicker(java.awt.Frame parent, boolean modal, int c)
|
||||
{
|
||||
super(parent, modal);
|
||||
couleur = c;
|
||||
|
||||
initComponents();
|
||||
couleur = c;
|
||||
jSlider.setValue(couleur);
|
||||
jPanel.setBackground(new Color(couleur,couleur,couleur));
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
jSlider = new javax.swing.JSlider();
|
||||
jPanel = new javax.swing.JPanel();
|
||||
jButtonOk = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle("Choix du niveau de gris");
|
||||
setResizable(false);
|
||||
jSlider.setMajorTickSpacing(255);
|
||||
jSlider.setMaximum(255);
|
||||
jSlider.setMinorTickSpacing(15);
|
||||
jSlider.setPaintLabels(true);
|
||||
jSlider.setPaintTicks(true);
|
||||
jSlider.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
||||
jSliderStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jPanel.setBorder(javax.swing.BorderFactory.createCompoundBorder(null, javax.swing.BorderFactory.createLineBorder(new Color(255, 0, 0))));
|
||||
javax.swing.GroupLayout jPanelLayout = new javax.swing.GroupLayout(jPanel);
|
||||
jPanel.setLayout(jPanelLayout);
|
||||
jPanelLayout.setHorizontalGroup(
|
||||
jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 62, Short.MAX_VALUE)
|
||||
);
|
||||
jPanelLayout.setVerticalGroup(
|
||||
jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 45, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
jButtonOk.setText("Ok");
|
||||
jButtonOk.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonOkActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(19, 19, 19)
|
||||
.addComponent(jPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
|
||||
.addComponent(jButtonOk, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jButtonOk, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
|
||||
.addComponent(jPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jSlider, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jButtonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOkActionPerformed
|
||||
couleur = jSlider.getValue();
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}//GEN-LAST:event_jButtonOkActionPerformed
|
||||
|
||||
private void jSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSliderStateChanged
|
||||
int valeur = jSlider.getValue();
|
||||
Color c = new Color(valeur,valeur,valeur);
|
||||
jPanel.setBackground(c);
|
||||
}//GEN-LAST:event_jSliderStateChanged
|
||||
|
||||
public int getCouleur() { return couleur; }
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
new GreyScalePicker(new javax.swing.JFrame(), true, 128).setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton jButtonOk;
|
||||
private javax.swing.JPanel jPanel;
|
||||
private javax.swing.JSlider jSlider;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user