summaryrefslogtreecommitdiffstats
path: root/src/cppcheckplus/menu/MyMenuItem.java
blob: 6ac46e96556ce8d3d023c78cca503523fa833147 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

package cppcheckplus.menu;

import java.awt.Color;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.JMenuItem;
import javax.swing.border.Border;

import cppcheckplus.control.MyContorlUtil;

public class MyMenuItem extends JMenuItem
{
	private static final long serialVersionUID = 1L;
	private Color backgroundColor;
	private Color foregroundColor;
	private int borderThickness;
	private Border border;
	private int preferredHeight;
	
	public MyMenuItem()
	{
		backgroundColor = MyContorlUtil.MENUITEM_BACKGROUND;
		foregroundColor = MyContorlUtil.DEFAULT_TEXT_COLOR;
		borderThickness = 1;
		border = BorderFactory.createLineBorder(backgroundColor, borderThickness);
		preferredHeight = 23;
		init();
	}
	public MyMenuItem(String text)
	{
		super(text);
		backgroundColor = MyContorlUtil.MENUITEM_BACKGROUND;
		foregroundColor = MyContorlUtil.DEFAULT_TEXT_COLOR;
		borderThickness = 1;
		border = BorderFactory.createLineBorder(backgroundColor, borderThickness);
		preferredHeight = 23;
		init();
	}
	private void init()
	{
		setForeground(foregroundColor);
		setFont(MyContorlUtil.FONT_14_BOLD);
		setBackground(backgroundColor);
		setBorder(border);
	}
	@Override
	public Dimension getPreferredSize()
	{
		return new Dimension(super.getPreferredSize().width, preferredHeight);
	}
}