本文整理匯總了Java中javax.swing.PopupFactory.getPopup方法的典型用法代碼示例。如果您正苦於以下問題:Java PopupFactory.getPopup方法的具體用法?Java PopupFactory.getPopup怎麽用?Java PopupFactory.getPopup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.PopupFactory
的用法示例。
在下文中一共展示了PopupFactory.getPopup方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showToolTip
import javax.swing.PopupFactory; //導入方法依賴的package包/類
private void showToolTip(boolean flag) {
try {
if (flag) {
int qtd = heroi.getDeck().size();
String txt = (qtd == 0 ? "Nenhum card" : qtd == 1
? "1 card" : qtd + " cards");
Point p = getLocationOnScreen();
JToolTip tip = createToolTip();
tip.setTipText(txt);
PopupFactory popupFactory = PopupFactory.getSharedInstance();
tooltip = popupFactory.getPopup(this, tip, p.x + 10, p.y + 10);
tooltip.show();
} else {
tooltip.hide();
}
} catch (Exception ex) {
//ignorar
}
}
示例2: showPopup
import javax.swing.PopupFactory; //導入方法依賴的package包/類
private void showPopup(Painter p, Rectangle rect) {
mouse.deinstall();
Point l = table.getLocationOnScreen();
rect.translate(l.x, l.y);
popupRect = rect;
popupLocation = new Point(l.x + p.getX(), l.y + p.getY());
PopupFactory popupFactory = PopupFactory.getSharedInstance();
popup = popupFactory.getPopup(table, p, popupLocation.x, popupLocation.y);
popup.show();
paranoid = new Paranoid(p);
paranoid.install();
awt = new AWT();
awt.install();
}
示例3: showToolTip
import javax.swing.PopupFactory; //導入方法依賴的package包/類
private void showToolTip(boolean flag) {
try {
if (flag) {
int qtd = heroi.getMao().size();
String txt = (qtd == 0 ? "Nenhum card" : qtd == 1
? "1 card" : qtd + " cards");
Point p = getLocationOnScreen();
JToolTip tip = createToolTip();
tip.setTipText(txt);
PopupFactory popupFactory = PopupFactory.getSharedInstance();
tooltip = popupFactory.getPopup(this, tip, p.x + 10, p.y + 10);
tooltip.show();
} else {
tooltip.hide();
}
} catch (Exception ex) {
//ignorar
}
}
示例4: showPopup
import javax.swing.PopupFactory; //導入方法依賴的package包/類
private void showPopup(Set<AppearancePort> portObjects) {
dragStart = null;
CircuitState circuitState = canvas.getCircuitState();
if (circuitState == null)
return;
ArrayList<Instance> ports = new ArrayList<Instance>(portObjects.size());
for (AppearancePort portObject : portObjects) {
ports.add(portObject.getPin());
}
hideCurrentPopup();
LayoutThumbnail layout = new LayoutThumbnail();
layout.setCircuit(circuitState, ports);
JViewport owner = canvasPane.getViewport();
Point ownerLoc = owner.getLocationOnScreen();
Dimension ownerDim = owner.getSize();
Dimension layoutDim = layout.getPreferredSize();
int x = ownerLoc.x + Math.max(0, ownerDim.width - layoutDim.width - 5);
int y = ownerLoc.y + Math.max(0, ownerDim.height - layoutDim.height - 5);
PopupFactory factory = PopupFactory.getSharedInstance();
Popup popup = factory.getPopup(canvasPane.getViewport(), layout, x, y);
popup.show();
curPopup = popup;
curPopupTime = System.currentTimeMillis();
}
示例5: showCRPopup
import javax.swing.PopupFactory; //導入方法依賴的package包/類
private void showCRPopup() {
carringtonPanel.setTime(time);
// get position for popup
int x = crPopupButton.getLocationOnScreen().x;
int y = crPopupButton.getLocationOnScreen().y + crPopupButton.getSize().height;
// create popup
PopupFactory factory = PopupFactory.getSharedInstance();
// correct position of popup when it does not fit into screen area
x = x + carringtonPanel.getSize().width > Toolkit.getDefaultToolkit().getScreenSize().width ? Toolkit.getDefaultToolkit().getScreenSize().width - carringtonPanel.getSize().width : x;
x = x < 0 ? 0 : x;
y = y + carringtonPanel.getSize().height > Toolkit.getDefaultToolkit().getScreenSize().height ? crPopupButton.getLocationOnScreen().y - carringtonPanel.getSize().height : y;
y = y < 0 ? 0 : y;
// show popup
crPopup = factory.getPopup(crPopupButton, carringtonPanel, x, y);
crPopup.show();
}
示例6: showPermanent
import javax.swing.PopupFactory; //導入方法依賴的package包/類
private void showPermanent()
{
if(permanentPopup != null)
{
if(permanentToolTip == toolTip)
return;
permanentPopup.hide();
permanentPopup = null;
permanentToolTip = null;
}
permanentToolTip = new AddonToolTip(toolTip);
permanentToolTip.setTemporary(false);
Point location = toolTip.getLocationOnScreen();
PopupFactory popupFactory = PopupFactory.getSharedInstance();
permanentPopup = popupFactory.getPopup(toolTip.getComponent(), permanentToolTip, location.x, location.y);
permanentPopup.show();
}
示例7: showPopup
import javax.swing.PopupFactory; //導入方法依賴的package包/類
private void showPopup(Set<AppearancePort> portObjects) {
dragStart = null;
CircuitState circuitState = canvas.getCircuitState();
if (circuitState == null)
return;
ArrayList<Instance> ports = new ArrayList<Instance>(portObjects.size());
for (AppearancePort portObject : portObjects) {
ports.add(portObject.getPin());
}
hideCurrentPopup();
LayoutThumbnail layout = new LayoutThumbnail();
layout.setCircuit(circuitState, ports);
JViewport owner = canvasPane.getViewport();
Point ownerLoc = owner.getLocationOnScreen();
Dimension ownerDim = owner.getSize();
Dimension layoutDim = layout.getPreferredSize();
int x = ownerLoc.x + Math.max(0, ownerDim.width - layoutDim.width - 5);
int y = ownerLoc.y
+ Math.max(0, ownerDim.height - layoutDim.height - 5);
PopupFactory factory = PopupFactory.getSharedInstance();
Popup popup = factory.getPopup(canvasPane.getViewport(), layout, x, y);
popup.show();
curPopup = popup;
curPopupTime = System.currentTimeMillis();
}
示例8: showPopup
import javax.swing.PopupFactory; //導入方法依賴的package包/類
private void showPopup(Set<AppearancePort> portObjects) {
dragStart = null;
CircuitState circuitState = canvas.getCircuitState();
if (circuitState == null) return;
ArrayList<Instance> ports = new ArrayList<Instance>(portObjects.size());
for (AppearancePort portObject : portObjects) {
ports.add(portObject.getPin());
}
hideCurrentPopup();
LayoutThumbnail layout = new LayoutThumbnail();
layout.setCircuit(circuitState, ports);
JViewport owner = canvasPane.getViewport();
Point ownerLoc = owner.getLocationOnScreen();
Dimension ownerDim = owner.getSize();
Dimension layoutDim = layout.getPreferredSize();
int x = ownerLoc.x + Math.max(0, ownerDim.width - layoutDim.width - 5);
int y = ownerLoc.y + Math.max(0, ownerDim.height - layoutDim.height - 5);
PopupFactory factory = PopupFactory.getSharedInstance();
Popup popup = factory.getPopup(canvasPane.getViewport(), layout, x, y);
popup.show();
curPopup = popup;
curPopupTime = System.currentTimeMillis();
}
示例9: getPopup
import javax.swing.PopupFactory; //導入方法依賴的package包/類
@Override
public Popup getPopup(JPopupMenu popup, int x, int y) {
PopupFactory popupFactory = layer.hackedPopupFactory;
if(popupFactory == null) {
return super.getPopup(popup, x, y);
}
return popupFactory.getPopup(popup.getInvoker(), popup, x, y);
}
示例10: show
import javax.swing.PopupFactory; //導入方法依賴的package包/類
/**
* Create and display the popup at the given bounds.
*
* @param popupBounds location and size of the popup.
* @param displayAboveCaret whether the popup is displayed above the anchor
* bounds or below them (it does not be right above them).
*/
private void show(Rectangle popupBounds, boolean displayAboveCaret) {
// Hide the original popup if exists
if (popup != null) {
popup.hide();
popup = null;
}
// Explicitly set the preferred size
Dimension origPrefSize = getPreferredSize();
Dimension newPrefSize = popupBounds.getSize();
JComponent contComp = getContentComponent();
if (contComp == null){
return;
}
contComp.setPreferredSize(newPrefSize);
showRetainedPreferredSize = newPrefSize.equals(origPrefSize);
PopupFactory factory = PopupFactory.getSharedInstance();
// Lightweight completion popups don't work well on the Mac - trying
// to click on its scrollbars etc. will cause the window to be hidden,
// so force a heavyweight parent by passing in owner==null. (#96717)
JTextComponent owner = layout.getEditorComponent();
if(owner != null && owner.getClientProperty("ForceHeavyweightCompletionPopup") != null) {
owner = null;
}
// #76648: Autocomplete box is too close to text
if(displayAboveCaret && Utilities.isMac()) {
popupBounds.y -= 10;
}
popup = factory.getPopup(owner, contComp, popupBounds.x, popupBounds.y);
popup.show();
this.popupBounds = popupBounds;
this.displayAboveCaret = displayAboveCaret;
}
示例11: show
import javax.swing.PopupFactory; //導入方法依賴的package包/類
/**
* Create and display the popup at the given bounds.
*
* @param popupBounds location and size of the popup.
* @param displayAboveCaret whether the popup is displayed above the anchor
* bounds or below them (it does not be right above them).
*/
private void show(Rectangle popupBounds, boolean displayAboveCaret) {
// Hide the original popup if exists
if (popup != null) {
popup.hide();
popup = null;
}
// Explicitly set the preferred size
Dimension origPrefSize = getPreferredSize();
Dimension newPrefSize = popupBounds.getSize();
JComponent contComp = getContentComponent();
if (contComp == null){
return;
}
contComp.setPreferredSize(newPrefSize);
showRetainedPreferredSize = newPrefSize.equals(origPrefSize);
PopupFactory factory = PopupFactory.getSharedInstance();
// Lightweight completion popups don't work well on the Mac - trying
// to click on its scrollbars etc. will cause the window to be hidden,
// so force a heavyweight parent by passing in owner==null. (#96717)
JTextComponent owner = getEditorComponent();
if(owner != null && owner.getClientProperty("ForceHeavyweightCompletionPopup") != null) { //NOI18N
owner = null;
}
// #76648: Autocomplete box is too close to text
if(displayAboveCaret && Utilities.isMac()) {
popupBounds.y -= 10;
}
popup = factory.getPopup(owner, contComp, popupBounds.x, popupBounds.y);
popup.show();
this.popupBounds = popupBounds;
this.displayAboveCaret = displayAboveCaret;
}
示例12: addStatistics
import javax.swing.PopupFactory; //導入方法依賴的package包/類
private void addStatistics(String kind, int count, int numRow,
final MouseEvent e) {
JLabel label = (JLabel)e.getComponent();
if(!label.getToolTipText().contains(kind)) {
// add the statistics to the tooltip
String toolTip = label.getToolTipText();
toolTip = toolTip.replaceAll("</?html>", "");
toolTip = kind + " = " + count + "<br>" + toolTip;
toolTip = "<html>" + toolTip + "</html>";
label.setToolTipText(toolTip);
}
if(bottomSplitPane.getDividerLocation()
/ bottomSplitPane.getSize().getWidth() < 0.90) {
// select the row in the statistics table
statisticsTabbedPane.setSelectedIndex(1);
oneRowStatisticsTable.setRowSelectionInterval(numRow, numRow);
oneRowStatisticsTable.scrollRectToVisible(oneRowStatisticsTable
.getCellRect(numRow, 0, true));
} else {
// display a tooltip
JToolTip tip = label.createToolTip();
tip.setTipText(kind + " = " + count);
PopupFactory popupFactory = PopupFactory.getSharedInstance();
final Popup tipWindow =
popupFactory.getPopup(label, tip, e.getX()
+ e.getComponent().getLocationOnScreen().x, e.getY()
+ e.getComponent().getLocationOnScreen().y);
tipWindow.show();
Date timeToRun = new Date(System.currentTimeMillis() + 2000);
Timer timer = new Timer("Annic statistics hide tooltip timer", true);
timer.schedule(new TimerTask() {
@Override
public void run() {
// hide the tooltip after 2 seconds
tipWindow.hide();
}
}, timeToRun);
}
}
示例13: run
import javax.swing.PopupFactory; //導入方法依賴的package包/類
private void run() {
JPanel panel = new JPanel();
int count = 0;
long diffTime, initialDiffTime = 0;
while (count < ITERATION_NUMBER) {
robot.delay(ROBOT_DELAY);
PopupFactory factory = PopupFactory.getSharedInstance();
Popup popup = factory.getPopup(panel, textArea, editorPane.getLocation().x + 20,
editorPane.getLocation().y + 20);
long startTime = System.currentTimeMillis();
popup.show();
long endTime = System.currentTimeMillis();
diffTime = endTime - startTime;
if (count > 1) {
if (diffTime * HANG_TIME_FACTOR < (endTime - startTime)) {
throw new RuntimeException("The test is near to be hang: iteration count = " + count
+ " initial time = " + initialDiffTime
+ " current time = " + diffTime);
}
} else {
initialDiffTime = diffTime;
}
count++;
robot.delay(ROBOT_DELAY);
popup.hide();
}
}
示例14: showCalPopup
import javax.swing.PopupFactory; //導入方法依賴的package包/類
/**
* Opens an new popup window where the user can select a date.
*/
private void showCalPopup() {
// set up the popup content
jhvCalendar.setDate(calendar.getTime());
// get position for popup
int x = textField.getLocationOnScreen().x;
int y = textField.getLocationOnScreen().y + textField.getSize().height;
// create popup
PopupFactory factory = PopupFactory.getSharedInstance();
calPopup = factory.getPopup(calPopupButton, jhvCalendar, x, y);
calPopup.show();
jhvCalendar.resizeSelectionPanel();
// correct position of popup when it does not fit into screen area
x = x + jhvCalendar.getSize().width > Toolkit.getDefaultToolkit().getScreenSize().width ? Toolkit.getDefaultToolkit().getScreenSize().width - jhvCalendar.getSize().width : x;
x = x < 0 ? 0 : x;
y = y + jhvCalendar.getSize().height > Toolkit.getDefaultToolkit().getScreenSize().height ? textField.getLocationOnScreen().y - jhvCalendar.getSize().height : y;
y = y < 0 ? 0 : y;
calPopup.hide();
// show popup
calPopup = factory.getPopup(calPopupButton, jhvCalendar, x, y);
calPopup.show();
}
示例15: showPopup
import javax.swing.PopupFactory; //導入方法依賴的package包/類
/**
* Called internally to popup the dates.
*/
private void showPopup() {
if (popup == null){
PopupFactory fac = new PopupFactory();
Point xy = getLocationOnScreen();
datePanel.setVisible(true);
popup = fac.getPopup(this, datePanel, (int) xy.getX(), (int) (xy.getY()+this.getHeight()));
popup.show();
}
}