Swing: Look and Feel

I've found this page with a nice look and feel:
https://substance.dev.java.net/docs/skins.html#CremeSkin
But I can't use it.
I import this:
import org.jvnet.substance.skin.SubstanceCremeLookAndFeel;
And do this:
UIManager.setLookAndFeel(new SubstanceCremeLookAndFeel());
But the import-libary are not correct. Hope somebody can help me! I'm using netBeans.

you can add LAF without changing of code. Start app from command line like this
@call set_classpath.bat
@set classpath=../../laf/substance.jar;%classpath%
@java -Dswing.defaultlaf=org.jvnet.substance.SubstanceLookAndFeel myPkg.myApp
see quick review of LAF's - http://sss1024.googlepages.com/

Similar Messages

  • Drawing window borders swing look and feel

    Does anyone know how to change the frame window border from being drawn in the windows look and feel? I want them to be drawn as a swing application. Can anyone help?

    Frames (and JFrames) are top-level containers that are not subject to rendering by the Look-and-Feel manager (they are actually "heavy-weight" native components). However, in 1.4 it is possible to use an undecorated frame (using Frame.setUndecorated(true)) which you could paint to look like a JInternalFrame. However, I think you lose the automatic handling of resizing, moving, iconifying, maximizing, closing, etc.

  • NetBeans: Dinamically changing Look and Feel Problem

    Hi there, Java lovers.
    I need some help here!
    I love java, and I used to program my graphical user interfaces by hand. In my applications, there is a dropdown for the user to chose the desired look and feel. Then I save the selected option to a file and on the startup I do something like this:
                UIManager.setLookAndFeel(savedUserSelectedLookAndFeel);That always worked really fine. The look and feel would change and everything worked really well.
    However, programing GUI by hand is really a PITA. So I was seduced by Netbeans. I am using Netbeans 6.0 on Windows XP, and I designed the GUIs really fast now.
    The problem is, the system look and feel works really well, but when I change the look and feel of my application to a different one (Java/Motif/etc..) the look and feel changes but the components positions and sizes becomes all messed up. It really becomes impossible to work with a different look and feel because some components are outside of frames.
    I believe the cause of this is because Netbeans generates the code automatically using Grids and stuff like that, and by doing so, the change of the look and feel becomes messed up. This is a thing that would not happen with my manually created code.
    This is really troubling me. Does someone has the same problem. Is there something I can do? Or do I need to create my GUIs by hand like before?

    Oyashiro-sama (少し日本語を知っているし、そんな「様」っていう使い方はちょっと変そうですね (^_-) 「冗談」っていう顔文字です。)
    Sorry for the delay in reply, but one problem for you is that this is not a NetBeans users forum, thus you will not necessarily receive speedy replies here to your NetBeans questions. The best place to send NetBeans questions is:
    [email protected]
    [email protected] (for NetBeans API issues)
    As for your question, you seem to already know quite a bit about NetBeans UI Look and Feel programming, but have you seen these:
    WORKING WITH SWING LOOK AND FEEL:
    http://java.sun.com/developer/JDCTechTips/2004/tt0309.html#1
    Java GUI Swing Programming Using NetBeans 5 (should apply to NetBeans 6):
    http://wiki.netbeans.org/JavaGUISwingProgrammingUsingNetBeans5
    Regards,
    -Brad Mayer

  • Swing disabled components look and feel problem.

    Hi All,
    I have a Swing application. My system is recently upgraded to JRE 1.6 and I'm facing problem with look and feel of swing components when they are disabled. Color of disabled components is very faint and its being difficult to read the text in such disabled components. In JRE 1.4 this problem was not there. Please let me know what I can do to get the look and feel(Color and Font) of disabled components, same as JRE 1.4.
    Thanks

    Sandip_Jarad wrote:
    ..I have a Swing application. My system is recently upgraded to JRE 1.6 and I'm facing problem with look and feel of swing components when they are disabled. Which look and feel is the application using? As an aside, did it never occur to you to mention the PLAF?
    ..Color of disabled components is very faint and its being difficult to read the text in such disabled components. Why is it so gosh-darned important to read the text on a control that is (supposedly) not relevant or not available?
    ..In JRE 1.4 this problem was not there. Please let me know what I can do to get the look and feel(Color and Font) of disabled components, same as JRE 1.4. Here are some suggestions, some of them are actually serious. I'll leave it as an exercise for you, to figure out which ones.
    - Run the app. in 1.4.
    - Use a custom PLAF that offers a 'less faint' rendering of disabled components.
    - Use Motif PLAF (I haven't checked, but I bet that has not changed since 1.4).
    - Put the important text in a tool-tip.

  • 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.

  • 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

  • Problem With ButtonUI in an Auxiliary Look and Feel

    This is my first post to one of these forums, so I hope everything works correctly.
    I have been trying to get an axiliary look and feel installed to do some minor tweaking to the default UI. In particular, I need it to work with Windows and/or Metal as the default UI. For the most part I let the installed default look and feel handle things with my code making some colors lighter, darker, etc. I also play with focus issues by adding FocusListeners to some components. I expect my code to work reasonably well no matter what the default look and feel is. It works well with Motif, Metal, and Windows, the only default look and feels I've tested with. What I'm going to post is a stripped down version of what I have been working on. This example makes gross changes to the JButton background and foreground colors in order to illustrate what I've encountered.
    I have three source code files. The first, Problem.java, creates a JFrame and adds five buttons to it. One button installs MyAuxLookAndFeel as an auxiliary look and feel using MyAuxButtonUI for the look and feel of JButtons. The next button removes that look and feel. The next button does nothing except print a line to System.out. The next button installs MyAuxLookAndFeel as an auxiliary look and feel using MyModButtonUI for the look and feel of JButtons. The last button removes that look and feel.
    The problem is, when I install the first auxiliary look and feel, buttons are no longer tabable. Also, they cannot be invoked by pressing the space button when they're in focus. When I remove the first auxiliary look and feel everything reverts to behaving normally. When I add the "Mod" version, button tabability is fine. The only difference is I've added the following code:
    if ( c.isFocusable() ) {
       c.setFocusable(true);
    }That strikes me as an odd piece of code to profoundly change the program behavior. Anyway, after adding and removing the "Mod" look and feel, the tababilty is forever fixed. That is, if I subsequently re-install the first look and feel, tababilty works just fine.
    The problem with using the space bar to select a focused button is more problematic. My class is not supposed to mess with the default look and feel which may or may not use the space bar to press the button with focus. When the commented code in MyModButtonUI is uncommented, things behave correctly. Even the statement
    button.getInputMap().remove( spaceKeyStroke );doesn't mess things up after the auxiliary look and feel is removed. So far I've tested this with JRE 1.4.2_06 under Windows 2000, JRE 1.4.2_10 under Windows XP, and JRE 1.5.0_06 under Windows XP and the behavior is the same.
    All of this leads me to two questions.
    1. Is my approach fundamentally flawed? I've extended TextUI and ScrollBarUI with no problems. This is the only problem I've encountered with ButtonUI. My real workaround for the space bar issue is better than the one I've supplied in the example, but it certainly is not guaranteed to work for any arbitrary default look and feel.
    2. Assuming I have no fundamental problems with my approach, it's possible I've found a real bug. I searched the bug database and couldn't find anything like this. Of course, this is the first time I've tried seasrching the database for a bug so my I'm doing it badly. Has this already been reported as a bug? Is there any reason I shouldn't report it?
    What follows is the source code for my example. It's in three files because the two ButtonUI classes must be public in order to work. Thanks for insight you can provide.
    Bill
    File Problem.java:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Problem extends JFrame {
       public boolean isAuxInstalled = false;
       public boolean isModInstalled = false;
       public LookAndFeel lookAndFeel = new MyAuxLookAndFeel();
       private static int ctr = 0;
       public static void main( String[] args ) {
          new Problem();
       public Problem() {
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setSize(250, 150);
          setTitle("Button Test");
          JButton install = new JButton("Install");
          JButton remove = new JButton("Remove");
          JButton doNothing = new JButton("Do Nothing");
          JButton installMod = new JButton("Install Mod");
          JButton removeMod = new JButton("Remove Mod");
          this.getContentPane().setLayout(new FlowLayout());
          this.getContentPane().add(install);
          this.getContentPane().add(remove);
          this.getContentPane().add(doNothing);
          this.getContentPane().add(installMod);
          this.getContentPane().add(removeMod);
          install.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                if ( !isAuxInstalled ) {
                   isAuxInstalled = true;
                   UIManager.addAuxiliaryLookAndFeel( lookAndFeel );
                   SwingUtilities.updateComponentTreeUI( Problem.this );
          remove.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                if ( isAuxInstalled ) {
                   isAuxInstalled = false;
                   UIManager.removeAuxiliaryLookAndFeel( lookAndFeel );
                   SwingUtilities.updateComponentTreeUI( Problem.this );
          doNothing.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                System.out.println( "Do nothing " + (++ctr) );
          installMod.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                if ( !isModInstalled ) {
                   isModInstalled = true;
                   UIManager.addAuxiliaryLookAndFeel( lookAndFeel );
                   SwingUtilities.updateComponentTreeUI( Problem.this );
          removeMod.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                if ( isModInstalled ) {
                   isModInstalled = false;
                   UIManager.removeAuxiliaryLookAndFeel( lookAndFeel );
                   SwingUtilities.updateComponentTreeUI( Problem.this );
          setVisible(true);
       class MyAuxLookAndFeel extends LookAndFeel {
          public String getName() {
             return "Button Test";
          public String getID() {
             return "Not well known";
          public String getDescription() {
             return "Button Test Look and Feel";
          public boolean isSupportedLookAndFeel() {
             return true;
          public boolean isNativeLookAndFeel() {
             return false;
          public UIDefaults getDefaults() {
             UIDefaults table = new MyDefaults();
             Object[] uiDefaults = {
                "ButtonUI", (isModInstalled ? "MyModButtonUI" : "MyAuxButtonUI"),
             table.putDefaults(uiDefaults);
             return table;
       class MyDefaults extends UIDefaults {
          protected void getUIError(String msg) {
    //         System.err.println("(Not) An annoying error message!");
    }File MyAuxButtonUI.java:
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.plaf.*;
    import javax.swing.plaf.multi.*;
    import javax.accessibility.*;
    public class MyAuxButtonUI extends ButtonUI {
       private Color background;
       private Color foreground;
       private ButtonUI ui = null;
       public static ComponentUI createUI( JComponent c ) {
          return new MyAuxButtonUI();
       public void installUI(JComponent c) {
          MultiButtonUI multiButtonUI = (MultiButtonUI) UIManager.getUI(c);
          this.ui = (ButtonUI) (multiButtonUI.getUIs()[0]);
          super.installUI( c );
          background = c.getBackground();
          foreground = c.getForeground();
          c.setBackground(Color.GREEN);
          c.setForeground(Color.RED);
       public void uninstallUI(JComponent c) {
          super.uninstallUI( c );
          c.setBackground(background);
          c.setForeground(foreground);
          this.ui = null;
       public void paint(Graphics g, JComponent c) {
          this.ui.paint( g, c );
       public void update(Graphics g, JComponent c) {
          this.ui.update( g, c );
       public Dimension getPreferredSize(JComponent c) {
          if ( this.ui == null ) {
             return super.getPreferredSize( c );
          return this.ui.getPreferredSize( c );
       public Dimension getMinimumSize(JComponent c) {
          if ( this.ui == null ) {
             return super.getMinimumSize( c );
          return this.ui.getMinimumSize( c );
       public Dimension getMaximumSize(JComponent c) {
          if ( this.ui == null ) {
             return super.getMaximumSize( c );
          return this.ui.getMaximumSize( c );
       public boolean contains(JComponent c, int x, int y) {
          if ( this.ui == null ) {
             return super.contains( c, x, y );
          return this.ui.contains( c, x, y );
       public int getAccessibleChildrenCount(JComponent c) {
          if ( this.ui == null ) {
             return super.getAccessibleChildrenCount( c );
          return this.ui.getAccessibleChildrenCount( c );
       public Accessible getAccessibleChild(JComponent c, int ii) {
          if ( this.ui == null ) {
             return super.getAccessibleChild( c, ii );
          return this.ui.getAccessibleChild( c, ii );
    }File MyModButtonUI.java:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.plaf.*;
    public class MyModButtonUI extends MyAuxButtonUI
       static KeyStroke spaceKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0 );
       public static ComponentUI createUI( JComponent c ) {
          return new MyModButtonUI();
       public void installUI(JComponent c) {
          super.installUI(c);
          c.setBackground(Color.CYAN);
          if ( c.isFocusable() ) {
             c.setFocusable(true);
    //      final JButton button = (JButton) c;
    //      button.getInputMap().put( spaceKeyStroke, "buttonexample.pressed" );
    //      button.getActionMap().put( "buttonexample.pressed", new AbstractAction() {
    //         public void actionPerformed(ActionEvent e) {
    //            button.doClick();
    //   public void uninstallUI(JComponent c) {
    //      super.uninstallUI(c);
    //      JButton button = (JButton) c;
    //      button.getInputMap().remove( spaceKeyStroke );
    //      button.getActionMap().remove( "buttonexample.pressed" );
    }

    here is the code used to change the current look and feel :
    try {
                   UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
             catch (InstantiationException e)
                  System.out.println("Error occured  "+ e.toString());
             catch (ClassNotFoundException e)
                  System.out.println("Error occured  "+ e.toString());
             catch (UnsupportedLookAndFeelException e)
                  System.out.println("Error occured  "+ e.toString());
             catch (IllegalAccessException e)
                  System.out.println("Error occured in .. " + e.toString());
             Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
             Fenetre fen = new Fenetre();
             fen.setSize(dim.width, dim.height);
             fen.setResizable(false);
                 fen.setLocation(0, 0);
                  fen.setVisible(true);

  • Accessing File/Folder icons for current Look and Feel

    Hi,
    I'm looking to get the Icon for files and folders that the current UIManager uses for some work I'm doing. Please could you help.
    I'm getting strange results from the method I'm using, which is to create a temporary file and do: Icon i = FileSystemView.getFileSystemView().getSystemIcon(tempFile);
    I don't like the idea of having to create a temporary file to do this - isn't there another way to do it? - for instance asking "get default file icon"/"get default folder icon".
    I could download a jpg image of the file/folder icons, but this is static - and I want my method to get the icons used for the current look and feel I'm using.
    There must be a simple way to do this right? I mean, java uses a method to get the icons for the current look and feel.. Oh.. Please help!
    - Edd.

    Try these:
    UIManager.getIcon("FileView.directoryIcon");
    UIManager.getIcon("FileView.fileIcon");Leif Samuelsson
    Java Swing Team
    Sun Microsystems, Inc.

  • 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

  • Problem setting look and feel

    It seems like I'm not able to change the windows xp look and feel, I'm using this code to change it but nothing happens, the window comes out with windows LAF:
    " public static void main(String[] args)
    try {
    UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (Exception e) { System.out.println(e.getMessage()); }
    new Ventana();
    Maybe... Am I missing some code? or a specific class needs to be downloaded?
    I'd apreciate any help

    That was not the problem, but thank you...
    I finally noticed the problem, what I was trying to do was actually done by writting this:
    JComponent.setDefaultLookAndFeelDecorated(true);
    Sets the OceanTheme feel on, but I noticed that when you try to use it with a Jdialog and a JFileChooser you get some ugly colors. Orange/Brown with JDialogs and Green with JFileChoosers. Is this a bug or it's ment to do that?
    Does somebody know how to fix it?
    Thanks for your support

  • Can i get XP look and feel?

    Hi,
    I want to XP look and feel in my swing application. In c# i can get XP style but is it possible in java or not. If yes how please give me a little hint
    thanks,

    Dude. this is just for making the L&F look as native platfrom.
    Its better than using motif or some that kinda L&F.
    (Looks like XP on Win XP... looks like windows on other win versions)
    String nativeLF = UIManager.getSystemLookAndFeelClassName();
         // Install the look and feel
         try {
              UIManager.setLookAndFeel(nativeLF);
         } catch (InstantiationException e) {
         } catch (ClassNotFoundException e) {
         } catch (UnsupportedLookAndFeelException e) {
         } catch (IllegalAccessException e) {
    Dont forget to import this :
    import javax.swing.UnsupportedLookAndFeelException;
    have fun Enjoy!
    [email protected]

  • Stefankrause XP look and feel

    Hi
    I m posting this thread again. Can anyone show the way to get rid of SecretLoader class in Stefankrause look and feel. SerectLoader Code is not available on net , but this is used in Stefankrause XP look and feel.I have tried default icons but does not exactly serve the purpose.
    I've downloded code from
    http://www.stefan-krause.com/java/
    Or if u've info regarding where is icon file for Microsoft Windows XP on Computer that are used in Java, like icons for plus ,minus, or question mark etc.
    Thanx.

    Hi there, I've used this package and u can use DJ - the java decompiler or jad to decomile it. Or event u can use Gel(a Java IDE written in Java) to just double click the class file to view it's source. Gel can be found at http://www.gexperts.com/.
    note the code
    abyte0[l] ^= 0x2a;
    is what the author exactual encode the resource. u can alse use this method to get the original images, in fact, i've done this, hehe. Since abyte ^ 0x2a ^ 0x2a = abyte, this is just a bitwise operation equals.
    // SecretLoader.java
    // Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://kpdus.tripod.com/jad.html
    // Decompiler options: packimports(3)
    package com.stefankrause.xplookandfeel.skin;
    import java.awt.*;
    import java.io.ByteArrayOutputStream;
    import java.io.InputStream;
    import java.net.URL;
    import javax.swing.JPanel;
    public class SecretLoader
    public SecretLoader()
    static Image loadImage(String s)
    URL url;
    url = (com.stefankrause.xplookandfeel.skin.SecretLoader.class).getResource("/com/stefankrause/xplookandfeel/icons/" + s);
    Object obj = null;
    Image image;
    InputStream inputstream = url.openStream();
    ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
    byte abyte0[];
    if(s.endsWith(".res"))
    inputstream.read();
    inputstream.read();
    for(int i = inputstream.read(buffer); i != -1; i = inputstream.read(buffer))
    bytearrayoutputstream.write(buffer, 0, i);
    abyte0 = bytearrayoutputstream.toByteArray();
    for(int l = 0; l < abyte0.length; l++)
    abyte0[l] ^= 0x2a;
    } else
    for(int j = inputstream.read(buffer); j != -1; j = inputstream.read(buffer))
    bytearrayoutputstream.write(buffer, 0, j);
    abyte0 = bytearrayoutputstream.toByteArray();
    int k = inputstream.read(abyte0);
    image = Toolkit.getDefaultToolkit().createImage(abyte0, 0, abyte0.length);
    MediaTracker mediatracker = new MediaTracker(panel);
    mediatracker.addImage(image, 0);
    try
    mediatracker.waitForID(0);
    catch(InterruptedException interruptedexception) { }
    return image;
    Throwable throwable;
    throwable;
    throw new IllegalArgumentException("File " + s + " could not be loaded.");
    static JPanel panel = new JPanel();
    static byte buffer[] = new byte[4096];
    }

  • HELP !! XP look and feel ...

    how can i make my frame have an XP look and feel ??????
    please help me in details , cause i haven't done this look and feel thing before ??? thanks in advance ..

    You need to change to the windows LnF which is not the default. The
    following code will do it for you. Note that it will only work if your
    using Windows XP.
    * LookAndFeel.java
    public class LookAndFeel {
        public static final String MAC_CLASS = "com.sun.java.swing.plaf.mac.MacLookAndFeel";
        public static final String METAL_CLASS = "javax.swing.plaf.metal.MetalLookAndFeel";
        public static final String MOTIF_CLASS = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
        public static final String WINDOWS_CLASS = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
        public static final String GTK_CLASS = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
        public static final String KUNSTSTOFF_CLASS = "com.incors.plaf.kunststoff.KunststoffLookAndFeel";
        public static boolean updateLookAndFeel(String currentLookAndFeel, java.awt.Component parent) {
         try {
             javax.swing.UIManager.setLookAndFeel(currentLookAndFeel);
                if(parent != null) {
                    javax.swing.SwingUtilities.updateComponentTreeUI(parent);
         } catch(Exception ex) {
             System.out.println(ex);
                return false;
            return true;
    }To get it to work do the following:
        LookAndFeel.updateLookAndFeel(LookAndFeel.WINDOWS_CLASS, this);where this represents your JWindow or JFrame.
    Hope it helps.
    James.

  • Motif look and feel

    if i run the following code,it displayes a dialog with missing title text
    import javax.swing.JOptionPane;
    import javax.swing.UIManager;
    public class TestMotif {
         * @param args
         public static void main(String[] args) {
              try
                   //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                   UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              JOptionPane.showMessageDialog(null, "done", "Confirmation Dialog for testing",
                        JOptionPane.INFORMATION_MESSAGE);
    in motif look and feel(system look and feel for solaris os)the dialog size is dependent on the message text length not on tilte text length.
    whereas in other look and feel the dialog size is dependent on both message and title text length.I raisedn it in sun's bug but didnt get any reply.Can anyone tell how can it be fixed in jre level.
    Edited by: AGS_CONTACT on Jun 30, 2008 11:07 AM

    It's not the answer you want to hear, but it's pretty simple:
    Write your own JDialog subclass that implements the behavior you want. It should be pretty straightforward to write a JOptionPane message dialog clone.

  • 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

Maybe you are looking for

  • Unable to login to application

    Hi All, After doing the cloning in unable to login to applications im getting error "page cannot be displayed". Apache error 168.94.79.130 - - [13/May/2011:08:31:13 -0500] "POST /OA_HTML/fndvald.jsp HTTP/1.1" 302 262 1 168.94.79.130 - - [13/May/2011:

  • Profit Center Derivation in AuC Line Item

    Hi Team, We have Investment Profile configured, where in AuC gets automatically created in background with WBS Release. Step 1: While settlement from WBS to AuC, Profit Center remains blank under Entry View for AuC Line (GL View = Inheritance from th

  • Problem with Footer

    Hi ABAP Gurus,                           I am having a problem with the footer. One of the entry is triggering in the first page but it is displaying in the second page. . But in the footer total that entry is getting calculated . Can you please sugg

  • Safari Caching

    Okay.... I'm incredibly frustrated, but perhaps someone here is genius enough to save my day. I'm hosting www.howcanidomore.com it loads GREAT in firefox. (i hear it loads fine in IE as well, and I'm not worried about chrome yet) Loads fine at first

  • How to find Tables behind a Custom Query in SAP

    Hi Gurus, Can anyone please help me find tables behind a custom query in SAP. Regards As