JOptionPane fdifferent look'n'feel to to parent ?

Should a JOptionPane have the same look and feel as the parent panel ? I've added a JOptionPane to the content pane, and although I have a windows look'n'feel, (blue title bar), the dialog has the hashed grey style title bar ?
Is this correct ?
Tony

I've added a JOptionPane to the content paneWhat? An option pane is a JDialog. You can't add it to a content pane.
If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

Similar Messages

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

  • Losing Title Bar when changing Look and Feel on the fly

    Hello,
    I have an option in my Swing app for the user to change the Look & Feel on the fly by selecting from a radio button list. The look and feel is changed when the user make the selection, however the Windows Title Bar disappears. Any ideas what I'm missing?
    private void setLook(String mode)
    String lookAndFeelClassName = null;
    UIManager.LookAndFeelInfo looks[] = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < looks.length; i++)
    if (mode.equalsIgnoreCase(looks.getName()))
    lookAndFeelClassName = looks[i].getClassName();
    break;
    try
    m_view.dispose();
    UIManager.setLookAndFeel(lookAndFeelClassName);
    SwingUtilities.updateComponentTreeUI(m_view);
    m_view.setVisible(true);
    catch (Exception e)
    JOptionPane.showMessageDialog(m_view, "Can't change look and feel:" + lookAndFeelClassName, "Invalid PLAF", JOptionPane.ERROR_MESSAGE);

    You are disposing the view. My guess is that this is your problem. Try creating a new one instead of just showing the old disposed one

  • Plaf: Using multiple Look'n'Feels at the same time

    Hi
    in our application we use different color schemes. I know have a bug that forces me two provide two different UI implementations for the same class (JTextField). One UI in the normal context (grey) and one in a special edit context (kinda yellow).
    Id like to know what is the best practice to solve this issue? I would prefer not to write a special constructor which contains the desired UI-Name but rather as such that the parent Panel knows "i am yellow, so my kids need to be yellow too"...
    What is the best way to accomplish this. Has anyone a "best pratice" idea or does swing support "conditional look and feels" ?
    Thanks in advance!
    Matthias

    This is very strange, difficult to guess the cause... never had such an issue. Normally when the object to which the audio is attached disappears the audio stops. So in your case going to a next slide should stop the audio of the previous slide. Same with object audio.
    Do you have the different audio clips (one per slide) in the Library? Could you try to delete the audio on the slide and drag it again from the Library to see if you have the same result? And what happens when you attach the audio clip to an object on the slide (you can create a totally transparent rectangle with no stroke that will not be visible to attach the audio).
    Lilybiri

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

  • Replacing part of a Look and Feel

    Hi, all,
    I have designed a new UI delegate for buttons (Both command buttons and toggle buttons), ones that fit better with the color palette, gradients, fonts, spacing, icons, borders, etc, that we have been using for much of the rest of our GUI. Up to now, I've been replacing the UI delegate of each button after I create it, but I'd like to do a global replacement of this UI for all buttons that use the default UI delegate. That way, I can still use things like JOptionPane.showXXXMessage(), and those buttons will be updated as well.
    The only way I can find to do this is to write a new Look and Feel, but I only have a new UI delegate for buttons, and I would like for any other JComponents to continue to use the default look and feel (that is, the system native look and feel, or which ever look and feel is set to be used in their properties, etc). Does anybody know of a way to tell the UIManager (or some other component it uses) to use my UI delegate for Buttons, and use it's defaults for everything else? Preferably without writing a new Look and Feel?
    Thanks!
    Adam

    To make all buttons use the BasicButtonUI you set the following:
    UIManager.put("ButtonUI", "javax.swing.plaf.basic.BasicButtonUI");I imagine that you can replace the class name with your own UI. Remember to do this after you set the look and feel.

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

  • Problems installing the new 'Look And Feel' done by Francios Degrelle

    I have download the new verison of the new 'Look And Feel' from
    http://sheikyerbouti.developpez.com/forms-pjc-bean/LAF/sources/v133/LAF_133.zip
    1- I defined a new section in formsweb.cfg named summit in the middle tier (AS 10g Rel2):
    [Summit]
    baseHTML=base.htm
    baseHTMLjinitiator=basejpi.htm
    baseHTMLjpi=basejpi.htm
    baseHTMLie=baseie.htm
    HTMLdelimiter=%
    workingDirectory=e:\app\summit
    envFile=default.env
    IE=JInitiator
    escapeparams=true
    form=customers_laf
    debug=no
    otherparams=buffer_records=%buffer% debug_messages=%debug_messages% array=%array% obr=%obr% query_only=%query_only% quiet=%quiet% render=%render% record=%record% tracegroup=%tracegroup% log=%log% term=%term% useSDI=yes
    buffer=no
    debug_messages=no
    array=no
    obr=no
    query_only=no
    quiet=yes
    render=no
    pageTitle=Summit
    serverURL=/forms/lservlet
    codebase=/forms/java
    imageBase=DocumentBase
    width=100%
    height=100%
    separateFrame=false
    splashScreen=no
    lookAndFeel=oracle
    colorScheme=blue
    logo=no
    restrictedURLparams=HTMLbodyAttrs,HTMLbeforeForm,pageTitle,HTMLafterForm,log,allow_debug,allowNewConnections
    serverApp=default
    archive_jini=frmall_jinit.jar
    archive=frmall.jar,laf.jar
    WebUtilArchive=
    jpi_download_page=http://java.sun.com/products/archive/j2se/1.4.2_09/index.html
    jpi_classid=clsid:8AD9C840-044E-11D1-B3E9-00805F499D93
    jpi_codebase=http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0
    2- then I put a copy of the file 'forms.css' in the middle tier in the folder :
    apache\apache\htdocs
    so as to be on the path and then modified PM$CSS_FILENAME in all forms to be 'forms.css' instead of 'c:\forms.css' and recompiled.
    3-I put a copy of the file 'laf.jar' in the folder : 'd\Ora_AS\forms\java' in the middle tier and added this path to the classpath environment variable.
    4- I restarted the middle tier and wrote this URL:
    http://test/forms/frmservlet/config=summit
    the customers form opened but with no background images,I added the following to the URL '&form=test_laf_color_scheme.fmx',the form opened with the default color scheme to 'purple',I changed it from a drop down list to orange and all buttons background color degraded to orange.
    My questions:
    1-where are the background images ?
    2- I cannot compile the 'laf.pll' file to 'laf.plx',when I compile I get this error:
    FRm-91507 -internal error
    P.S. I read this thread :
    FRM-91507 when compiling a library with Forms 6i
    and I didn't understand it,where do I change the Forms_Path? in the forms Home release 1 or Forms home release 2?!!!
    3-Is the 'forms.css' file properly located? if not? where do I put it?
    Sorry for the long scenario but I'm really confused?
    Thanks
    Mohammad

    Hello,
    I'm curently out of everything so I cannot answer this one. All I can tell is that images are read from the client machine or jar file. If you want read images from the application server, you need the http:// syntax.
    Francois

  • How to change the default look and feel

    Hi.
    Does anyone knows how to change the default Caspian look and feel to, for example, Nimbus ?
    Or the skin feature turns look and feel setting, as We know in java, unnecessary in javafx ?
    I´m using javafx 1.2.
    Cheers

    Canspian is not a look&feel, it's a skin.
    Look&feel only change the SwingComponent,
    regards.

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

  • How to give BSP Iview look and feel of portal??

    Hi All,
    I've created a BSP application that I use to create an Iview for portal.
    I thought that if i used htmlb tags that the look and feel of portal would be automatic to my app but its not.
    I've tried assigning portal css classes to a html table but there's no effect.
    I've previewed one of the standard ivews and viewed the source and found the path of the css file.  But when i looked for it on the server, while the out folder was there (com.sap.portal.design.portaldesigndata) , there was no css files in this folder.
    So i'm at a loss.  In summary, how do i get my bsp app to have the portal look and feel?????  I would prefer to use the css files so that if any changes are made to the standard, the changes will be reflected in my custom iviews too.
    Any help, would be most welcome,
    Liz.

    Hi Liz,
    on the properties tab for the BSP application try selecting the "Supports Portal Integration" checkbox.
    Cheers
    Graham Robbo

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

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

