JButton & Win XP Look and Feel focus rectangle bug??

I searched the bug database but was unable to find any matches...
I have received a bug report from our users relating to mistakenly thinking a button has focus. In the XP LAF, when a button is a 'default' button, it has a blue rectancle drawn around it (which is correct). When you tab to that button however, there is no additional 'focus' rectangle to indicate that the button has focus. I tested this in native XP components and an additional rectancle IS drawn when the button gets focus (in addition to the blue rectangle). Shouldn't there be some sort of focus indicator in addition to the blue rectangle? I'm using JRE version 1.4.2_02.
Thanks,
Andy

Hello Andy!
If the behavior of Win XP LAF is different from the native this is definitely a bug. It would be greate if you file a bug here
http://java.sun.com/webapps/bugreport.
Thank you.
Anton

Similar Messages

  • Problem in JButton while changing look and feel to CDE/Motif

    In my application i'm using JButtons placed in JToolbar. I've setIcons for the JButtons. The top of the icons i.e the JButtons get hided while i changing the look & feel to CDE/Motif. But again if i change the look & feel to Metal, no problem is there. Expecting a favourable response from someone well versed / faced such problems earlier problems.
    Cheers
    sunil s

    Sounds suspiciously like you are setting absolute sizes for your buttons or elsewhere in application. Can you post code snippets showing how you layout your application.
    Cheers
    DB

  • 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);

  • Transparent TextField with Synth Look and Feel

    I am trying to use synth to implement a textfield with a transparent background, and having some problems with it. I can see my panel and the transparent field fine enough in the beginning, but when the text in the field changes, it writes right over the previous text and becomes a pile of unreadable white marks. I've experimented with varying degrees of transparency, but you can still see the old field underneath slightly. Does anyone have any suggestions? My code is below.
    Thanks.
    synth.xml
    <synth>
    <!-- PANEL -->
    <style id="panelStyle">
        <state>
            <imagePainter method="panelBackground" path="../../../lafImages/papyrus_bkgd.gif" sourceInsets="10 15 10 15"/>
        </state>
    </style>
    <bind style="panelStyle" type="name" key="PAPYRUS_PANEL"/>
    <!-- TEXTFIELD -->
    <style id="textFieldStyle">
        <font name="Kudasai" size="12"/>
        <state>
            <color type="TEXT_FOREGROUND" value="#FFFFFF"/>
            <!-- set the alpha value for transparency in 1st two digits -->
            <color type="BACKGROUND" value="#00000000"/>
        </state>
        <opaque value="false"/>
    </style>
    <bind style="textFieldStyle" type="region" key="TEXTFIELD"/>
    </synth>
    my tester
    class SynthTester {
        private JTextField field;
        public SynthTester(){
            initLookAndFeel();
            JFrame main = new JFrame();
            JPanel panel = new JPanel();
            panel.setName("PAPYRUS_PANEL");
            field = new JTextField(3);
            field.setText("0");
            panel.add(field);
            JButton button = new JButton("+");
            button.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    int val;
                    try {
                        val = Integer.parseInt(field.getText());
                    } catch( Exception ex ) {
                        val = 0;
                    val++;
                    field.setText(Integer.toString(val));
            panel.add(button);
            main.add(panel);
            main.pack();
            main.setVisible(true);
        private void initLookAndFeel() {
            SynthLookAndFeel lookAndFeel = new SynthLookAndFeel(); 
            try {
                InputStream is = getClass().getResourceAsStream("synth.xml");
                if( is == null) {
                    System.err.println("unable to load resource stream");
                } else {
                    lookAndFeel.load(is, getClass());
                    UIManager.setLookAndFeel(lookAndFeel);
            } catch (Exception e) {
                System.err.println("Couldn't get specified look and feel ("+ lookAndFeel+ "), for some reason.");
                System.err.println("Using the default look and feel.");
                e.printStackTrace();
                System.exit(1);
    }

    As its name implies, an imagePainter element creates a SynthPainter that paints from an image. For example:
    <synth>
    <style id="example">
    <state>
    <color value="white" type="BACKGROUND"/>
    </state>
    <imagePainter method="panelBackground" path="background.png"
    sourceInsets="5 6 6 7" paintCenter="false"/>
    <insets top="5" bottom="6" right="7" left="6"/>
    </style>
    <bind style="example" type="region" key="Panel"/>
    </synth>

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

  • Why my System Look and feel got corrupted ??

    HI ,
    I have written a simple swing app which consists of jtextarea in a jscrollpane , and a jbutton, in which the textarea is updated with random text.
    I decided to change the theme to native look&feel and so i included the
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName() );
    in the constructor ..
    but the components went messy in the output !!!
    It'sn't a system look and feel ..
    I tried inserting in a static block before the constructor and tried changing the theme ... but in vain
    take a look
    http://img228.imageshack.us/my.php?image=javaswingprobaw3.jpg
    Pls help

    My thoughts exactly .. looks Windowsy to me.

  • Function to change Boarder Look and feel of Jframe - Not working

    Hi all,
    In the given SSCE, the functionpublic void changeButtonColor(Component[] comps) to change the border look and feel of JFrame is not working.Please help.
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Insets;
    import java.util.Vector;
    import javax.swing.AbstractButton;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JViewport;
    import javax.swing.SwingConstants;
    import javax.swing.UIManager;
    public class ScrollableWrapTest {
        public static void main(String[] args) {
            try {
                final JPanel mainPanel = new JPanel(new WrapScollableLayout(FlowLayout.LEFT, 10, 10));
                mainPanel.setBackground(Color.WHITE);
                JScrollPane pane = new JScrollPane(mainPanel);
                pane.setPreferredSize(new Dimension(320, 200));
                Vector v = new Vector();
                v.add("first");
                JButton button = null;
                for(int i =0;i<v.size();i++){
                        JPanel panel = new JPanel(new BorderLayout());
                        panel.setBackground(Color.WHITE);
                        int num = mainPanel.getComponentCount()+1;
                        button = new JButton("button" + num);
                        button.setPreferredSize(new Dimension(90, 25));
                        JLabel label = new JLabel((String)v.elementAt(i));
                        label.setHorizontalAlignment(SwingConstants.CENTER);
                        panel.add(button, BorderLayout.NORTH);
                        panel.add(label, BorderLayout.SOUTH);
                        mainPanel.add(panel);
                        mainPanel.revalidate();
                ScrollableWrapTest st = new ScrollableWrapTest();
                st.buildGUI(pane);
            } catch (Exception e) {e.printStackTrace();}
        public void buildGUI(JScrollPane scrollPane)
             JFrame frame = new JFrame("Scrollable Wrap Test");
             JFrame.setDefaultLookAndFeelDecorated(true);
            UIManager.put("activeCaption", new javax.swing.plaf.ColorUIResource(Color.LIGHT_GRAY));
            changeButtonColor(frame.getComponents());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(scrollPane, BorderLayout.CENTER);
            frame.setLocationRelativeTo(null);
            frame.pack();
            frame.setVisible(true);
        public void changeButtonColor(Component[] comps)
          for(int x = 0, y = comps.length; x < y; x++)
            if(comps[x] instanceof AbstractButton)
              ((AbstractButton)comps[x]).setBackground(Color.LIGHT_GRAY);
              ((AbstractButton)comps[x]).setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
            else if (comps[x] instanceof Container)
              changeButtonColor(((Container)comps[x]).getComponents());
        private static class WrapScollableLayout extends FlowLayout {
            public WrapScollableLayout(int align, int hgap, int vgap) {
                super(align, hgap, vgap);
            public Dimension preferredLayoutSize(Container target) {
                synchronized (target.getTreeLock()) {
                    Dimension dim = super.preferredLayoutSize(target);
                    layoutContainer(target);
                    int nmembers = target.getComponentCount();
                    for (int i = 0 ; i < nmembers ; i++) {
                        Component m = target.getComponent(i);
                        if (m.isVisible()) {
                            Dimension d = m.getPreferredSize();
                            dim.height = Math.max(dim.height, d.height + m.getY());
                    if (target.getParent() instanceof JViewport)
                        dim.width = ((JViewport) target.getParent()).getExtentSize().width;
                    Insets insets = target.getInsets();
                    dim.height += insets.top + insets.bottom + getVgap();
                    return dim;
    }Please help.
    Rony

    You are calling changeButtonColor(frame.getComponents()) before you add the JScrollPane to the content pane.
    But why not just move this to the button creation loop?
    button = new JButton("button" + num);
    button.setBackground(Color.LIGHT_GRAY);
    button.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));

  • Introduction of R12 look and feel

    I built jsp pages using adf components on jdev 10.1.3
    I tried to introduce the swan look and feel by makin an xss sheet in WEB-INF/lib/META-INF/adf/styles directory
    I was able to change the background colors but couldnt change the look of commandbutton.
    What I did was i made a new style selector called .OrabuttonEnabled and in the styleclass property of the commandbutton i added this value. But its not working.
    Also I was not able to change the icons like focus,expand and collapse icons of treetable.
    Please help me.

    So I tried with a css file.It works fine now.
    I made a new style selector called .AFbuttonEnabled and set it as styleclass for the enabled buttons and .AFbuttonDisabled as style selector for disabled buttons.
    But i have some disabled buttons that are enabled when a boolean value is set.
    So how do I change the style class accordingly.
    What I mean to ask is if there is some way to change the style class conditionally.
    Please reply.

  • How to customize the title bar on my own Look And Feel?

    Hi all!
    I am creating my own Look and Feel which extends from NimbusLookAndFeel. What I'm doing is overwriting UIDefaults values??, referring to the Painters. For example:
    +uiDefault.put ("Button [Enabled]", new ButtonEnabledPainter());+
    But now I need is to customize the title bar of the JFrame's, but I do not see this option in Painter's values ??can be overwritten by Nimbus (http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults . html).
    You know as possible? I have to overwrite an existing UI component? The idea is I want to make the look and feel like SeaGlass, but the code seems a bit complex to know where to begin.
    I hope you can guide me on this issue.
    Thank you very much for everything! And excuse my English!.
    Greetings!

    very simple example, with direct methods
    import java.awt.*;
    import java.awt.event.*;
    import java.util.LinkedList;
    import java.util.Queue;
    import javax.swing.*;
    public class NimbusBorderPainterDemo extends JFrame {
        private static final long serialVersionUID = 1L;
        private JFrame frame = new JFrame();
        private JPanel fatherPanel = new JPanel();
        private JPanel contentPanel = new JPanel();
        private GradientPanel titlePanel = new GradientPanel(Color.BLACK);
        private JLabel buttonPanel = new JLabel();
        private Queue<Icon> iconQueue = new LinkedList<Icon>();
        public NimbusBorderPainterDemo() {
            iconQueue.add(UIManager.getIcon("OptionPane.errorIcon"));
            iconQueue.add(UIManager.getIcon("OptionPane.informationIcon"));
            iconQueue.add(UIManager.getIcon("OptionPane.warningIcon"));
            iconQueue.add(UIManager.getIcon("OptionPane.questionIcon"));
            JButton button0 = createButton();
            button0.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    frame.setExtendedState(ICONIFIED);
            JButton button1 = createButton();
            button1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    frame.setExtendedState(MAXIMIZED_BOTH | NORMAL);
                }//quick implemented, not correct you have to override both methods
            JButton button2 = createButton();
            button2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    int confirm = JOptionPane.showOptionDialog(frame,
                            "Are You Sure to Close Application?", "Exit Confirmation",
                            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
                            null, null, null);
                    if (confirm == JOptionPane.YES_OPTION) {
                        System.exit(1);
            buttonPanel.setLayout(new GridLayout(0, 3, 5, 0));
            buttonPanel.setPreferredSize(new Dimension(160, 30));
            buttonPanel.add(button0);// JLabel is best and cross_platform JComponents
            buttonPanel.add(button1);// not possible put there witouth set Dimmnesion
            buttonPanel.add(button2);// and LayoutManager, work in all cases better
            titlePanel.setLayout(new BorderLayout());//than JPanel or JCompoenent
            titlePanel.add(new JLabel(nextIcon()), BorderLayout.WEST);
            titlePanel.add(new JLabel("My Frame"), BorderLayout.CENTER);
            titlePanel.setBorder(BorderFactory.createLineBorder(Color.GRAY));
            titlePanel.add(buttonPanel, BorderLayout.EAST);
            JTextField field = new JTextField(50);
            JButton btn = new JButton("Close Me");
            btn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.exit(1);
            contentPanel.add(field);
            contentPanel.add(btn);
            fatherPanel.setLayout(new BorderLayout());
            fatherPanel.add(titlePanel, BorderLayout.NORTH);
            fatherPanel.add(contentPanel, BorderLayout.CENTER);
            frame.setUndecorated(true);
            frame.add(fatherPanel);
            frame.setLocation(50, 50);
            frame.pack();
            frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
            frame.setVisible(true);
            ComponentMover cm = new ComponentMover(frame, titlePanel);
            //by camickr http://tips4java.wordpress.com/2009/06/14/moving-windows/
        private JButton createButton() {
            JButton button = new JButton();
            button.setBorderPainted(false);
            button.setBorder(null);
            button.setFocusable(false);
            button.setMargin(new Insets(0, 0, 0, 0));
            button.setContentAreaFilled(false);
            button.setIcon(nextIcon());
            button.setRolloverIcon(nextIcon());
            button.setPressedIcon(nextIcon());
            button.setDisabledIcon(nextIcon());
            nextIcon();
            return button;
        private Icon nextIcon() {
            Icon icon = iconQueue.peek();
            iconQueue.add(iconQueue.remove());
            return icon;
        private class GradientPanel extends JPanel {
            private static final long serialVersionUID = 1L;
            public GradientPanel(Color background) {
                setBackground(background);
            @Override
            public void paintComponent(Graphics g) {
                super.paintComponent(g);
                if (isOpaque()) {
                    Color background = new Color(168, 210, 241);
                    Color controlColor = new Color(230, 240, 230);
                    int width = getWidth();
                    int height = getHeight();
                    Graphics2D g2 = (Graphics2D) g;
                    Paint oldPaint = g2.getPaint();
                    g2.setPaint(new GradientPaint(0, 0, background, width, 0, controlColor));
                    g2.fillRect(0, 0, width, height);
                    g2.setPaint(oldPaint);
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
                    } catch (Exception fail) {
                    UIManager.getLookAndFeelDefaults().put("nimbusFocus", Color.RED);
                    NimbusBorderPainterDemo nimbusBorderPainterDemo = new NimbusBorderPainterDemo();
    }

  • Windows 10 look and feel thoughts

    First off I want to start by saying I've run Windows 8/8.1 from the beginning on all my machines. With Windows 8 I didn't miss the start menu and quickly understood the advantages and the short cuts. Also working for a large software company
    I personally made sure that we created a Windows 8 app and a Windows 8 Phone app. Oh yea, early adopter of the Windows 8 phone too which I still absolutely love. I'm not saying everything was rosy. I still have Win App API complaints
    which I voiced on another thread years ago and still have the same complaint all thought I do understand why they do what they do. There are so many great features in Windows 8/8.1/10. Being able to log in once from any device and access the same information,
    desktop and One Drive. Now I can't live with out these features. Home, office, phone, surface. I love it.
    The second the Windows 10 preview launched it was loaded on my laptop and surface. Not even VM. Yes it crashes a lot. It's a tech preview. Of course it does.
    I demoed some bleeding edge code on a bleeding edge OS to a customer. By bleeding I mean cut your wrist bleeding. It's a tech preview I knew better. After that tragedy, I had to get ready for our yearly conference which I planed
    on using Windows 10 for but instead decided to reload my laptop with Windows 7.... I have barely touched Windows 7 in years. Why Windows 7. The start menu. I didn't realize that missed it and how much better it is to use till Windows 10. In Windows
    10, I love the new start menu. Incorporating the live tiles with the basic Win 7 start menu ready extend it functionally and make it far easier and efficient to use.
    This is where I realized the difference and it's really just purely visual, but that is a lot. It isn't just the start menu. I miss the look and feel of Windows 7. The features in Windows 7 don't even compare with the new versions of Windows but why is it
    that Windows 10 still feel like Windows 3.1. Hardware has only gotten better. Even the GPU onboard of the newer CPUs is better than a lot of video cards these days however Win forms, shadowing all of the visuals that made Windows 7, well for
    lack of a better word, pretty. They are all gone. Win 8 to 10 are all about WPF and that's ok, but even WPF looks and feels better on Windows 7. This is where the new OSs fail. I know that the difference in the way WPF and Win forms appear has been
    highlighted on more than a few threads. But I think it's beyond that. The whole presentation in Windows 10 is just lacking.
    Now, would I personally go back to Windows 7 on all machines because of the visual short comings of Windows 10. No, of course not. The new features are far to valuable. But I'll never demo anything with dialogs, forms and even WPF forms on
    anything other than Windows 7 again. A 6 year old feature lacking OS that just looks more refined than the current OSs.
    Just some thoughts. Some people might not agree with me.

    I'd try them over here.
    http://answers.microsoft.com/en-us/windows/forum/windows_tp?tab=Threads
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • Push Button look and feel

    Hi,
    I am using forms 10g
    I have a requirement to make the look and feel of the push button like a hyperlink.
    Basically the button background should merge with the canvas background and text should appear on the canvas.
    I have to use push buttons only as i have a require setting mouse navigate property for the buttons to function correctly.
    I tried using image instead of buttons but image does not have mouse navigate property.
    kindly reply as this is becoming a show stopper fr the proposed look and feel in the current project.
    Edited by: user3067156 on May 4, 2010 6:01 AM

    One use case for setting mouse navigate property to yes is mentioned in this link
    http://www.oracle.com/technology/obe/obe_as_10g/bi/forms/formsmasterdetailobe.htm
    When Mouse Navigate is No, Form Builder does not perform navigation to the item when the end user activates it with the mouse. For example, a mouse click in a button or check box is not treated as a navigational event.
    Form Builder fires any triggers defined for the button or check box (such as When-Button-Pressed), but the input focus remains in the current item.
    When Mouse Navigate is Yes, Form Builder navigates to the item, firing any appropriate navigation and validation triggers on the way.
    if the button performs query or cancel mouse navigate is set to No
    if the button performs first ,next, commit record mouse navigate is set to Yes.

  • F2 Edit in JTable -- standard for all look and feel ?

    hi,
    I use a robot to simulate a F2 when a column is in focus in a JTABLE so that user can just type without having to type the <F2> key.
    My question is:
    Is F2 (to get a column in edit mode) for JTABLE standard for all look and feel (metal, X-windows ..) ?
    Thanks.
    Tony

    Read the JTable API. There is a link the gives the
    standard key assignments for the standard LAF's.thanks. got it.

  • Mac like Look and Feel

    Can I find Look and Feel with Mac Style for Windows? Is it really? I found one, but it is very slow (and has bugs).

    How you seen the same program being run under Win default LookAndFeel and under Mac one. If you happen to do you'll change your attitude :p
    Yes, I've seen both looks and feels.
    If I'm using a Windows box I expect applications to look and behave like Windows applications, and similarly for Mac. A large number of users of each system have no experience with the other and there's plently who, like me, are perfectly familiar with Windows but only partially familiar with Mac interfaces.
    Let's take an example, from the Quaqua L&F:
    http://javootoo.l2fprod.com/plaf/quaqua/quaqua_filechooser_panther.png
    If I had that appear in Windows I'd scream. I'd have to try and remember what the coloured blobs in the title bar mean, I'd have to figure out how that file chooser works (like I do every time I use Gimp with its GTK file chooser that seems totally unfriendly to me). All second nature to Mac users of course, but it just makes life really difficult for Windows users, and probably simply because some stupid software developer somewhere thought that coloured blobs "look way more cool than Windows stuff."
    :o)
    Rule of thumb is that you'd better have a good reason for using anything other than platform look and feel, because if you do so without great care then chances are you're making life a lot harder for your users if you do.

  • JFileChooser not opening when we applied custom Look and Feel & Theme

    Dear All,
    JFileChooser not opening when we applied custom Look and Feel & Theme.
    The following is the source code
    import java.awt.Color;
    import javax.swing.*;
    import javax.swing.plaf.ColorUIResource;
    import javax.swing.plaf.metal.MetalLookAndFeel;
    import com.jgoodies.looks.plastic.*;
    public class CustomTheme {
    public static void main(String[] args)throws UnsupportedLookAndFeelException{
    UIManager.setLookAndFeel(new MyLookAndFeel());
    MyLookAndFeel.setCurrentTheme(new CustomLaF());
    JFrame frame = new JFrame("Metal Theme");
    JFileChooser jf = new JFileChooser();
    System.out.println("UI - > "+jf.getUI());
    //jf.updateUI();
    frame.getContentPane().add(jf);
    frame.pack();
    frame.setVisible(true);
    static class CustomLaF extends PlasticTheme {
    protected ColorUIResource getPrimary1() {
    return new ColorUIResource(232,132,11);
    public ColorUIResource getPrimary2() {
              return (new ColorUIResource(Color.white));
         public ColorUIResource getPrimary3() {
              return (new ColorUIResource(232,132,11));
    public ColorUIResource getPrimaryControl() {
    return new ColorUIResource(Color.GREEN);
    protected ColorUIResource getSecondary1() {
    return new ColorUIResource(Color.CYAN);
    protected ColorUIResource getSecondary2() {
              return (new ColorUIResource(Color.gray));
         protected ColorUIResource getSecondary3() {
              return (new ColorUIResource(235,235,235));
         protected ColorUIResource getBlack() {
              return BLACK;
         protected ColorUIResource getWhite() {
              return WHITE;
    static class MyLookAndFeel extends Plastic3DLookAndFeel {
              protected void initClassDefaults(UIDefaults table) {
                   super.initClassDefaults(table);
              protected void initComponentDefaults(UIDefaults table) {
                   super.initComponentDefaults(table);
                   Object[] defaults = {
                             "MenuItem.foreground",new ColorUIResource(Color.white),
                             "MenuItem.background",new ColorUIResource(Color.gray),
                             "MenuItem.selectionForeground",new ColorUIResource(Color.gray),
                             "MenuItem.selectionBackground",new ColorUIResource(Color.white),
                             "Menu.selectionForeground", new ColorUIResource(Color.white),
                             "Menu.selectionBackground", new ColorUIResource(Color.gray),
                             "MenuBar.background", new ColorUIResource(235,235,235),
                             "Menu.background", new ColorUIResource(235,235,235),
                             "Desktop.background",new ColorUIResource(235,235,235),
                             "Button.select",new ColorUIResource(232,132,11),
                             "Button.focus",new ColorUIResource(232,132,11),
                             "TableHeader.background", new ColorUIResource(232,132,11),
                             "TableHeader.foreground", new ColorUIResource(Color.white),
                             "ScrollBar.background", new ColorUIResource(235,235,235),
                             "ToolTip.foreground", new ColorUIResource(232,132,11),
                             "ToolTip.background", new ColorUIResource(Color.white),
                             "OptionPane.questionDialog.border.background", new ColorUIResource(Color.gray),
                             "OptionPane.errorDialog.titlePane.foreground", new ColorUIResource(Color.white),
                             "OptionPane.questionDialog.titlePane.background", new ColorUIResource(232,132,11),
                             "Table.selectionBackground", new ColorUIResource(232,132,11)
                   table.putDefaults(defaults);
    When i run this program the following error is coming:
    Exception in thread "main" java.lang.NullPointerException
    at javax.swing.plaf.metal.MetalFileChooserUI$IndentIcon.getIconWidth(Unknown Source)
    at javax.swing.SwingUtilities.layoutCompoundLabelImpl(Unknown Source)
    at javax.swing.SwingUtilities.layoutCompoundLabel(Unknown Source)
    at javax.swing.plaf.basic.BasicLabelUI.layoutCL(Unknown Source)
    at javax.swing.plaf.basic.BasicLabelUI.getPreferredSize(Unknown Source)
    at javax.swing.JComponent.getPreferredSize(Unknown Source)
    at javax.swing.plaf.basic.BasicListUI.updateLayoutState(Unknown Source)
    at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(Unknown Source)
    at javax.swing.plaf.basic.BasicListUI$ListSelectionHandler.valueChanged(Unknown Source)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
    at javax.swing.DefaultListSelectionModel.changeSelection(Unknown Source)
    at javax.swing.DefaultListSelectionModel.changeSelection(Unknown Source)
    at javax.swing.DefaultListSelectionModel.setSelectionInterval(Unknown Source)
    at javax.swing.JList.setSelectedIndex(Unknown Source)
    at javax.swing.plaf.basic.BasicComboPopup.setListSelection(Unknown Source)
    at javax.swing.plaf.basic.BasicComboPopup.access$000(Unknown Source)
    at javax.swing.plaf.basic.BasicComboPopup$ItemHandler.itemStateChanged(Unknown Source)
    at javax.swing.JComboBox.fireItemStateChanged(Unknown Source)
    at javax.swing.JComboBox.selectedItemChanged(Unknown Source)
    at javax.swing.JComboBox.contentsChanged(Unknown Source)
    at javax.swing.AbstractListModel.fireContentsChanged(Unknown Source)
    at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.setSelectedItem(Unknow
    at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.addItem(Unknown Source
    at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.access$2300(Unknown So
    at javax.swing.plaf.metal.MetalFileChooserUI.doDirectoryChanged(Unknown Source)
    at javax.swing.plaf.metal.MetalFileChooserUI.access$2600(Unknown Source)
    at javax.swing.plaf.metal.MetalFileChooserUI$12.propertyChange(Unknown Source)
    at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(Unknown Source)
    at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(Unknown Source)
    at javax.swing.JComponent.firePropertyChange(Unknown Source)
    at javax.swing.JFileChooser.setCurrentDirectory(Unknown Source)
    at javax.swing.JFileChooser.<init>(Unknown Source)
    at javax.swing.JFileChooser.<init>(Unknown Source)
    at CustomTheme.main(CustomTheme.java:20)
    I am extending the JGoodies Look And Feel & Theme.
    Thanks in advance
    Krishna Mohan.

    Dear cupofjoe,
    Thank you for your response.
    I am using the Latest JGoodies Look & Feel which is downloaded from http://www.jgoodies.com.
    i am writing our own custom Look & Feel By Overridding Jgoodies Look & Feel.
    In that case i am getting that error.
    The following is the source code:
    import java.awt.Color;
    import javax.swing.*;
    import javax.swing.plaf.ColorUIResource;
    import javax.swing.plaf.metal.MetalLookAndFeel;
    import com.jgoodies.looks.plastic.*;
    public class CustomTheme {
    public static void main(String[] args)throws UnsupportedLookAndFeelException{
    UIManager.setLookAndFeel(new MyLookAndFeel());
    MyLookAndFeel.setCurrentTheme(new CustomLaF());
    JFrame frame = new JFrame("Metal Theme");
    JFileChooser jf = new JFileChooser();
    //System.out.println("UI - > "+jf.getUI());
    //jf.updateUI();
    //frame.getContentPane().add(jf);
    frame.pack();
    frame.setVisible(true);
    static class CustomLaF extends PlasticTheme {
    protected ColorUIResource getPrimary1() {
    return new ColorUIResource(232,132,11);
    public ColorUIResource getPrimary2() {
              return (new ColorUIResource(Color.white));
         public ColorUIResource getPrimary3() {
              return (new ColorUIResource(232,132,11));
    public ColorUIResource getPrimaryControl() {
    return new ColorUIResource(Color.GREEN);
    protected ColorUIResource getSecondary1() {
    return new ColorUIResource(Color.CYAN);
    protected ColorUIResource getSecondary2() {
              return (new ColorUIResource(Color.gray));
         protected ColorUIResource getSecondary3() {
              return (new ColorUIResource(235,235,235));
         protected ColorUIResource getBlack() {
              return BLACK;
         protected ColorUIResource getWhite() {
              return WHITE;
    static class MyLookAndFeel extends Plastic3DLookAndFeel {
              protected void initClassDefaults(UIDefaults table) {
                   super.initClassDefaults(table);
              protected void initComponentDefaults(UIDefaults table) {
                   super.initComponentDefaults(table);
                   Object[] defaults = {
                             "MenuItem.foreground",new ColorUIResource(Color.white),
                             "MenuItem.background",new ColorUIResource(Color.gray),
                             "MenuItem.selectionForeground",new ColorUIResource(Color.gray),
                             "MenuItem.selectionBackground",new ColorUIResource(Color.white),
                             "Menu.selectionForeground", new ColorUIResource(Color.white),
                             "Menu.selectionBackground", new ColorUIResource(Color.gray),
                             "MenuBar.background", new ColorUIResource(235,235,235),
                             "Menu.background", new ColorUIResource(235,235,235),
                             "Desktop.background",new ColorUIResource(235,235,235),
                             "Button.select",new ColorUIResource(232,132,11),
                             "Button.focus",new ColorUIResource(232,132,11),
                             "TableHeader.background", new ColorUIResource(232,132,11),
                             "TableHeader.foreground", new ColorUIResource(Color.white),
                             "ScrollBar.background", new ColorUIResource(235,235,235),
                             "ToolTip.foreground", new ColorUIResource(232,132,11),
                             "ToolTip.background", new ColorUIResource(Color.white),
                             "OptionPane.questionDialog.border.background", new ColorUIResource(Color.gray),
                             "OptionPane.errorDialog.titlePane.foreground", new ColorUIResource(Color.white),
                             "OptionPane.questionDialog.titlePane.background", new ColorUIResource(232,132,11),
                             "Table.selectionBackground", new ColorUIResource(232,132,11)
                   table.putDefaults(defaults);
    pls suggest me the how to solve this problem.
    thanks in advance
    Krishna MOhan

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

Maybe you are looking for

  • If I make a new apple ID, will I be able to transfer my credits and purchases?

    Recently, my brother was given an iTunes Gift Card. Whenever he tries to purchase something, however, it asks for the answers to his security questions. The problem is that he has no recollection of even answering these security questions. I have no

  • Error while creating Info Object in Info object catelog

    Hi experts, I'm making few info object in info object catelog but while activating system giving error mesage as "Error when generating master data routines" can any one tell what's the problem and what needs to be done. Sumantra

  • ECLIPSE ve install program.

    I have sought many articles on net the problem about how to install VE plug-in unit successfully, but I fail with great efforts for 2 days eventually still. What I install is that eclipse3. 0 editions, after having downloaded every plug-in unit, have

  • Tms error

    Dear Sir, while i config stms path for all the 3system landscape.example J1 ,J2,J3 server.Only J2 setup is showing some error in stms t-code error is (error whwen import quaue.)please tell me the  solution of this error. Regards, K.Ramamoorthy

  • Recovering partitions

    Well, I screwed up one of the HDDs that I have installed, causing the computer to not be able to recognize the filesystem type. The HDD was on sdb and had two partitions, one NTFS for Windows, and another Fat32 that I was storing media on. I did some