Tweak Javas Look and Feel

Hello everybody,
just wondering if you can help me here, I want to tweak the Look and Feel of some of the objects within a program such a menu backgrounds etc. I think that I am the right lines with this but it does not appear to do anything
I have a class which is called DefaultDEFTheme in this I am declaring the following lines:
public ColorUIResource getRedBackground()/*Could this be problem because getRedBackground does not exist?*/
return new ColorUIResource(255, 0, 0);
Then I have a class that is called DEFLookandFeel and I want to set the colors in the UIDefaults table, so for instance this is the code if I wanted to change the menu background
protected void initSystemColorDefaults(UIDefaults table)
Object[] systemColors = {
"desktop", getDesktopColor(), /* Color of the desktop background */
"activeCaption", getWindowTitleBackground(), /* Color for captions (title bars) when they are active. */
"activeCaptionText", getWindowTitleForeground(), /* Text color for text in captions (title bars). */
"activeCaptionBorder", getPrimaryControlShadow(), /* Border color for caption (title bar) window borders. */
"inactiveCaption", getWindowTitleInactiveBackground(), /* Color for captions (title bars) when not active. */
"inactiveCaptionText", getWindowTitleInactiveForeground(), /* Text color for text in inactive captions (title bars). */
"inactiveCaptionBorder", getControlShadow(), /* Border color for inactive caption (title bar) window borders. */
"window", getWindowBackground(), /* Default color for the interior of windows */
"windowBorder", getControl(), /* ??? */
"windowText", getUserTextColor(), /* ??? */
"menu", getMenuBackground(), /* Background color for menus, I am right in presuming this does not change? */
"menuText", getMenuForeground(), /* Text color for menus */
"text", getWindowBackground(), /* Text background color */
"textText", getUserTextColor(), /* Text foreground color */
"textHighlight", getTextHighlightColor(), /* Text background color when selected */
"textHighlightText", getHighlightedTextColor(), /* Text color when selected */
"textInactiveText", getInactiveSystemTextColor(), /* Text color when disabled */
"control", getControl(), /* Default color for controls (buttons, sliders, etc) */
"controlText", getControlTextColor(), /* Default color for text in controls */
"controlHighlight", getControlHighlight(), /* Specular highlight (opposite of the shadow) */
"controlLtHighlight", getControlHighlight(), /* Highlight color for controls */
"controlShadow", getControlShadow(), /* Shadow color for controls */
"controlDkShadow", getControlDarkShadow(), /* Dark shadow color for controls */
"scrollbar", getControl(), /* Scrollbar background (usually the "track") */
"info", getPrimaryControl(), /* ToolTip Background */
"infoText", getPrimaryControlInfo() /* ToolTip Text */
for (int i = 0; i < systemColors.length; i += 2)
table.put( (String) systemColors, systemColors[i + 1]);
UIManager.put("Button.select", getButtonSelectColor());
// Set the color for selected button */
UIManager.put("Button.background", getButtonBackground());
/* Set the color for selected button */
UIManager.put("Menu.background", getRedBackground());
/* Set the color for the menu to red background*/
Then further on I set this:
public static ColorUIResource getRedBackground(){ return getCurrentTheme().getRedBackground(); }
But i have left in the getMenuBackground above it, I have also tried to take it out but nothing happens.
I also have a class called DEFTheme and in this I declare the following
public ColorUIResource getRedBackground()
return new ColorUIResource(255, 0, 0 );
Yet after changing all of this nothing ever happens. Am I going about this the completley wrong way ie should I change the colors in the DEFTheme and thats it?
Please please help, this is becoming a real problem and I cannot find any relevant resources!!
Thanks so much in advance,
Z.

Yes, its a crosspost, but this is the correct forum since this a Swing related question. Your crosspost comment belongs in the other forum.
Check out this article:
http://www.javareference.com/jrexamples/viewexample.jsp?id=66

Similar Messages

  • Problem with java look and feel

    Hi! This is my first time posting here. Do apologize me if I am not familiar with the regulations here. Thanks!
    Currently, I am developing a project using NetBeans IDE. It is using RMI, and some basic UI. I am facing the following error when I tried applying the java look and feel code. Please see below for the code used and the error message.
    try {   UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception e) { }
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.plaf.ColorUIResource cannot be cast to java.util.List
    at javax.swing.plaf.metal.MetalUtils.drawGradient(MetalUtils.java:196)
    at javax.swing.plaf.metal.MetalInternalFrameTitlePane.paintComponent(MetalInternalFrameTitlePane.java:384)
    at javax.swing.JComponent.paint(JComponent.java:1027)
    at javax.swing.JComponent.paintChildren(JComponent.java:864)
    at javax.swing.JComponent.paint(JComponent.java:1036)
    at javax.swing.JComponent.paintChildren(JComponent.java:864)
    at javax.swing.JComponent.paint(JComponent.java:1036)
    at javax.swing.JLayeredPane.paint(JLayeredPane.java:564)
    at javax.swing.JComponent.paintChildren(JComponent.java:864)
    at javax.swing.JComponent.paint(JComponent.java:1036)
    at javax.swing.JComponent.paintChildren(JComponent.java:864)
    at javax.swing.JComponent.paint(JComponent.java:1036)
    at javax.swing.JLayeredPane.paint(JLayeredPane.java:564)
    at javax.swing.JComponent.paintChildren(JComponent.java:864)
    at javax.swing.JComponent.paintToOffscreen(JComponent.java:5129)
    at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:285)
    at javax.swing.RepaintManager.paint(RepaintManager.java:1128)
    at javax.swing.JComponent.paint(JComponent.java:1013)
    at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
    at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
    at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
    at java.awt.Container.paint(Container.java:1797)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:734)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:679)
    at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:659)
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    Java Result: 1

    Thanks for everyone's help!
    Below is the executable code generated using NetBeans which is enough to generate the error message. Sometimes you can get the error message just by running the program. Sometimes the error will occur when you go into the Menu and click on Item.
    * NewJFrame.java
    * Created on January 8, 2008, 1:11 PM
    package client;
    import javax.swing.UIManager;
    * @author  Yang
    public class NewJFrame extends javax.swing.JFrame {
        /** Creates new form NewJFrame */
        public NewJFrame() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents() {
            jDesktopPane1 = new javax.swing.JDesktopPane();
            jInternalFrame1 = new javax.swing.JInternalFrame();
            jMenuBar1 = new javax.swing.JMenuBar();
            jMenu1 = new javax.swing.JMenu();
            jMenuItem1 = new javax.swing.JMenuItem();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
            jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
            jInternalFrame1Layout.setHorizontalGroup(
                jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 190, Short.MAX_VALUE)
            jInternalFrame1Layout.setVerticalGroup(
                jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 95, Short.MAX_VALUE)
            jInternalFrame1.setBounds(80, 40, 200, 130);
            jDesktopPane1.add(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER);
            jMenu1.setText("Menu");
            jMenuItem1.setText("Item");
            jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuItem1ActionPerformed(evt);
            jMenu1.add(jMenuItem1);
            jMenuBar1.add(jMenu1);
            setJMenuBar(jMenuBar1);
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 484, Short.MAX_VALUE)
                    .addGap(20, 20, 20))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE)
            pack();
        }// </editor-fold>                       
        private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {                                          
    // TODO add your handling code here:
            jInternalFrame1.setVisible(true);
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new NewJFrame().setVisible(true);
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception e) {
                e.printStackTrace();
        // Variables declaration - do not modify                    
        private javax.swing.JDesktopPane jDesktopPane1;
        private javax.swing.JInternalFrame jInternalFrame1;
        private javax.swing.JMenu jMenu1;
        private javax.swing.JMenuBar jMenuBar1;
        private javax.swing.JMenuItem jMenuItem1;
        // End of variables declaration                  
    }Edited by: Boxie on Jan 7, 2008 11:23 PM

  • JTree Button, Line and Java look and feel ?

    Hi all,
    I have 3 small problem with my JTree ..
    1) The 'expand' button size ...
    I set a different Icon for each node in a getTreeCellRendererComponent method (from a class that extends DefaultTreeCellRenderer )...
    The icon are 32x32 pixels.. .and the RowHeight and the Font have been changed too. .
    How to change the size of the expand button (+/-) near the text node ? Because on my JTree, the expand/collapse buttons are really small compare to the icon & row height.
    2) No line appear between the node ...
    I try to set the line style property with -> putClientProperty("JTree.lineStyle", "Angled"); in the JTree constructor OR in the DefaultTreeCellRenderer constructor .. but it doesn't work :/
    3) How to set a Java look and feel for my JTree (actually, I have a Windows look and feel ..)
    I know .. I have grouped 3 question in the same topic ...
    If anyone can help me on one of these subjects. .. Thanks !
    Regards,
    Didier

    So, the Problem 1) is solved ..
    About the Problem 2)
    I put the code UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel()) in the main method, like
      //Main method
      public static void main(String[] args) {
        try {
          UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
        catch(Exception e) {
          e.printStackTrace();
        new MainApplication();
      }But it only set a Java L&F on the spliter, and on the toolbar contained in my application... Any idea why the title bar is not changed too ?
    (The title bar stay with a Window$ XP L&F ...)
    About the problem 3)
    When I set the L&F->UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); then the lines appear .. ??!! .. if I set again the previous value UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); .. then the lines desappear ..

  • What version of jre is the older style java look and feel?

    I have two windos xp systems, one running the 1.5.0_05 JRE and one running the 1.4.2_08 JRE.
    The system that has the more up to date version has a more aesthetically pleasing java (metal) LookAndFeel. The older version has dark gray buttons/backgrounds and has purple scrollbars. The newer version has a lighter gray background with light blue (and partially shaded) buttons, scrollbars, checkboxes, etc.
    Does anyone know what version of the JRE made the move from the older style LookAndFeel to the newer one?
    Thanks!

    There were only maintence releases between 1.4.2 and 1.5.0. So the answer is 1.4.2 (old) 1.5.0 (new).

  • Where can I find Java look and feel icons besides those provided in sun?

    thanx

    You can draw your own or download from site like the one shown below:
    http://www.graphxkingdom.com/shtml/doc1.shtml
    ;o)
    V.V.

  • JFrame look and feel

    Hi everybody,
    I'm a beginner in working with Java Look and Feel. I want to customize a frame's title bar, border and buttons. For example I want to put some other icons for the close, minimize and maximize button, change the height and color of the titlebar, and put some other border to the window.
    My question is if I can do this by modifying the LAF. Maybe somebody can give me a link to some good and detailed documentation regarding LAF.
    Thanks.

    Hi,
    You have a better chance to get your question answered if you post this in the Swing forum. (Do also mention that it is a cross-post, and provide a link to this thread)
    Kaj

  • Create or Customize a look and feel

    I'd like to create my own java look and feel and I wonder if a tool that allows to create or customize my laf exists ? What's the better or faster way to do so ?

    LookAndFeel lf = UIManager.getLookAndFeel();
             // Install a different look and feel; specifically, the Windows look and feel
             try {                         //com.sun.java.swing.plaf.windows.WindowsLookAndFeel
                                            //javax.swing.plaf.metal.MetalLookAndFeel
             UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
             } catch (InstantiationException e) {
             } catch (ClassNotFoundException e) {
             } catch (UnsupportedLookAndFeelException e) {
             } catch (IllegalAccessException e) {
             }

  • Ask for Look and Feel examples

    Hi,
    I'm reading "Java Look and Feel Design Guidelines" (http://java.sun.com/products/jlf/ed2/book/index.html). It's very interesting! But I don't have the lib to test its example (samples.accessory.*). If you have one, could you share it to me?
    Thank you very much!
    Best regards,
    Lehoanq

    check this URL
    http://www.javootoo.com/
    very good look & feel stuff
    GoodLuck

  • Windows look and feel instead, in InternalFrameDemo.java

    Hi all, I am learning swing and I am trying to modify the
    InternalFrameDemo.java source from
    http://docs.oracle.com/javase/tutorial/uiswing/examples/components/index.html#InternalFrameDemo
    My idea is to add the line
    JFrame.setDefaultLookAndFeelDecorated(true); in the constructor, but it doesn't work
    and I don't understand why.
    Could somebody please help me?
    Kindest regards,
    Lasse
    public InternalFrameDemo() {
    super("InternalFrameDemo");
    //Make the big window be indented 50 pixels from each edge
    //of the screen.
    int inset = 50;
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setBounds(inset, inset,
    screenSize.width - inset*2,
    screenSize.height - inset*2);
    //FDoesn't work
    JFrame.setDefaultLookAndFeelDecorated(true);
    //Set up the GUI.
    desktop = new JDesktopPane(); //a specialized layered pane
    createFrame(); //create first "window"
    setContentPane(desktop);
    setJMenuBar(createMenuBar());
    //Make dragging a little faster but perhaps uglier.
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    }

    Uh I think you're mistaken. Whenever in doubt or something doesn't work as expected, check the javadocs. The link to the javadocs can usually be found really easily by typing "java 6 classname". In this case:
    http://docs.oracle.com/javase/6/docs/api/javax/swing/JFrame.html
    If you want to set the Windows look & feel as your thread title suggests, this was not the method you were looking for as the javadocs will tell you. That method controls if a frame is decorated or not (as the name suggests), which it is by default. Setting it to true will not change anything.
    So what then? You type into Google "java swing windows look and feel". Without quotes of course.

  • How can I include a portal component look and feel in a java servlet

    Does any body know how can i include a portal component look and feel (tables, buttons, etc) in a java servlet?

    Hi José,
    I don't think that is possible. But you can import the css files that ep uses for its look and feel and try to give your web pages similar look and feel. The tables and other controls used in EP are totally different and are done through complex JavaScript coding instead of simple HTML tags. If you want exact lok and feel then i thin you must go for a Webdynpro based application rather then a J2EE application with JSPs.
    Regards,
    Guru.
    PS: Give points for helpful replies.

  • Setting the Brushed Metal look and feel for macs using Java.

    Hello,
    I am relatively new to Java and I am new to Mac-specific java stuff. Anyways, when I try to set the look and feel of my classes to the "apple.awt.brushMetalLook" look and feel, I am unable to. It works if I have System.setProperty("apple.awt.brushMetalLook", "true"); written before I create any swing component. This would be fine, except that means that it is impossible to extend any swing component, such as JFrame or JApplet. Is there a way around this?
    Thanks!

    This might answer your question:
    http://lists.apple.com/archives/Java-dev/2003/Apr/msg00829.html

  • Does java has "Transparent" look and feel?????

    I want to know whether there is a transparent look and feel developed for java,
    if it is there please post an link to download the API
    Thank you very much..

    As far as I know, NO.
    There is a way to do this, using robot to get desktop image and draw it using paint object when you render your component, but, performance is not good.

  • [SOLVED] Java GTK look and feel

    I opened a thread recently about replacing the ugly swing buttons in Java applications. After successfully modifying my ~/.bashrc, all was well. However, these new changes were only present when run from a terminal. I assumed it was because my desktop was still running a bash session that hadn't loaded the new options yet, so I restarted.
    Symptom: Java apps launched from the GUI still have old swing buttons, but have the GTK look and feel when launched from a terminal.
    My .bashrc additions:
    # Java stuff
    export _JAVA_OPTIONS="-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel"
    I use SLiM for a graphical login experience. Could this be affecting it? I'm not sure what happens differently behind the scenes when using a login manager other than that CTRL+ALT+F7 brings me to my GUI when I use one (because all 6 TTYs are still TTYs).
    Last edited by 2mac (2014-01-02 20:51:35)

    I had a similar issue where .xinitrc wasn't working to set an environment variable. I put mine in ~/.config/openbox/environment and it worked. If you run openbox try that. If using a different window manager maybe try /etc/environment I am unsure of how slim functions though maybe there are config files for it. I think slim is on it's way out though (already lacks some compatibility with systemd; they may fix it though upstream I have no idea). But yeah try the environment file way and see if that does it (assuming you have tested your command from the shell and it works how you want).

  • Java is designed to have a look and feel equivalent to????

    Java is a programming language designed to have a look and feel equivalent to:
    a. VB
    b. C++
    c. Cobol
    d. NotesScript
    Cheers!

    If you mean look and feel from a language perspective, Java was heavily influenced by C++.
    Since this is a multiple choice question quoted verbatim from either a textbook or your homework, I assume that you aren't really interested in any more information than that.

  • Java Components and Look and Feel

    Can anyone suggest a free look and feel that does not resemble the standard stuff that comes with the JDK?
    Also, Swing seems to be missing some important components like dockable windows, and toolbars. Can anyone suggest some resource that offers interesting swing components?

    Can someone suggest a good API for doing this stuff?
    I would really like to consider using Java for some
    e real world application, but the swing interface
    makes applications look at least 15 years old.Really? My applications look like native windows applications (when run under Windows, at least). Try setting the native look and feel. Search the forum if you don't know how.