Maybe you are looking for

  • My HP Officejet Pro 8600 Plus is always off line and doesn't print anymore

    I use my HP Officejet Pro 8600 Plus with the wi-fi. it worked for 3 months, in the las week it is not working anymore. I verified the Ip , I verified the connection.. Nothing works it is really frustrating thanks for helping Chiara This question was

  • Disable dialog box in smartforms

    DATA: wa_ctrlop TYPE ssfctrlop,         wa_outopt TYPE ssfcompop. This is the code i'm using to generate SF. i want to generate PDF using this SF. so i don't want to display the dialogbox for "print". This is urgent. wa_ctrlop-getotf = 'X'.   wa_ctrl

  • Cannot collectto BT cloud

    I cannot connect to BT cloud. A fully up to date windows 8.1 machine working off a home network with a gigabit switch. BT cloud installs but fails to connect giving the same  error message. "Cannot connect to service check your network connection." I

  • Replacement iPhone restore problems - only a very old backup

    My partner lost her iPhone 4 and just purchased an iPhone 4S - she didn't want the new 5s (size). When she went to do a backup from her computer the most recent restore option is more than 18 months ago. She doesn't do frequent sync to iTunes but she

  • Mathematical formula for even dashed lines?

    Is there a mathmatical formula for getting evenly distributed dashed lines in Illustrator? Something involving Pi, I assume. I usually get double dashes next to each other or unevenly distributed dashes. For example, I have a stroked circle with a wi