我想用getDesktopProperty()函数得到系统任务栏的属性值,就是不知道这个属性的名字
高手指点一下

解决方案 »

  1.   

    http://gceclub.sun.com.cn/Java_Docs/jdk6/html/zh_CN/api/java/awt/doc-files/DesktopProperties.htmlapi上说的很清楚了
      

  2.   

    这上面的Property貌似只举了一个例子 awt.font.desktophints桌面属性抽象了其下平台的设置,是具有平台依赖的,大部分是windows平台的String propnames[] = (String[]) Toolkit.getDefaultToolkit()
    .getDesktopProperty("win.propNames");
    System.out.println("Supported windows property names:");
    for (int i = 0; i < propnames.length; i++) {
        System.out.println(propnames[i]);
    }Supported windows property names:
    DnD.gestureMotionThreshold
    awt.dynamicLayoutSupported
    awt.file.showAttribCol
    awt.file.showHiddenFiles
    awt.font.desktophints
    awt.mouse.numButtons
    awt.multiClickInterval
    awt.wheelMousePresent
    win.3d.backgroundColor
    win.3d.darkShadowColor
    win.3d.highlightColor
    win.3d.lightColor
    win.3d.shadowColor
    win.ansiFixed.font
    win.ansiFixed.font.height
    win.ansiVar.font
    win.ansiVar.font.height
    win.button.textColor
    win.defaultGUI.font
    win.defaultGUI.font.height
    win.desktop.backgroundColor
    win.deviceDefault.font
    win.deviceDefault.font.height
    win.drag.height
    win.drag.width
    win.frame.activeBorderColor
    win.frame.activeCaptionColor
    win.frame.activeCaptionGradientColor
    win.frame.backgroundColor
    win.frame.captionButtonHeight
    win.frame.captionButtonWidth
    win.frame.captionFont
    win.frame.captionFont.height
    win.frame.captionGradientsOn
    win.frame.captionHeight
    win.frame.captionTextColor
    win.frame.color
    win.frame.fullWindowDragsOn
    win.frame.inactiveBorderColor
    win.frame.inactiveCaptionColor
    win.frame.inactiveCaptionGradientColor
    win.frame.inactiveCaptionTextColor
    win.frame.sizingBorderWidth
    win.frame.smallCaptionButtonHeight
    win.frame.smallCaptionButtonWidth
    win.frame.smallCaptionFont
    win.frame.smallCaptionFont.height
    win.frame.smallCaptionHeight
    win.frame.textColor
    win.highContrast.on
    win.icon.font
    win.icon.font.height
    win.icon.hspacing
    win.icon.shellIconBPP
    win.icon.titleWrappingOn
    win.icon.vspacing
    win.item.highlightColor
    win.item.highlightTextColor
    win.item.hotTrackedColor
    win.item.hotTrackingOn
    win.mdi.backgroundColor
    win.menu.backgroundColor
    win.menu.buttonWidth
    win.menu.font
    win.menu.font.height
    win.menu.height
    win.menu.keyboardCuesOn
    win.menu.textColor
    win.menubar.backgroundColor
    win.messagebox.font
    win.messagebox.font.height
    win.oemFixed.font
    win.oemFixed.font.height
    win.properties.version
    win.scrollbar.backgroundColor
    win.scrollbar.height
    win.scrollbar.width
    win.sound.asterisk
    win.sound.close
    win.sound.default
    win.sound.exclamation
    win.sound.exit
    win.sound.hand
    win.sound.maximize
    win.sound.menuCommand
    win.sound.menuPopup
    win.sound.minimize
    win.sound.open
    win.sound.question
    win.sound.restoreDown
    win.sound.restoreUp
    win.sound.start
    win.status.font
    win.status.font.height
    win.system.font
    win.system.font.height
    win.systemFixed.font
    win.systemFixed.font.height
    win.text.fontSmoothingContrast
    win.text.fontSmoothingOn
    win.text.fontSmoothingOrientation
    win.text.fontSmoothingType
    win.text.grayedTextColor
    win.tooltip.backgroundColor
    win.tooltip.font
    win.tooltip.font.height
    win.tooltip.textColor
    win.xpstyle.colorName
    win.xpstyle.dllName
    win.xpstyle.sizeName
    win.xpstyle.themeActive
      

  3.   

    6楼是个高手,好厉害呀!
    分肯定给,顺便问一下,
    我自己做了一个自定义的Frame,就是标题栏隐藏然后标题栏都自己实现就是像Msn的窗口一样。
    但是我发现,窗口最大化的时候,就变成全屏了,下面的任务栏也都覆盖住了,有办法和正常的窗口一样的,最大化的时候任务栏不被覆盖呢?
      

  4.   

    我试了,Frame和JFrame最大化的时候都不会覆盖任务栏,代码有吗,看看
      

  5.   

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;/*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    /**
     *
     * @author zhabu
     */
    public class TFrame extends JFrame {    public TFrame() {
            this.setUndecorated(true);
            this.setBounds(100, 100, 300, 300);
            this.setLayout(null);        JButton btnMax = new JButton("MaxFrame");
            btnMax.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent evt) {
                    btnMaxActionPerformed(evt);
                }
            });
            btnMax.setBounds(100, 100, 100, 25);
            this.getContentPane().add(btnMax);        JButton btnClose = new JButton("CloseFrame");
            btnClose.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent evt) {
                    btnCloseActionPerformed(evt);
                }
            });
            btnClose.setBounds(100, 130, 100, 25);
            this.getContentPane().add(btnClose);    }    private void btnMaxActionPerformed(java.awt.event.ActionEvent evt) {
            this.setExtendedState(JFrame.MAXIMIZED_BOTH);
        }    private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {
            System.exit(0);
        }    public static void main(String args[]){
            TFrame frame = new TFrame();
            frame.setVisible(true);
        }
    }
    不好意思,我的代码太乱了,整理提出来的,所以慢了点儿!
      

  6.   

    把setBounds改成this.setSize(500, 300);把this.setExtendedState(JFrame.MAXIMIZED_BOTH);替换:Rectangle rec = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
    this.setSize(rec.width, rec.height);
      

  7.   

    这个的确能做到不覆盖任务栏,
    但是如果任务栏的高度变化的话,不会跟着变呀(比如把任务栏拖动到上面)。
    我也用类似的代码达到过这个效果,代码如下
    Dimension   screen   =   Toolkit.getDefaultToolkit().getScreenSize();
    Insets   insets   =   Toolkit.getDefaultToolkit().getScreenInsets(frame.getGraphicsConfiguration());  
    frame.setSize(screenSize.width,   screenSize.height-insets.bottom);但是一样的结果,如果任务栏的状态变化了就不行了。
      

  8.   

    如果要跟着变化,最直接想到的就是加自己监听的机制,后台线程监听MaximumWindowBounds,一旦发生变化,resize,这个对粒度要求不是很高的,我不知道有没有事件主动通知的方式