use of javax.swing.JToolTip in project UniversalMediaServer by UniversalMediaServer.
the class CustomJLabel method createToolTip.
public JToolTip createToolTip() {
JToolTip tip = new HyperLinkToolTip();
tip.setComponent(this);
return tip;
}
use of javax.swing.JToolTip in project UniversalMediaServer by UniversalMediaServer.
the class CustomJComboBox method createToolTip.
public JToolTip createToolTip() {
JToolTip tip = new HyperLinkToolTip();
tip.setComponent(this);
return tip;
}
use of javax.swing.JToolTip in project UniversalMediaServer by UniversalMediaServer.
the class CustomJSpinner method createToolTip.
public JToolTip createToolTip() {
JToolTip tip = new HyperLinkToolTip();
tip.setComponent(this);
return tip;
}
use of javax.swing.JToolTip in project jsql-injection by ron190.
the class TabManagers method buildI18nTab.
private void buildI18nTab(String keyLabel, String keyTooltip, Icon icon, Component manager) {
final JToolTipI18n[] tooltip = new JToolTipI18n[] { new JToolTipI18n(I18n.valueByKey(keyTooltip)) };
JLabel labelTab = new JLabel(I18n.valueByKey(keyLabel), icon, SwingConstants.CENTER) {
@Override
public JToolTip createToolTip() {
JToolTip tipI18n = new JToolTipI18n(I18n.valueByKey(keyTooltip));
tooltip[0] = (JToolTipI18n) tipI18n;
return tipI18n;
}
};
labelTab.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
TabManagers.this.setSelectedComponent(manager);
super.mousePressed(e);
}
});
this.addTab(I18n.valueByKey(keyLabel), icon, manager);
this.setTabComponentAt(this.indexOfTab(I18n.valueByKey(keyLabel)), labelTab);
I18nView.addComponentForKey(keyLabel, labelTab);
I18nView.addComponentForKey(keyTooltip, tooltip[0]);
labelTab.setToolTipText(I18n.valueByKey(keyTooltip));
labelTab.addMouseListener(new TabSelectionMouseHandler());
}
use of javax.swing.JToolTip in project triplea by triplea-game.
the class TripleAFrame method getArrowKeyListener.
private KeyListener getArrowKeyListener() {
return new KeyListener() {
@Override
public void keyPressed(final KeyEvent e) {
isCtrlPressed = e.isControlDown();
// scroll map according to wasd/arrowkeys
final int diffPixel = computeScrollSpeed();
final int x = mapPanel.getXOffset();
final int y = mapPanel.getYOffset();
final int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_RIGHT) {
getMapPanel().setTopLeft(x + diffPixel, y);
} else if (keyCode == KeyEvent.VK_LEFT) {
getMapPanel().setTopLeft(x - diffPixel, y);
} else if (keyCode == KeyEvent.VK_DOWN) {
getMapPanel().setTopLeft(x, y + diffPixel);
} else if (keyCode == KeyEvent.VK_UP) {
getMapPanel().setTopLeft(x, y - diffPixel);
}
// I for info
if (keyCode == KeyEvent.VK_I || keyCode == KeyEvent.VK_V) {
String unitInfo = "";
if (unitsBeingMousedOver != null && !unitsBeingMousedOver.isEmpty()) {
final Unit unit = unitsBeingMousedOver.get(0);
final UnitAttachment ua = UnitAttachment.get(unit.getType());
if (ua != null) {
unitInfo = "<b>Unit:</b><br>" + unit.getType().getName() + ": " + ua.toStringShortAndOnlyImportantDifferences(unit.getOwner(), true, false);
}
}
String terrInfo = "";
if (territoryLastEntered != null) {
final TerritoryAttachment ta = TerritoryAttachment.get(territoryLastEntered);
if (ta != null) {
terrInfo = "<b>Territory:</b><br>" + ta.toStringForInfo(true, true) + "<br>";
} else {
terrInfo = "<b>Territory:</b><br>" + territoryLastEntered.getName() + "<br>Water Territory";
}
}
String tipText = unitInfo;
if (unitInfo.length() > 0 && terrInfo.length() > 0) {
tipText = tipText + "<br><br><br><br><br>";
}
tipText = tipText + terrInfo;
if (tipText.length() > 0) {
final Point currentPoint = MouseInfo.getPointerInfo().getLocation();
final PopupFactory popupFactory = PopupFactory.getSharedInstance();
final JToolTip info = new JToolTip();
info.setTipText("<html>" + tipText + "</html>");
final Popup popup = popupFactory.getPopup(mapPanel, info, currentPoint.x, currentPoint.y);
popup.show();
new Thread(() -> {
Interruptibles.sleep(5000);
popup.hide();
}, "popup waiter").start();
}
}
}
@Override
public void keyTyped(final KeyEvent e) {
}
@Override
public void keyReleased(final KeyEvent e) {
isCtrlPressed = e.isControlDown();
}
};
}
Aggregations