javax.swing.JRootPane#PLAIN_DIALOG源码实例Demo

下面列出了javax.swing.JRootPane#PLAIN_DIALOG 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: visualvm   文件: StartupDialog.java
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;
    }
}
 
源代码2 项目: beautyeye   文件: BETitlePane.java
/**
	 * 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;
	}
 
源代码3 项目: PolyGlot   文件: POptionPane.java
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;
    }
}
 
源代码4 项目: beautyeye   文件: BETitlePane.java
/**
	 * 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);
		}
	}
 
源代码5 项目: beautyeye   文件: BETitlePane.java
/**
 * 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;
	}
}
 
源代码6 项目: beautyeye   文件: BETitlePane.java
/**
	 * 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;
		}
	}