Maybe you are looking for

  • Migration of Smartforms / SAPScript forms from SAP R/3 4.7 to SAP ECC 6.0

    Dear Members, We are in process of re-implementing SAP with SAP ECC 6.0 from SAP R/3 version 4.7 We have created many layouts using SAPScripts & SAP Smartforms in SAP R/3. My question is, are there any migration tools available in SAP ECC 6.0 in the

  • Special characters in Web Services

    I have developed a Web Service in Java using JBuilder 2005 and deployed it on BEA Weblogic 8.1 SP5. Weblogic is configured to use the ISO-8859-1 encoding as well as JBuilder. I am living in South Africa and we need to cater for special characters. A

  • Can JSC support Sun App Server 9?

    Does anyone know if JSC can support sun app server 9? Last I heard was that 8.2 is the max version. Along the same line, is there any word of another update to JSC that will work with app server 9 and jdk 6???

  • 2011 and 12 macs won't firewire older ones will

    I have an iMac (mavericks) 2011 and a Macbook pro(mountain lion) 2012 neither of these will connect to my Panasonic DVX-100B via firewire.  My 2008 (Leopard) macbook pro and my 2005 mac mini (tiger)  will both connect and capture video. Is this due t

  • Proxying convergence with apache

    I managed to get application server to listen on the JK listener, and Apache will proxy connections. However, Convergence doesn't work. It partially loads the UI, but it appears that not all of the AJAX calls are succeeding. This happens whether I pr