本文整理汇总了Java中javax.swing.PopupFactory.setSharedInstance方法的典型用法代码示例。如果您正苦于以下问题:Java PopupFactory.setSharedInstance方法的具体用法?Java PopupFactory.setSharedInstance怎么用?Java PopupFactory.setSharedInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.PopupFactory
的用法示例。
在下文中一共展示了PopupFactory.setSharedInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPopupFactory
import javax.swing.PopupFactory; //导入方法依赖的package包/类
public static void setPopupFactory() {
PopupFactory.setSharedInstance(new PopupFactory() {
@Override
public Popup getPopup(Component owner, Component contents, int x, int y) throws IllegalArgumentException {
if (contents instanceof JToolTip) {
JToolTip toolTip = (JToolTip)contents;
int width = (int) toolTip.getPreferredSize().getWidth();
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
int screenWidth = gd.getDisplayMode().getWidth();
// if there is enough room, move tooltip to the right to have enough room
// for large tooltips.
// this way they don't hinder mouse movement and make it possible to easily
// view multiple tooltips of items.
if (x + width + TOOLTIP_X_OFFSET < screenWidth) {
x += TOOLTIP_X_OFFSET;
}
}
return super.getPopup(owner, contents, x, y);
}
});
}
示例2: install
import javax.swing.PopupFactory; //导入方法依赖的package包/类
public static void install() {
PopupFactory factory = PopupFactory.getSharedInstance();
if (factory instanceof RoundedPopupFactory) {
return;
}
PopupFactory.setSharedInstance(new RoundedPopupFactory(factory));
}
示例3: uninstall
import javax.swing.PopupFactory; //导入方法依赖的package包/类
public static void uninstall() {
PopupFactory factory = PopupFactory.getSharedInstance();
if (!(factory instanceof RoundedPopupFactory)) {
return;
}
PopupFactory stored = ((RoundedPopupFactory) factory).storedFactory;
PopupFactory.setSharedInstance(stored);
}
示例4: initialize
import javax.swing.PopupFactory; //导入方法依赖的package包/类
public static void initialize() {
if(initialized)
return;
try {
PopupFactory oldFactory = PopupFactory.getSharedInstance();
PopupFactory.setSharedInstance(new AppletPopupFactory(oldFactory));
} finally {
initialized = true;
}
}
示例5: installOther
import javax.swing.PopupFactory; //导入方法依赖的package包/类
@Override
protected void installOther(UIDefaults table)
{
// 使用自定义工厂, 设置Popup为透明, 否则无法使用阴影边框
// Use a custom factory, set the Popup to be transparent.
// otherwise you can not use the shadow border.
PopupFactory.setSharedInstance(new LuckPopupFactory());
}
示例6: setupLookAndFeel
import javax.swing.PopupFactory; //导入方法依赖的package包/类
/**
* Setup applications Look and Feel.
*/
private void setupLookAndFeel(ApplicationArguments args)
{
/*
* Don't prevent the user from overriding the laf is they choose to use
* Swing's default laf prop
*/
String userSpecifiedOverride = System.getProperty("swing.defaultlaf");
if (userSpecifiedOverride != null && !"".equals(userSpecifiedOverride)) { return; }
String lafClassName =
args.useNativeLAF() ? UIManager.getSystemLookAndFeelClassName() : MetalLookAndFeel.class.getName();
if (!args.useDefaultMetalTheme())
{
MetalLookAndFeel.setCurrentTheme(new AllBluesBoldMetalTheme());
}
try
{
// The following is a work-around for the problem on Mac OS X where
// the Apple LAF delegates to the Swing Popup factory but then
// tries to set a 90% alpha on the underlying Cocoa window, which
// will always be null if you're using JGoodies L&F
// see http://www.caimito.net/pebble/2005/07/26/1122392314480.html#comment1127522262179
// This has no effect on Linux/Windows
PopupFactory.setSharedInstance(new PopupFactory());
UIManager.setLookAndFeel(lafClassName);
}
catch (Exception ex)
{
// i18n[Application.error.setlaf=Error setting LAF]
s_log.error(s_stringMgr.getString("Application.error.setlaf"), ex);
}
}
示例7: install
import javax.swing.PopupFactory; //导入方法依赖的package包/类
public static void install()
/* 22: */ {
/* 23:117 */ if (LookUtils.IS_OS_MAC) {
/* 24:118 */ return;
/* 25: */ }
/* 26:121 */ PopupFactory factory = PopupFactory.getSharedInstance();
/* 27:122 */ if ((factory instanceof ShadowPopupFactory)) {
/* 28:123 */ return;
/* 29: */ }
/* 30:125 */ PopupFactory.setSharedInstance(new ShadowPopupFactory(factory));
/* 31: */ }
示例8: uninstall
import javax.swing.PopupFactory; //导入方法依赖的package包/类
public static void uninstall()
/* 34: */ {
/* 35:135 */ PopupFactory factory = PopupFactory.getSharedInstance();
/* 36:136 */ if (!(factory instanceof ShadowPopupFactory)) {
/* 37:137 */ return;
/* 38: */ }
/* 39:139 */ PopupFactory stored = ((ShadowPopupFactory)factory).storedFactory;
/* 40:140 */ PopupFactory.setSharedInstance(stored);
/* 41: */ }
示例9: install
import javax.swing.PopupFactory; //导入方法依赖的package包/类
/**
* Installs the ShadowPopupFactory as the shared popup factory
* on non-Mac platforms. Also stores the previously set factory,
* so that it can be restored in <code>#uninstall</code>.<p>
*
* In some Mac Java environments the popup factory throws
* a NullPointerException when we call <code>#getPopup</code>.<p>
*
* The Mac case shows that we may have problems replacing
* non PopupFactory instances. Therefore we should consider
* replacing only instances of PopupFactory.
*
* @see #uninstall()
*/
public static void install() {
final String os = System.getProperty("os.name");
final boolean macintosh = os != null && os.indexOf("Mac") != -1;
if (macintosh) {
return;
}
final PopupFactory factory = PopupFactory.getSharedInstance();
if (factory instanceof ShadowPopupFactory) {
return;
}
PopupFactory.setSharedInstance(new ShadowPopupFactory(factory));
}
示例10: uninstall
import javax.swing.PopupFactory; //导入方法依赖的package包/类
/**
* Uninstalls the ShadowPopupFactory and restores the original
* popup factory as the new shared popup factory.
*
* @see #install()
*/
public static void uninstall() {
final PopupFactory factory = PopupFactory.getSharedInstance();
if (!(factory instanceof ShadowPopupFactory)) {
return;
}
final PopupFactory stored = ((ShadowPopupFactory) factory).storedFactory;
PopupFactory.setSharedInstance(stored);
}
示例11: JScalablePanel
import javax.swing.PopupFactory; //导入方法依赖的package包/类
public JScalablePanel() {
super();
setLayout(cl);
autoscrollingTask = new AutoScrollTimerTask();
autoscrollingTimer = new Timer(AUTO_SCROLLING_DELAY, autoscrollingTask);
setOpaque(false);
EventsTargetPanel leventsTarget = new EventsTargetPanel();
drawWall = new DrawWallPanel(leventsTarget);
add(drawWall, DrawWallPanel.class.getSimpleName());
add(leventsTarget, EventsTargetPanel.class.getSimpleName());
eventsTarget = leventsTarget;
drawWall.addMouseListener(this);
drawWall.addMouseMotionListener(this);
drawWall.addMouseWheelListener(this);
if (PopupFactory.getSharedInstance() == null || !(PopupFactory.getSharedInstance() instanceof ScalablePopupFactory)) {
PopupFactory.setSharedInstance(new ScalablePopupFactory(PopupFactory.getSharedInstance()));
}
try {
ScalableTransferHandler sclTHandler = new ScalableTransferHandler(this);
setTransferHandler(sclTHandler);
getDropTarget().addDropTargetListener(this);
} catch (TooManyListenersException ex) {
Logger.getLogger(JScalablePanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例12: uninstall
import javax.swing.PopupFactory; //导入方法依赖的package包/类
/**
* Uninstalls the ShadowPopupFactory and restores the original
* popup factory as the new shared popup factory.
*
* @see #install()
*/
public static void uninstall() {
PopupFactory factory = PopupFactory.getSharedInstance();
if (!(factory instanceof ShadowPopupFactory)) {
return;
}
PopupFactory stored = ((ShadowPopupFactory) factory).storedFactory;
PopupFactory.setSharedInstance(stored);
}
示例13: tweakNimbusUI
import javax.swing.PopupFactory; //导入方法依赖的package包/类
private static void tweakNimbusUI() {
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
defaults.put("nimbusOrange", defaults.get("nimbusBase"));
defaults.put("Table.gridColor", new Color(214, 217, 223));
defaults.put("Table.disabled", false);
defaults.put("Table.showGrid", true);
defaults.put("Table.intercellSpacing", new Dimension(1, 1));
defaults.put("CheckBoxMenuItem.font", new java.awt.Font("sansserif", 0, 11));
defaults.put("RadioButtonMenuItem.font", new java.awt.Font("sansserif", 0, 11));
defaults.put("MenuItem.font", new java.awt.Font("sansserif", 0, 11));
defaults.put("Menu.font", new java.awt.Font("sansserif", 0, 11));
defaults.put("Table.font", new java.awt.Font("sansserif", 0, 11));
defaults.put("Label.font", new java.awt.Font("sansserif", 0, 11));
defaults.put("TextField.font", new java.awt.Font("sansserif", 0, 11));
defaults.put("TextArea.font", new java.awt.Font("sansserif", 0, 11));
defaults.put("CheckBox.font", new java.awt.Font("sansserif", 0, 11));
defaults.put("ComboBox.font", new java.awt.Font("sansserif", 0, 11));
defaults.put("ToolTip.font", new java.awt.Font("sansserif", 0, 11));
defaults.put("Button.font", new java.awt.Font("sansserif", 0, 11));
defaults.put("TableHeader.font", new java.awt.Font("sansserif", 0, 11));
defaults.put("FileChooser.font", new java.awt.Font("sansserif", 0, 11));
/**
* custom tab-area border painter
*/
Painter tabborder = (Painter) (Graphics2D g, Object object, int width, int height) -> {
//add code to customize
};
defaults.put("TabbedPane:TabbedPaneTabArea[Disabled].backgroundPainter", tabborder);
defaults.put("TabbedPane:TabbedPaneTabArea[Enabled+MouseOver].backgroundPainter", tabborder);
defaults.put("TabbedPane:TabbedPaneTabArea[Enabled+Pressed].backgroundPainter", tabborder);
defaults.put("TabbedPane:TabbedPaneTabArea[Enabled].backgroundPainter", tabborder);
PopupFactory.setSharedInstance(new PopupFactory() {
@Override
public Popup getPopup(Component owner, final Component contents, int x, int y) throws IllegalArgumentException {
Popup popup = super.getPopup(owner, contents, x, y);
SwingUtilities.invokeLater(() -> {
contents.repaint();
});
return popup;
}
});
}
示例14: uninitialize
import javax.swing.PopupFactory; //导入方法依赖的package包/类
public void uninitialize()
{
PopupFactory.setSharedInstance(new PopupFactory());
}
示例15: uiImpl
import javax.swing.PopupFactory; //导入方法依赖的package包/类
/**
* Ui impl.
*/
public static void uiImpl()
{
PopupFactory.setSharedInstance(popupFactoryDIY);
}