Last active
December 14, 2015 19:39
-
-
Save figengungor/5137832 to your computer and use it in GitHub Desktop.
Java GUI >> Setting Background Color
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.awt.BorderLayout; | |
| import java.awt.Color; | |
| import javax.swing.JFrame; | |
| import javax.swing.JPanel; | |
| public class MyGUI extends JFrame { | |
| JPanel jp1,jp2,jp3; | |
| public MyGUI(){ | |
| setTitle("Background Color Example"); | |
| setSize(300,300); | |
| setVisible(true); | |
| setDefaultCloseOperation(EXIT_ON_CLOSE); | |
| jp1 = new JPanel(); | |
| jp2 = new JPanel(); | |
| jp3 = new JPanel(); | |
| jp1.setBackground(Color.BLUE); | |
| add(jp1); | |
| jp2.setBackground(Color.RED); | |
| add(jp2, BorderLayout.WEST); | |
| jp3.setBackground(Color.GREEN); | |
| add(jp3, BorderLayout.EAST); | |
| } | |
| public static void main(String [] args) { | |
| new MyGUI(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment