We help IT Professionals succeed at work.

Change background colour of JInternalFrame

zolf
zolf asked
on
1,631 Views
Last Modified: 2013-11-23
Hello thre,

How can i change the background colour of all my JInternal Frame in my application.Thanks in advance

cheers
Zolf
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

Commented:
jif.getContentPane().setBackground(Color.BLUE);
ksivananthVice President

Commented:
internalFrame.setBackground( Color.WHITE ) ;

Author

Commented:

i tried this myself begore,but did not change the BG

getContentPane().add(main);
getContentPane().add(toolBar,BorderLayout.NORTH);

getContentPane().setBackground(Color.BLUE);

setVisible(true);
ksivananthVice President

Commented:
try setting that color to main,

main.setBackground( Color.WHITE ) ;

Author

Commented:

>>main.setBackground( Color.WHITE ) ;
i did not understand
CERTIFIED EXPERT
Top Expert 2016
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:

this is one of my JInternalFrame code
public StoringRMaterialWHInvoiceInternalFrame(int parentWidth, int parentHeight, boolean rightToLeftAllignment,String currentUser,int currentUserId,Connection connection) {
		super(getTranslationKeyDefault("Receiving & Storing"), 
				true, //resizable
				true, //closable
				true, //maximizable
				true);//iconifiable
		this.conn=connection;
		this.currentUser=currentUser;
		this.currentUserId=currentUserId;
		this.rightToLeftAlligned=rightToLeftAllignment;
		
		setSize(950,500);
		setMinimumSize(new Dimension(950,500));
		//setBackground(Color.BLUE);
		//Set the window's location.
		setLocation(Math.min(xOffset*openFrameCount,parentWidth-xOffset), Math.min(yOffset*openFrameCount,parentHeight-xOffset));
		openFrameCount++;
		addInternalFrameListener(new InternalFrameAdapter(){
			@Override
			public void internalFrameClosed(InternalFrameEvent e) {
				super.internalFrameClosed(e);
				openFrameCount--;
			}
		});
		
		receivingReceiptNumberTF=new JTextField();
		receivingReceiptNumberTF.setEditable(false);
 
		supplierInvoiceNoTF=new JTextField();
		supplierInvoiceNoTF.setEditable(false);
		totalTF=new JTextField();
		totalTF.setEditable(false);
		
		totalCTF=new JTextField();
		totalCTF.setEditable(false);
 
		previousReportsList=new JList(new DefaultListModel());
		
		initPreviousReportsList();
		
		
				
				
		
		getContentPane().add(main);
		getContentPane().add(toolBar,BorderLayout.NORTH);
		
		lockForm();
		initInvoices();
		initSlider();
		ignoreChanges=false;
		reinitSlider();
		if(rightToLeftAllignment)
		{
			StoringRMaterialWHInvoiceInternalFrame.this.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		}
			
		GUITools.makeSameSize(label2,label3);
 
		
		getContentPane().setBackground(Color.BLUE);
		setVisible(true);
	}

Open in new window

Author

Commented:
i tried this

main.setBackground(Color.BLUE);

but then i get blue colour,but only some parts.
CERTIFIED EXPERT
Top Expert 2016

Commented:
>>but then i get blue colour,but only some parts.

Well, probably because there are components on top - that's how it works
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
need something like:

main.setOpaque(false);
getContentPane().setBackground(Color.BLUE);


Author

Commented:

i changed my code to this.it looks like this.

main.setOpaque(false);
getContentPane().setBackground(Color.BLUE);
setVisible(true);
3.JPG

Author

Commented:

so i cannot change the look of the JInternal Frame
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
you need to make those other components opaque, OR
change their background colour as well.

If you're after a standard look across your app then its oftn easier to instead change the default colours using UIManager

CERTIFIED EXPERT
Top Expert 2016

Commented:
Yes, the blue bits are the background - i'm wondering why *any* background is showing - it must be a reasonably complex layout

Author

Commented:

>>If you're after a standard look across your app then its oftn easier to instead change the default colours using UIManager

yes i want to have a standard colour for all my Internal Frame.for e.g. all my JInternal Frame should have light blue colour.

Author

Commented:

what do you guys say.is it good to change the BG Colour or keep the default frame.what are your suggestions
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
CERTIFIED EXPERT
Top Expert 2016

Commented:
I would actually change your layout until any and all of that blue disappears. Otherwise, you're wasting screen real estate

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.