public void testSetGetUI() { BasicDesktopIconUI ui = new BasicDesktopIconUI(); icon.setUI(ui); assertTrue(icon.getUI() == ui); }
WindowEx() { super("", true, true, true, true); getDesktopIcon().setUI(new BasicDesktopIconUI() { protected void installComponents() { super.installComponents(); } @Override public Dimension getPreferredSize(JComponent c) { return new Dimension(145, 25); } protected void uninstallComponents() { super.uninstallComponents(); } }); setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE); // Dispose itself when ESC is pressed from the keyboard KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { dispose(); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); javax.swing.plaf.basic.BasicInternalFrameUI ui = new javax.swing.plaf.basic.BasicInternalFrameUI(this); super.setUI(ui); ui.getNorthPane().setPreferredSize(new Dimension(ui.getNorthPane().getPreferredSize().width, 22)); super.setVisible(true); ModalLayer = new JComponent() { @Override protected void paintComponent(Graphics g) { g.setColor(getBackground()); g.fillRect(0,0,getWidth(),getHeight()); } @Override public void setBackground(Color background) { super.setBackground( background ); } }; ModalLayer.addMouseListener(new MouseAdapter(){}); ModalLayer.addMouseMotionListener(new MouseMotionAdapter(){}); ModalLayer.setOpaque(true); ModalLayer.setVisible(false); ModalLayer.setEnabled(false); ModalLayer.setBackground(new Color(0x22, 0x22, 0x22, 0xae)); ModalLayer.setLayout(new GridBagLayout()); super.addComponentListener(new ComponentAdapter(){ @Override public void componentResized(ComponentEvent ce) { ModalLayer.setBounds(1, 1, getRootPane().getWidth() - 2, getRootPane().getHeight() - 2); ModalLayer.doLayout(); } }); super.getLayeredPane().add(ModalLayer, JLayeredPane.PALETTE_LAYER); DataBase.addDataBaseListener(this); }