How do I change color/customize a JOptionPane window in processing?

I've been trying to use UIManager but couldnt get it to work.

UIManager.put("OptionPane.background", color(0,0,0)); UIManager.put("Panel.background", color(0,0,0));

Example of the JOptionPane I'm using.

void exit(){

  int choice = JOptionPane.showConfirmDialog(null,
   "", JOptionPane.YES_NO_OPTION);
  //println(choice);


  if (choice == JOptionPane.YES_OPTION)
  {

    saveData();
  }


  super.exit();
}

Answers

  • edited January 2018

    use the UI Manager class

  • use the UI Manager class

  • A full example below.

    Kf

    import javax.swing.*;
    import java.awt.Font;
    import java.awt.Color;
    import java.awt.Dimension;
    import javax.swing.UIManager;
    
    void setup() {
    }
    
    void draw() {
    }
    
    void mouseReleased() {
      exit();
    }
    
    void exit() {
    
      UIManager UI=new UIManager();
      UI.put("OptionPane.background", new Color(255, 0, 0));
      UI.put("Panel.background", Color.red);
    
      int choice = JOptionPane.showConfirmDialog(null, "msg", 
        "title", JOptionPane.YES_NO_OPTION);
      //println(choice);
    
    
      if (choice == JOptionPane.YES_OPTION) { 
        println("YES");
      }
    
      if (choice == JOptionPane.NO_OPTION) { 
        println("NO? But WHY?");
      }
    
    
      super.exit();
    }
    
Sign In or Register to comment.