changedUpdate exception
[fedora-idea.git] / platform / platform-impl / src / com / intellij / ui / plaf / beg / BegMenuBorder.java
blobc101555922ec6958590d814cb4c82598a22dc342
2 /*
3 * Copyright 2000-2009 JetBrains s.r.o.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package com.intellij.ui.plaf.beg;
19 import java.awt.*;
20 import javax.swing.*;
21 import javax.swing.border.AbstractBorder;
22 import javax.swing.plaf.UIResource;
24 /**
27 public class BegMenuBorder extends AbstractBorder implements UIResource {
28 protected static Insets borderInsets = new Insets(2, 2, 2, 2);
30 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
31 JMenuItem b = (JMenuItem)c;
32 ButtonModel model = b.getModel();
34 g.translate(x, y);
35 if (c.getParent() instanceof JMenuBar){
36 if (model.isArmed() || model.isSelected()){
38 g.setColor( MetalLookAndFeel.getControlDarkShadow() );
39 g.drawLine( 0, 0, w - 2, 0 );
40 g.drawLine( 0, 0, 0, h - 1 );
41 g.drawLine( w - 2, 2, w - 2, h - 1 );
43 g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
44 g.drawLine( w - 1, 1, w - 1, h - 1 );
46 g.setColor( MetalLookAndFeel.getMenuBackground() );
47 g.drawLine( w - 1, 0, w - 1, 0 );
51 else{
52 if (model.isArmed() || (c instanceof JMenu && model.isSelected())){
54 g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
55 g.drawLine( 0, 0, w - 1, 0 );
57 g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
58 g.drawLine( 0, h - 1, w - 1, h - 1 );
61 else{
63 g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
64 g.drawLine( 0, 0, 0, h - 1 );
68 g.translate(-x, -y);
71 public Insets getBorderInsets(Component c) {
72 return borderInsets;