Example usage for javax.swing JColorChooser showDialog

List of usage examples for javax.swing JColorChooser showDialog

Introduction

In this page you can find the example usage for javax.swing JColorChooser showDialog.

Prototype

public static Color showDialog(Component component, String title, Color initialColor) throws HeadlessException 

Source Link

Document

Shows a modal color-chooser dialog and blocks until the dialog is hidden.

Usage

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void cloudButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_cloudButtonActionPerformed
{//GEN-HEADEREND:event_cloudButtonActionPerformed

    final Color newColour = JColorChooser.showDialog(this, "Choose Cloud Colour", cloudButton.getBackground());

    if (newColour != null) {
        /// then a new colour was chosen
        final float[] comps = newColour.getRGBColorComponents(null);

        final CloudParameters params = this.parent.getParameters().getCloudParameters();

        final FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]);
        params.setColour(newRGB);//from  w  w  w.jav a2  s  .  c  om
        cloudButton.setBackground(newColour);
    }
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void fogButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_fogButtonActionPerformed
{//GEN-HEADEREND:event_fogButtonActionPerformed

    final Color newColour = JColorChooser.showDialog(this, "Choose Fog Colour", fogButton.getBackground());

    if (newColour != null) {
        /// then a new colour was chosen
        final float[] comps = newColour.getRGBColorComponents(null);

        final RenderParameters params = this.parent.getParameters().getRenderParameters();

        FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]);
        params.setFogColour(newRGB);/* ww  w  .  j  a  v a 2 s . co m*/
        fogButton.setBackground(newColour);
    }
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void sunlightButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_sunlightButtonActionPerformed
{//GEN-HEADEREND:event_sunlightButtonActionPerformed

    Color newColour = JColorChooser.showDialog(this, "Choose Ambient Light Colour",
            sunlightButton.getBackground());

    if (newColour != null) {
        /// then a new colour was chosen
        float[] comps = newColour.getRGBColorComponents(null);

        final RenderParameters params = this.parent.getParameters().getRenderParameters();

        final FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]);
        params.setSunColour(newRGB);/*from  ww w .  ja  v  a2  s .c  o  m*/
        sunlightButton.setBackground(newColour);
    }
}

From source file:AppearanceExplorer.java

public void actionPerformed(ActionEvent e) {
    Color currentColor = color3f.get();
    Color newColor = JColorChooser.showDialog(this, name, currentColor);
    if (newColor != null) {
        color3f.set(newColor);/*from  www  . j a  va2s.co  m*/
        color.x = color3f.x;
        color.y = color3f.y;
        color.z = color3f.z;
        valueChanged();
    }
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void snowButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_snowButtonActionPerformed
{//GEN-HEADEREND:event_snowButtonActionPerformed

    final Color newColour = JColorChooser.showDialog(this, "Choose Snow Colour", snowButton.getBackground());

    if (newColour != null) {
        /// then a new colour was chosen
        final float[] comps = newColour.getRGBColorComponents(null);

        final TerrainParameters params = this.parent.getParameters().getTerrainParameters();

        final FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]);
        params.setColourSnow(newRGB);/*from ww w  . ja v  a 2s  .  c  o  m*/
        snowButton.setBackground(newColour);
    }
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void shorelineButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_shorelineButtonActionPerformed
{//GEN-HEADEREND:event_shorelineButtonActionPerformed

    final Color newColour = JColorChooser.showDialog(this, "Choose Shoreline Colour",
            shorelineButton.getBackground());

    if (newColour != null) {
        /// then a new colour was chosen
        final float[] comps = newColour.getRGBColorComponents(null);

        final TerrainParameters params = this.parent.getParameters().getTerrainParameters();

        final FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]);
        params.setColourShoreline(newRGB);
        shorelineButton.setBackground(newColour);
    }/*from  w  ww  . j av a  2s .c om*/
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void riverButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_riverButtonActionPerformed
{//GEN-HEADEREND:event_riverButtonActionPerformed

    final Color newColour = JColorChooser.showDialog(this, "Choose River Colour", riverButton.getBackground());

    if (newColour != null) {
        /// then a new colour was chosen
        final float[] comps = newColour.getRGBColorComponents(null);

        final TerrainParameters params = this.parent.getParameters().getTerrainParameters();

        final FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]);

        params.setColourRiver(newRGB);//from   ww  w  .  j a  v  a  2 s.  c o  m
        riverButton.setBackground(newColour);
    }
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void oceanButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_oceanButtonActionPerformed
{//GEN-HEADEREND:event_oceanButtonActionPerformed

    final Color newColour = JColorChooser.showDialog(this, "Choose Ocean Colour", oceanButton.getBackground());

    if (newColour != null) {
        /// then a new colour was chosen
        final float[] comps = newColour.getRGBColorComponents(null);

        final TerrainParameters params = this.parent.getParameters().getTerrainParameters();

        final FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]);

        params.setColourOcean(newRGB);/*w  w w  .  j  a  va 2 s . com*/
        oceanButton.setBackground(newColour);
    }
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void highTerrainButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_highTerrainButtonActionPerformed
{//GEN-HEADEREND:event_highTerrainButtonActionPerformed

    final Color newColour = JColorChooser.showDialog(this, "Choose High Terrain Colour",
            highTerrainButton.getBackground());

    if (newColour != null) {
        /// then a new colour was chosen
        final float[] comps = newColour.getRGBColorComponents(null);

        final TerrainParameters params = this.parent.getParameters().getTerrainParameters();

        final FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]);
        params.setColourHigh(newRGB);//from  ww w  .  ja v  a2  s.  c o  m
        highTerrainButton.setBackground(newColour);
    }
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void lowTerrainButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_lowTerrainButtonActionPerformed
{//GEN-HEADEREND:event_lowTerrainButtonActionPerformed

    final Color newColour = JColorChooser.showDialog(this, "Choose Low Terrain Colour",
            lowTerrainButton.getBackground());

    if (newColour != null) {
        /// then a new colour was chosen
        final float[] comps = newColour.getRGBColorComponents(null);

        final TerrainParameters params = this.parent.getParameters().getTerrainParameters();

        final FloatRGBA newRGB = new FloatRGBA(comps[0], comps[1], comps[2]);
        params.setColourLow(newRGB);//from ww w .  j  a  v  a2  s.co m
        lowTerrainButton.setBackground(newColour);
    }
}