[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Swing objects background color?

Posted on 2005-04-27
13
Medium Priority
?
595 Views
Last Modified: 2013-12-29
Hello,

I building a mp3 player, to look as:

www.members.aol.com/emailsurfer95/jukebox.jpg

I have the icons, but I wondered anyone had a idea of what the background color is on all the swing objects?

Thanks
0
Comment
Question by:EmailSurfer
  • 7
  • 3
  • 2
  • +1
13 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 13874342
Looks like the default component colour to me ;-)
0
 
LVL 92

Expert Comment

by:objects
ID: 13874353
depends on the look and feel and the system colours being used.
0
 

Author Comment

by:EmailSurfer
ID: 13874368
I am using win98, and jkd1.4.

Do you think the output is based on a newer version of windows?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 35

Expert Comment

by:TimYates
ID: 13874371
The image “http://www.members.aol.com/emailsurfer95/jukebox.jpg” cannot be displayed, because it contains errors.

:-D
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13874374
Ahhh...works now...

That's Ocean L&F (I think)...  you want to change it to use the Windows L&F I guess..
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13874381
public static void main(String[] args) {
    try {
        UIManager.setLookAndFeel( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
    } catch (Exception e) { }

    new SwingApplication(); //Create and show the GUI.
}

0
 
LVL 35

Accepted Solution

by:
TimYates earned 120 total points
ID: 13874384
0
 

Author Comment

by:EmailSurfer
ID: 13874641
Thanks

So, when using MS Windows XP the swings objects by defualt would look like the jpg.

And when using win98 and jdk1.4.2, we can tell the Java to display the swing objects in MS XP mode.

Is that correct?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13874673
>> So, when using MS Windows XP the swings objects by defualt would look like the jpg.

They would look like the default Java L&F, yes :-)

>> And when using win98 and jdk1.4.2, we can tell the Java to display the swing objects in MS XP mode.

No, if you are on Win98, the WindowsLookAndFeel will look like Win98 (ish -- it's not perfect in 1.4.2)

If you are on XP, it will try to look like XP (if you are using 1.5 -- I believe)

Tim
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13874680
You should note that I am on Linux, so can't verify this ;-)
0
 

Author Comment

by:EmailSurfer
ID: 13874758
Could I ask finally, in a simple exmple like this.

Where would I add the UIManager.setLookAndFeel lines of code?

thanks

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class LabelTest extends JFrame{

   JTextArea title, authors;

   LabelTest(){
      super("Test GUI");
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      JPanel panel1 = new JPanel();
      panel1.add(new JLabel("Authors"));
      authors = new JTextArea(3,20);

      JScrollPane jsp  = new JScrollPane(authors,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      panel1.add(jsp);

      JPanel panel2 = new JPanel();
      panel2.add(new JLabel("Title"));
      panel2.add(title = new JTextArea(3,20));
      title.setLineWrap(true);
      title.setEditable(false);

      getContentPane().setLayout(new FlowLayout());
      getContentPane().add(panel1);
      getContentPane().add(panel2);

      pack();
      show();
   }

   public static void main(String args[]){
      LabelTest label = new LabelTest();
   }

}
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13874804
here:

   public static void main(String args[]){
      try
      {
          UIManager.setLookAndFeel( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
      }
      catch (Exception e)
      {
         System.err.println( "Error setting Look and Feel" ) ;
      }
      LabelTest label = new LabelTest();
   }
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month20 days, 10 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question