本文整理匯總了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);
}