Java Code Examples for javax.swing.JRootPane#PLAIN_DIALOG

The following examples show how to use javax.swing.JRootPane#PLAIN_DIALOG . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StartupDialog.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private static int styleFromMessageType(int messageType) {
    switch (messageType) {
    case JOptionPane.ERROR_MESSAGE:
        return JRootPane.ERROR_DIALOG;
    case JOptionPane.QUESTION_MESSAGE:
        return JRootPane.QUESTION_DIALOG;
    case JOptionPane.WARNING_MESSAGE:
        return JRootPane.WARNING_DIALOG;
    case JOptionPane.INFORMATION_MESSAGE:
        return JRootPane.INFORMATION_DIALOG;
    case JOptionPane.PLAIN_MESSAGE:
    default:
        return JRootPane.PLAIN_DIALOG;
    }
}
 
Example 2
Source File: BETitlePane.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
	 * Returns the <code>JMenu</code> displaying the appropriate menu items
	 * for manipulating the Frame.
	 *
	 * @return the j menu
	 */
	private JMenu createMenu()
	{
		JMenu menu = new JMenu("");
//		menu.setRolloverEnabled(false);//本行一定要!这是Java 1.5之Metal主题的Bug! -- jack,2009-09-11
		menu.setOpaque(false);//本行一定要,否则将导致窗口图标区会绘制Menu的背景!这是Java Metal主题的Bug! -- jack,2009-09-11
		if (getWindowDecorationStyle() == JRootPane.FRAME
				||getWindowDecorationStyle() == JRootPane.PLAIN_DIALOG//现在也给dialog加上菜单项(但只有关闭项)
			)
		{
			addMenuItems(menu);
		}
		return menu;
	}
 
Example 3
Source File: POptionPane.java    From PolyGlot with MIT License 5 votes vote down vote up
private static int internalStyleFromMessageType(int messageType) {
    switch (messageType) {
        case ERROR_MESSAGE:
            return JRootPane.ERROR_DIALOG;
        case QUESTION_MESSAGE:
            return JRootPane.QUESTION_DIALOG;
        case WARNING_MESSAGE:
            return JRootPane.WARNING_DIALOG;
        case INFORMATION_MESSAGE:
            return JRootPane.INFORMATION_DIALOG;
        case PLAIN_MESSAGE:
        default:
            return JRootPane.PLAIN_DIALOG;
    }
}
 
Example 4
Source File: BETitlePane.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
/**
	 * Adds any sub-Components contained in the <code>MetalTitlePane</code>.
	 */
	private void installSubcomponents()
	{
		int decorationStyle = getWindowDecorationStyle();
		
		if (decorationStyle == JRootPane.FRAME||decorationStyle == JRootPane.PLAIN_DIALOG)
		{
			createActions();
			menuBar = createMenuBar();
			add(menuBar);
			createButtons();
			
			add(closeButton);
			
			//~* RootPane.setupButtonVisible是jb2011自定义的属性哦,目的是控制这个当前用于演示的设置按钮的可见性
			Object isSetupButtonVisibleObj = UIManager.get("RootPane.setupButtonVisible");
			//如果开发者没有设置此属性则默认认为是true(即显示该按钮)
			boolean isSetupButtonVisible = (isSetupButtonVisibleObj==null?true:(Boolean)isSetupButtonVisibleObj);
			if(isSetupButtonVisible)
				//加入设置按钮
				add(setupButton);
			
			if(decorationStyle!=JRootPane.PLAIN_DIALOG)//!
			{
				add(iconifyButton);
				add(toggleButton);
				menuBar.setEnabled(false);
			}
		}
		else if 
		(
//				decorationStyle == JRootPane.PLAIN_DIALOG
//				||
				decorationStyle == JRootPane.INFORMATION_DIALOG
				|| decorationStyle == JRootPane.ERROR_DIALOG
				|| decorationStyle == JRootPane.COLOR_CHOOSER_DIALOG
				|| decorationStyle == JRootPane.FILE_CHOOSER_DIALOG
				|| decorationStyle == JRootPane.QUESTION_DIALOG
				|| decorationStyle == JRootPane.WARNING_DIALOG)
		{
			createActions();
			createButtons();
			add(closeButton);
		}
	}
 
Example 5
Source File: BETitlePane.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
/**
 * Determines the Colors to draw with.
 */
