Answers for "set backround color jframe"

1

background color not applying in jframe

import javax.swing.JFrame;
import java.awt.Color;
import java.awt.EventQueue;

public class ColoredFrame {

  public static void main( String[] args ) {
    EventQueue.invokeLater( new Runnable() {
      @Override
      public void run() {
        JFrame frame = new JFrame( "TestFrame" );
        frame.getContentPane().setBackground( Color.PINK );
        //frame contains nothing, so set size
        frame.setSize( 200, 200 );
        frame.setVisible( true );
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
      }
    } );
  }
}
Posted by: Guest on June-06-2021
0

JFrame background color

setBackground(Color.red);
Posted by: Guest on January-21-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language