项目:openjdk-jdk10
文件:PointerInfoCrashTest.java
private static void testMouseInfoPeer() {
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit instanceof ComponentFactory) {
ComponentFactory componentFactory = (ComponentFactory) toolkit;
MouseInfoPeer mouseInfoPeer = componentFactory.getMouseInfoPeer();
mouseInfoPeer.fillPointWithCoords(new Point());
Window win = new Window(null);
win.setSize(300,300);
win.setVisible(true);
mouseInfoPeer.isWindowUnderMouse(win);
win.dispose();
}
}
/**
* Instantiates a new jdialog as chart editor .
*
* @param dynForm the {@link DynForm}
* @param startArgIndex the start argument index
*/
public ChartEditorjdialog(DynForm dynForm,int startArgIndex) {
this.dynForm = dynForm;
this.startArgIndex = startArgIndex;
this.setModal(true);
this.setSize(600,450);
this.setIconImage(imageAgentGUI);
this.setTitle(Language.translate("Edit Chart",Language.EN));
// --- center dialog --------------------
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int top = (screenSize.height - this.getHeight()) / 2;
int left = (screenSize.width - this.getWidth()) / 2;
this.setLocation(left,top);
this.setContentPane(this.getContentPane());
this.getContentPane().add(getButtonPane(),BorderLayout.soUTH);
}
项目:jdk8u-jdk
文件:DitherTest.java
@Override
protected void processEvent(AWTEvent evt) {
int id = evt.getID();
if (id != KeyEvent.KEY_TYPED) {
super.processEvent(evt);
return;
}
KeyEvent kevt = (KeyEvent) evt;
char c = kevt.getKeyChar();
// Digits,backspace,and delete are okay
// Note that the minus sign is not allowed (neither is decimal)
if (Character.isDigit(c) || (c == '\b') || (c == '\u007f')) {
super.processEvent(evt);
return;
}
Toolkit.getDefaultToolkit().beep();
kevt.consume();
}
项目:WordnetLoom
文件:ShortCut.java
/**
* Ukonanie akcji zwiazanej ze skrotem
*/
public void doAction() {
// czy jest to skrót do przycisku
// jeśli tak to wywoływany jest click
if (button != null && button.isEnabled()) {
button.doClick();
// jest to skrót do komponentu
// a więc ustawienie focuu
} else if (component != null) {
if (pane != null) { // zmienie aktywnej zakladki
pane.setSelectedindex(tabIndex);
Toolkit.getDefaultToolkit().sync();
}
component.grabFocus(); // ustawienie focusu
} else if (action != null) {
action.doAction(null,-1);
}
}
项目:litiengine
文件:ImageProcessing.java
/**
* All pixels that have the specified color are rendered transparent.
*
* @param img
* the img
* @param color
* the color
* @return the image
*/
public static Image applyAlphaChannel(final Image img,final Color color) {
if (color == null || img == null) {
return img;
}
final ImageFilter filter = new RGBImageFilter() {
// the color we are looking for... Alpha bits are set to opaque
public final int markerRGB = color.getRGB() | 0xFF000000;
@Override
public final int filterRGB(final int x,final int y,final int rgb) {
if ((rgb | 0xFF000000) == this.markerRGB) {
// Mark the alpha bits as zero - transparent
return 0x00FFFFFF & rgb;
} else {
// nothing to do
return rgb;
}
}
};
final ImageProducer ip = new FilteredImageSource(img.getSource(),filter);
return Toolkit.getDefaultToolkit().createImage(ip);
}
public void show(Point location) {
Rectangle screenBounds = null;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
for (GraphicsDevice device : gds) {
GraphicsConfiguration gc = device.getDefaultConfiguration();
screenBounds = gc.getBounds();
if (screenBounds.contains(location)) {
break;
}
}
// showing the popup tooltip
cp = new TooltipContentPanel(master.getTextComponent());
Window w = SwingUtilities.windowForComponent(master.getTextComponent());
contentwindow = new JWindow(w);
contentwindow.add(cp);
contentwindow.pack();
Dimension dim = contentwindow.getSize();
if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
}
if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
}
contentwindow.setSize(dim);
contentwindow.setLocation(location.x,location.y - 1); // slight visual adjustment
contentwindow.setVisible(true);
Toolkit.getDefaultToolkit().addAWTEventListener(this,AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
w.addWindowFocusListener(this);
contentwindow.addWindowFocusListener(this);
}
项目:incubator-netbeans
文件:HintsUI.java
private void removePopup() {
Toolkit.getDefaultToolkit().removeAWTEventListener(this);
if (listPopup != null) {
closeSubList();
if( tooltipPopup != null )
tooltipPopup.hide();
tooltipPopup = null;
listPopup.hide();
if (hintListComponent != null) {
hintListComponent.getView().removeMouseListener(this);
hintListComponent.getView().removeMouseMotionListener(this);
}
if (errorTooltip != null) {
errorTooltip.removeMouseListener(this);
}
hintListComponent = null;
errorTooltip = null;
listPopup = null;
if (hintIcon != null)
hintIcon.setToolTipText(NbBundle.getMessage(HintsUI.class,"HINT_Bulb")); // NOI18N
}
}
项目:blitzcrank_screenshoot
文件:Blitzcrank.java
/**
* @param args the command line arguments
* @throws java.awt.AWTException
* @throws java.lang.InterruptedException
* @throws java.io.IOException
*/
public static void main(String[] args) throws AWTException,InterruptedException,IOException {
String stringfyCurrent = String.valueOf(System.currentTimeMillis());
String path = "{path}";
String name = "capture" + stringfyCurrent;
String type = ".jpg";
//--
File file = new File(path + name + type);
BufferedImage imagexd = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(imagexd,type.replace(".",""),baos);
byte[] bytes = baos.toByteArray();
OutputStream out = new FileOutputStream(file);
out.write(bytes);
}
项目:jNotifyOSD
文件:ServerOSD.java
private Dimension getDeviceDimension() {
Dimension deviceDimension = null;
try {
Toolkit tool = Toolkit.getDefaultToolkit();
deviceDimension = tool.getScreenSize();
} catch (AWTError e) {
System.out.println(CLASS_NAME+": ERROR! "+ e.getMessage());
e.printstacktrace();
}
return deviceDimension;
}
项目:incubator-netbeans
文件:FastTypeProvider.java
@Override
public void open() {
boolean success = false;
try {
final FileObject fo = getFileObject();
if (fo != null) {
final DataObject d = DataObject.find(fo);
final EditCookie cake = d.getCookie(EditCookie.class);
if (cake != null) {
cake.edit();
success = true;
}
}
} catch (DataObjectNotFoundException ex) {
Exceptions.printstacktrace(ex);
}
if (!success) {
Toolkit.getDefaultToolkit().beep();
}
}
项目:incubator-netbeans
文件:KeyboardDnd.java
private void stop( boolean commitChanges ) {
Toolkit.getDefaultToolkit().removeAWTEventListener( this );
TopComponent.getRegistry().removePropertychangelistener( this );
try {
if( commitChanges ) {
TopComponentDroppable droppable = targets.get( currentIndex );
Point dropLocation = currentSide.getDropLocation( droppable );
if( droppable.canDrop( draggable,dropLocation ) ) {
dndManager.performDrop( dndManager.getController(),droppable,draggable,dropLocation );
}
}
} finally {
dndManager.dragFinished();
dndManager.dragFinishedEx();
if( currentDnd == this )
currentDnd = null;
}
}
项目:jdk8u-jdk
文件:MaximizedToMaximized.java
public static void main(String[] args) throws Exception {
Frame frame = new Frame();
final Toolkit toolkit = Toolkit.getDefaultToolkit();
final GraphicsEnvironment graphicsEnvironment =
GraphicsEnvironment.getLocalGraphicsEnvironment();
final GraphicsDevice graphicsDevice =
graphicsEnvironment.getDefaultScreenDevice();
final Dimension screenSize = toolkit.getScreenSize();
final Insets screenInsets = toolkit.getScreenInsets(
graphicsDevice.getDefaultConfiguration());
final Rectangle availableScreenBounds = new Rectangle(screenSize);
availableScreenBounds.x += screenInsets.left;
availableScreenBounds.y += screenInsets.top;
availableScreenBounds.width -= (screenInsets.left + screenInsets.right);
availableScreenBounds.height -= (screenInsets.top + screenInsets.bottom);
frame.setBounds(availableScreenBounds.x,availableScreenBounds.y,availableScreenBounds.width,availableScreenBounds.height);
frame.setVisible(true);
Rectangle frameBounds = frame.getBounds();
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
((SunToolkit) toolkit).realSync();
Rectangle maximizedFrameBounds = frame.getBounds();
if (maximizedFrameBounds.width < frameBounds.width
|| maximizedFrameBounds.height < frameBounds.height) {
throw new RuntimeException("Maximized frame is smaller than non maximized");
}
}
项目:incubator-netbeans
文件:ModeResizer.java
private void stop( boolean commitChanges ) {
Toolkit.getDefaultToolkit().removeAWTEventListener( this );
TopComponent.getRegistry().removePropertychangelistener( this );
if( null != frame ) {
boolean glassVisible = oldGlass.isVisible();
frame.setGlasspane( oldGlass);
oldGlass.setVisible( glassVisible );
}
if( !commitChanges ) {
if( null != parentSplitter ) {
parentSplitter.finishDraggingTo( originalParentLocation );
}
splitter.finishDraggingTo( originalLocation );
}
if( currentResizer == this )
currentResizer = null;
}
public static void main(String[] args) {
UIManager.put("swing.boldMetal",Boolean.FALSE);
jdialog.setDefaultLookAndFeelDecorated(true);
JFrame.setDefaultLookAndFeelDecorated(true);
Toolkit.getDefaultToolkit().setDynamicLayout(true);
System.setProperty("sun.awt.noerasebackground","true");
try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
System.out.println(
"Metal Look & Feel not supported on this platform. \n"
+ "Program Terminated");
System.exit(0);
}
JFrame frame = new MetalworksFrame();
frame.setVisible(true);
}
项目:Equella
文件:JNumberTextField.java
@Override
public void insertString(int offset,String s,AttributeSet attributeSet) throws BadLocationException
{
try
{
int value = Integer.parseInt(s);
if( value < 0 )
{
Toolkit.getDefaultToolkit().beep();
return;
}
}
catch( NumberFormatException ex )
{
Toolkit.getDefaultToolkit().beep();
return;
}
super.insertString(offset,s,attributeSet);
if( Integer.parseInt(getText(0,getLength())) > maxnumber )
{
Toolkit.getDefaultToolkit().beep();
super.remove(offset,s.length());
}
}
/** Test that iconResource really works.
* @see "#26887"
*/
public void testIcons() throws Exception {
Image i = Toolkit.getDefaultToolkit().getimage(SystemActionTest.class.getResource("data/someicon.gif"));
int h = imageHash("Control icon",i,16,16);
SystemAction a = SystemAction.get(SystemAction1.class);
CharSequence log = Log.enable("org.openide.util",Level.WARNING);
assertEquals("Absolute slash-initial iconResource works (though deprecated)",h,imageHash("icon1",icon2Image(a.getIcon()),16));
assertTrue(log.toString(),log.toString().contains("Initial slashes in Utilities.loadImage deprecated"));
a = SystemAction.get(SystemAction2.class);
assertEquals("Absolute no-slash-initial iconResource works",imageHash("icon2",16));
a = SystemAction.get(SystemAction3.class);
assertEquals("Relative iconResource works (though deprecated)",imageHash("icon3",log.toString().contains("Deprecated relative path"));
a = SystemAction.get(SystemAction4.class);
a.getIcon();
assertTrue(log.toString(),log.toString().contains("No such icon"));
}
项目:openjdk-jdk10
文件:CSS.java
ImageIcon getimage(URL base) {
if (!loadedImage) {
synchronized(this) {
if (!loadedImage) {
URL url = CSS.getURL(base,svalue);
loadedImage = true;
if (url != null) {
image = new ImageIcon();
Image tmpImg = Toolkit.getDefaultToolkit().createImage(url);
if (tmpImg != null) {
image.setimage(tmpImg);
}
}
}
}
}
return image;
}
项目:jdk8u-jdk
文件:WPageDialog.java
@Override
@SuppressWarnings("deprecation")
public void addNotify() {
synchronized(getTreeLock()) {
Container parent = getParent();
if (parent != null && parent.getPeer() == null) {
parent.addNotify();
}
if (getPeer() == null) {
ComponentPeer peer = ((WToolkit)Toolkit.getDefaultToolkit()).
createWPageDialog(this);
setPeer(peer);
}
super.addNotify();
}
}
项目:jdk8u-jdk
文件:bug7189299.java
public static void main(String[] args) throws Exception {
final SunToolkit toolkit = ((SunToolkit) Toolkit.getDefaultToolkit());
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
setup();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
try {
verifySingleDefaultButtonModelListener();
dotest();
verifySingleDefaultButtonModelListener();
} finally {
frame.dispose();
}
}
});
}
项目:LP_Proyecto
文件:Principal.java
private void jl_Imagen_ContactsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FirsT:event_jl_Imagen_ContactsMouseClicked
// Todo add your handling code here:
jl_Imagen_Contacts.setText("");
JFileChooser fc = new JFileChooser();
FileFilter filtro = new FileNameExtensionFilter("Imagenes","png","jpg","jpeg","gif");
fc.setFileFilter(filtro);
File Archivo;
int op = fc.showOpenDialog(this);
if (op == JFileChooser.APPROVE_OPTION) {
Archivo = fc.getSelectedFile();
Rutaimagen = Archivo.getPath();
System.out.println(Archivo.getPath());
Image Img = Toolkit.getDefaultToolkit().createImage(Archivo.getPath()).getScaledInstance(180,229,0);
this.jl_Imagen_Contacts.setIcon(new ImageIcon(Img));
}
}
protected static Image readImage24(FileInputStream fs,BitmapHeader bh) throws IOException {
Image image;
if (bh.iSizeimage == 0) {
bh.iSizeimage = ((((bh.iWidth * bh.iBitcount) + 31) & ~31) >> 3);
bh.iSizeimage *= bh.iHeight;
}
final int npad = (bh.iSizeimage / bh.iHeight) - bh.iWidth * 3;
final int ndata[] = new int[bh.iHeight * bh.iWidth];
final byte brgb[] = new byte[(bh.iWidth + npad) * 3 * bh.iHeight];
fs.read(brgb,(bh.iWidth + npad) * 3 * bh.iHeight);
int nindex = 0;
for (int j = 0; j < bh.iHeight; j++) {
for (int i = 0; i < bh.iWidth; i++) {
ndata[bh.iWidth * (bh.iHeight - j - 1) + i] = constructInt3(brgb,nindex);
nindex += 3;
}
nindex += npad;
}
image = Toolkit.getDefaultToolkit()
.createImage(new MemoryImageSource(bh.iWidth,bh.iHeight,ndata,bh.iWidth));
fs.close();
return (image);
}
项目:geomapapp
文件:Cursors.java
public static Cursor getCursor( int which ) {
Cursor c = (Cursor) cursorCache.get(new Integer(which));
if (c != null) return c;
try {
ClassLoader loader = org.geomapapp.util.Icons.class.getClassLoader();
String path = "org/geomapapp/resources/icons/" +names[which];
java.net.URL url = loader.getResource(path);
BufferedImage im = ImageIO.read(url);
String name = names[which].substring(0,names[which].lastIndexOf("."));
System.out.println(im.getWidth() + "\t" + im.getHeight());
c = Toolkit.getDefaultToolkit().createCustomCursor(im,new Point(hotSpot[which][0],hotSpot[which][1]),name);
cursorCache.put(new Integer(which),c);
return c;
} catch(Exception ex) {
return Cursor.getDefaultCursor();
}
}
ExecutableInputMethodManager() {
// set up host adapter locator
Toolkit toolkit = Toolkit.getDefaultToolkit();
try {
if (toolkit instanceof InputMethodSupport) {
InputMethodDescriptor hostAdapterDescriptor =
((InputMethodSupport)toolkit)
.getInputMethodAdapterDescriptor();
if (hostAdapterDescriptor != null) {
hostAdapterLocator = new InputMethodLocator(hostAdapterDescriptor,null,null);
}
}
} catch (AWTException e) {
// if we can't get a descriptor,we'll just have to do without native input methods
}
javaInputMethodLocatorList = new Vector<InputMethodLocator>();
initializeInputMethodLocatorList();
}
项目:powertext
文件:RtfGenerator.java
/**
* Resets this generator. All document @R_432_4045@ion and content is
* cleared.
*/
public void reset() {
fontList.clear();
colorList.clear();
document.setLength(0);
lastWasControlWord = false;
lastFontIndex = 0;
lastFGIndex = 0;
lastBold = false;
lastItalic = false;
lastFontSize = DEFAULT_FONT_SIZE;
screenRes = Toolkit.getDefaultToolkit().getScreenResolution();
}
项目:NotifyTools
文件:SimpleBeanInfo.java
public Image loadImage(String resourceName) {
if (null == resourceName) {
return null;
}
URL file = getClass().getResource(resourceName);
if (file != null) {
return Toolkit.getDefaultToolkit().createImage(file);
}
return null;
}
项目:jaer
文件:EyeTarget.java
public void dispose() {
disposed = true;
Toolkit.getDefaultToolkit().removeAWTEventListener(this);
SwingUtilities.invokelater(new Runnable() {
@Override public void run() {
paintTransparentFrame();
}
});
}
项目:freecol
文件:DropListener.java
/**
* Gets called when the mouse was released on a Swing component
* that has this object as a MouseListener.
*
* @param e The event that holds the @R_432_4045@ion about the mouse click.
*/
@Override
public void mouseReleased(MouseEvent e) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable clipData = clipboard.getContents(clipboard);
if (clipData != null) {
if (clipData.isDataFlavorSupported(DefaultTransferHandler.flavor)) {
JComponent comp = (JComponent)e.getSource();
TransferHandler handler = comp.getTransferHandler();
handler.importData(comp,clipData);
}
}
}
项目:Hydrograph
文件:TransformDialog.java
/**
* Return the initial size of the dialog.
*/
@Override
protected Point getinitialSize() {
container.getShell().layout(true,true);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
final Point newSize = container.getShell().computeSize(screenSize.width,screenSize.height,true);
container.getShell().setSize(newSize);
return newSize;
}
项目:litiengine
文件:KeyBoard.java
@Override
public String getText(final KeyEvent e) {
if (this.ispressed(KeyEvent.VK_SHIFT) || Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK)) {
return this.getShiftText(e);
} else if (this.ispressed(KeyEvent.VK_ALT_GRAPH)) {
return this.getAltText(e);
} else {
return this.getnormalText(e);
}
}
项目:jdk8u-jdk
文件:DragSource.java
private static Cursor load(String name) {
if (GraphicsEnvironment.isHeadless()) {
return null;
}
try {
return (Cursor)Toolkit.getDefaultToolkit().getDesktopProperty(name);
} catch (Exception e) {
e.printstacktrace();
throw new RuntimeException("Failed to load system cursor: " + name + " : " + e.getMessage());
}
}
public void insertString(FilterBypass fb,int offs,String str,AttributeSet a) throws BadLocationException {
if (DEBUG) {
System.out.println("in DocumentSizefilter's insertString method");
}
// This rejects the entire insertion if it would make
// the contents too long. Another option would be
// to truncate the inserted string so the contents
// would be exactly maxCharacters in length.
if ((fb.getDocument().getLength() + str.length()) <= maxCharacters)
super.insertString(fb,offs,str,a);
else
Toolkit.getDefaultToolkit().beep();
}
项目:rekit-game
文件:GameView.java
/**
* Center {@link Frame} relative to monitor.
*
* @param frame
* the frame
*/
private void center(Frame frame) {
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((dimension.getWidth() - frame.getWidth()) / 2);
int y = (int) ((dimension.getHeight() - frame.getHeight()) / 2);
frame.setLocation(x,y);
}
项目:incubator-netbeans
文件:SimpleEngine.java
public Action getAction (final String action,String containerCtx,final Map context) {
return new AbstractAction () {
public void actionPerformed (ActionEvent ae) {
SimpleInvoker invoker = interp.getInvoker(action);
System.err.println("Invoker is " + invoker);
System.err.println("Invoking " + action + " on " + context);
if (invoker != null) {
invoker.invoke(context);
} else {
Toolkit.getDefaultToolkit().beep();
}
}
};
}
项目:myfaces-trinidad
文件:ImageUtils.java
/**
* Return true if the Image has been successfully loaded.
* <p>
* @param image Image to check for sucessful loading
* <p>
* @return True if the image has been sucessfully loaded.
*/
static public boolean isImageLoaded(
Image image
)
{
Toolkit tk = Toolkit.getDefaultToolkit();
int status = tk.checkImage(image,-1,null);
return ((status & (ImageObserver.ALLBITS |ImageObserver.FRAMEBITS)) != 0);
}
项目:sentimental-analyzer
文件:Analyzer.java
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setIconImage(Toolkit.getDefaultToolkit().getimage("E:\\图片\\u=1829416607,2140971604&fm=21&gp=0.jpg"));
frame.setType(Type.UTILITY);
frame.setTitle("网络电影评论情感倾向性分类");
frame.setBounds(100,100,639,412);
frame.setDefaultCloSEOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
JMenu mnNewMenu = new JMenu("数据集自动标注");
menuBar.add(mnNewMenu);
JMenuItem mntmNewMenuItem_2 = new JMenuItem("自动标注");
mnNewMenu.add(mntmNewMenuItem_2);
JMenu mnNewMenu_1 = new JMenu("情感分析");
menuBar.add(mnNewMenu_1);
JMenuItem mntmNewMenuItem_3 = new JMenuItem("朴素贝叶斯算法");
mnNewMenu_1.add(mntmNewMenuItem_3);
JMenuItem mntmNewMenuItem_4 = new JMenuItem("N-Gram算法");
mnNewMenu_1.add(mntmNewMenuItem_4);
JMenuItem mntmNewMenuItem_5 = new JMenuItem("支持向量机");
mnNewMenu_1.add(mntmNewMenuItem_5);
JMenu mnNewMenu_2 = new JMenu("关于");
menuBar.add(mnNewMenu_2);
JMenuItem mntmNewMenuItem = new JMenuItem("作者");
mnNewMenu_2.add(mntmNewMenuItem);
JMenuItem mntmNewMenuItem_1 = new JMenuItem("New menu item");
mnNewMenu_2.add(mntmNewMenuItem_1);
}
项目:incubator-netbeans
文件:Utils.java
public static Graphics2D prepareGraphics(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
Map rhints = (Map)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
if( rhints == null && Boolean.getBoolean("swing.aatext") ) { //NOI18N
g2.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
} else if( rhints != null ) {
g2.addRenderingHints( rhints );
}
return g2;
}
项目:org.alloytools.alloy
文件:OurUtil.java
/**
* Construct a new JMenuItem then add it to an existing JMenu.
*
* @param parent - the JMenu to add this JMenuItem into (or null if you
* don't want to add it to any JMenu yet)
* @param label - the text to show on the menu
* @param attrs - a list of attributes to apply onto the new JMenuItem
* <p>
* If one positive number a is supplied,we call setMnemonic(a)
* <p>
* If two positive numbers a and b are supplied,and a!=VK_ALT,* and a!=VK_SHIFT,we call setMnemoic(a) and setAccelerator(b)
* <p>
* If two positive numbers a and b are supplied,and a==VK_ALT or
* a==VK_SHIFT,we call setAccelerator(a | b)
* <p>
* If an ActionListener is supplied,we call addActionListener(x)
* <p>
* If an Boolean x is supplied,we call setEnabled(x)
* <p>
* If an Icon x is supplied,we call setIcon(x)
*/
public static JMenuItem menuItem(JMenu parent,String label,Object... attrs) {
JMenuItem m = new JMenuItem(label,null);
int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
boolean hasMnemonic = false;
for (Object x : attrs) {
if (x instanceof Character || x instanceof Integer) {
int k = (x instanceof Character) ? ((int) ((Character) x)) : ((Integer) x).intValue();
if (k < 0)
continue;
if (k == KeyEvent.VK_ALT) {
hasMnemonic = true;
accelMask = accelMask | InputEvent.ALT_MASK;
continue;
}
if (k == KeyEvent.VK_SHIFT) {
hasMnemonic = true;
accelMask = accelMask | InputEvent.SHIFT_MASK;
continue;
}
if (!hasMnemonic) {
m.setMnemonic(k);
hasMnemonic = true;
} else
m.setAccelerator(Keystroke.getKeystroke(k,accelMask));
}
if (x instanceof ActionListener)
m.addActionListener((ActionListener) x);
if (x instanceof Icon)
m.setIcon((Icon) x);
if (x instanceof Boolean)
m.setEnabled((Boolean) x);
}
if (parent != null)
parent.add(m);
return m;
}
项目:jaer
文件:SimpleIPotSliderTextControl.java
private void valueTextFieldActionPerformed(final java.awt.event.ActionEvent evt) {// GEN-FirsT:event_valueTextFieldActionPerformed
// new pots current value entered
// System.out.println("value field action performed");
try {
startEdit();
pot.setBitValue(Integer.parseInt(valueTextField.getText()));
endEdit();
}
catch (final NumberFormatException e) {
Toolkit.getDefaultToolkit().beep();
valueTextField.selectAll();
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。