private void determineColors()
{
	switch (getWindowDecorationStyle())
	{
		case JRootPane.FRAME:
			activeBackground = UIManager.getColor("activeCaption");
			activeForeground = UIManager.getColor("activeCaptionText");
			activeShadow = UIManager.getColor("activeCaptionBorder");
			break;
		case JRootPane.ERROR_DIALOG:
			activeBackground = UIManager
					.getColor("OptionPane.errorDialog.titlePane.background");
			activeForeground = UIManager
					.getColor("OptionPane.errorDialog.titlePane.foreground");
			activeShadow = UIManager
					.getColor("OptionPane.errorDialog.titlePane.shadow");
			break;
		case JRootPane.QUESTION_DIALOG:
		case JRootPane.COLOR_CHOOSER_DIALOG:
		case JRootPane.FILE_CHOOSER_DIALOG:
			activeBackground = UIManager
					.getColor("OptionPane.questionDialog.titlePane.background");
			activeForeground = UIManager
					.getColor("OptionPane.questionDialog.titlePane.foreground");
			activeShadow = UIManager
					.getColor("OptionPane.questionDialog.titlePane.shadow");
			break;
		case JRootPane.WARNING_DIALOG:
			activeBackground = UIManager
					.getColor("OptionPane.warningDialog.titlePane.background");
			activeForeground = UIManager
					.getColor("OptionPane.warningDialog.titlePane.foreground");
			activeShadow = UIManager
					.getColor("OptionPane.warningDialog.titlePane.shadow");
			break;
		case JRootPane.PLAIN_DIALOG:
		case JRootPane.INFORMATION_DIALOG:
		default:
			activeBackground = UIManager.getColor("activeCaption");
			activeForeground = UIManager.getColor("activeCaptionText");
			activeShadow = UIManager.getColor("activeCaptionBorder");
			break;
	}
}
 
Example 6
Source File: BETitlePane.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
/**
	 * Renders the TitlePane.
	 *
	 * @param g the g
	 */
	public void paintComponent(Graphics g)
	{
		// As state isn't bound, we need a convenience place to check
		// if it has changed. Changing the state typically changes the
		if (getFrame() != null)
		{
			setState(getFrame().getExtendedState());
		}
		JRootPane rootPane = getRootPane();
		Window window = getWindow();
		boolean leftToRight = (window == null) ? rootPane
				.getComponentOrientation().isLeftToRight() : window
				.getComponentOrientation().isLeftToRight();
		boolean isSelected = (window == null) ? true : window.isActive();
		int width = getWidth();
		int height = getHeight();

		Color background;
		Color foreground;
		Color darkShadow;

		if (isSelected)
		{
			background = activeBackground;
			foreground = activeForeground;
			darkShadow = activeShadow;
		}
		else
		{
			background = inactiveBackground;
			foreground = inactiveForeground;
			darkShadow = inactiveShadow;
//			bumps = inactiveBumps;
		}
		//----------------------------------------------- 标题背景
		paintTitlePane(g,0,0,width,height,isSelected);

		//----------------------------------------------- 标题文字和图片
		int xOffset = leftToRight ? 5 : width - 5;

		if (getWindowDecorationStyle() == JRootPane.FRAME||getWindowDecorationStyle() ==JRootPane.PLAIN_DIALOG)
		{
			xOffset += leftToRight ? IMAGE_WIDTH + 5 : -IMAGE_WIDTH - 5;
		}

		String theTitle = getTitle();
		if (theTitle != null)
		{
			FontMetrics fm = MySwingUtilities2.getFontMetrics(rootPane, g);
			int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent();

			Rectangle rect = new Rectangle(0, 0, 0, 0);
			if (iconifyButton != null && iconifyButton.getParent() != null)
			{
				rect = iconifyButton.getBounds();
			}
			int titleW;

			if (leftToRight)
			{
				if (rect.x == 0)
				{
					rect.x = window.getWidth() - window.getInsets().right - 2;
				}
				titleW = rect.x - xOffset - 4;
				theTitle = MySwingUtilities2.clipStringIfNecessary(rootPane, fm,
						theTitle, titleW);
			}
			else
			{
				titleW = xOffset - rect.x - rect.width - 4;
				theTitle = MySwingUtilities2.clipStringIfNecessary(rootPane, fm,
						theTitle, titleW);
				xOffset -= MySwingUtilities2.stringWidth(rootPane, fm, theTitle);
			}
			
			int titleLength = MySwingUtilities2.stringWidth(rootPane, fm,theTitle);
			g.setColor(foreground);
			MySwingUtilities2.drawString(rootPane, g, theTitle, xOffset, yOffset);
			xOffset += leftToRight ? titleLength + 5 : -5;
		}
	}