Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    Default Is it possible to color a JFrame within certain Bounds?

    Is it possible to Color only a certain part of a JFrame? As shown in the Image? If yes...How?

    Thanks.
    Attached Thumbnails Attached Thumbnails Is it possible to color a JFrame within certain Bounds?-untitled.jpg  

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    Quote Originally Posted by Lykanthric_Aura View Post
    If yes...How?
    There are a few ways!
    You could paint the orange part in a jpanel
    Java Code:
    	public static void main(String[] args) throws Exception {
    		SwingUtilities.invokeLater(new Runnable() {
    			public void run() {
    				JFrame frame = new JFrame();
    				JPanel panel = new JPanel(){
    					{
    						setSize(400, 300);
    						setPreferredSize(getSize());
    					}
    					@Override
    					protected void paintComponent(Graphics g) {
    						super.paintComponent(g);
    						g.setColor(new Color(255 ,128, 65));
    						g.fillRect(50, 50, 300, 200);
    					}
    				};
    				frame.add(panel);
    				frame.pack();
    				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    				frame.setLocationRelativeTo(null);
    				frame.setVisible(true);
    			}
    		});
    	}
    or put/add the jpanel to the right position and change the background color of the panel
    Java Code:
    setBackground(new Color(255 ,128, 65))
    ...
    It depends on what kind of application that is and what do you want to show on it

Similar Threads

  1. Change border color from blue to green of JFrame
    By altu57 in forum AWT / Swing
    Replies: 1
    Last Post: 07-10-2010, 05:19 AM
  2. Change JFrame taskbar color?
    By dunafrothint in forum AWT / Swing
    Replies: 3
    Last Post: 03-05-2010, 06:14 AM
  3. [COLOR="Navy"]execute .bat file in mysql [/COLOR]
    By msankar.ravi in forum Networking
    Replies: 0
    Last Post: 02-24-2010, 05:27 AM
  4. JFrame window doesnt change background color
    By Addez in forum New To Java
    Replies: 7
    Last Post: 11-07-2009, 10:38 PM
  5. setting background color of JFrame form with NetBeans 6.1
    By onefootswill in forum New To Java
    Replies: 4
    Last Post: 08-12-2008, 08:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •