当前位置: 首页>>代码示例>>Java>>正文


Java Toolkit类代码示例

本文整理汇总了Java中java.awt.Toolkit的典型用法代码示例。如果您正苦于以下问题:Java Toolkit类的具体用法?Java Toolkit怎么用?Java Toolkit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Toolkit类属于java.awt包,在下文中一共展示了Toolkit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMouseInfoPeer

import java.awt.Toolkit; //导入依赖的package包/类
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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:PointerInfoCrashTest.java

示例2: main

import java.awt.Toolkit; //导入依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:Metalworks.java

示例3: ChartEditorJDialog

import java.awt.Toolkit; //导入依赖的package包/类
/**
 * 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);

}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:28,代码来源:ChartEditorJDialog.java

示例4: processEvent

import java.awt.Toolkit; //导入依赖的package包/类
@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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:DitherTest.java

示例5: doAction

import java.awt.Toolkit; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:22,代码来源:ShortCut.java

示例6: applyAlphaChannel

import java.awt.Toolkit; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:35,代码来源:ImageProcessing.java

示例7: show

import java.awt.Toolkit; //导入依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:TooltipWindow.java

示例8: removePopup

import java.awt.Toolkit; //导入依赖的package包/类
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
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:HintsUI.java

示例9: main

import java.awt.Toolkit; //导入依赖的package包/类
/**
 * @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);
    
}
 
开发者ID:theboshy,项目名称:blitzcrank_screenshoot,代码行数:25,代码来源:Blitzcrank.java

示例10: getDeviceDimension

import java.awt.Toolkit; //导入依赖的package包/类
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;
}
 
开发者ID:adbenitez,项目名称:jNotifyOSD,代码行数:12,代码来源:ServerOSD.java

示例11: open

import java.awt.Toolkit; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:FastTypeProvider.java

示例12: stop

import java.awt.Toolkit; //导入依赖的package包/类
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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:KeyboardDnd.java

示例13: main

import java.awt.Toolkit; //导入依赖的package包/类
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");
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:35,代码来源:MaximizedToMaximized.java

示例14: stop

import java.awt.Toolkit; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ModeResizer.java

示例15: insertString

import java.awt.Toolkit; //导入依赖的package包/类
@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());
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:27,代码来源:JNumberTextField.java


注:本文中的java.awt.Toolkit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。