本文整理汇总了Java中com.sun.awt.AWTUtilities类的典型用法代码示例。如果您正苦于以下问题:Java AWTUtilities类的具体用法?Java AWTUtilities怎么用?Java AWTUtilities使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AWTUtilities类属于com.sun.awt包,在下文中一共展示了AWTUtilities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGC
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
private static GraphicsConfiguration getGC() {
GraphicsConfiguration transparencyCapableGC =
GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDefaultConfiguration();
if (!AWTUtilities.isTranslucencyCapable(transparencyCapableGC)) {
transparencyCapableGC = null;
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = env.getScreenDevices();
for (int i = 0; i < devices.length && transparencyCapableGC == null; i++) {
GraphicsConfiguration[] configs = devices[i].getConfigurations();
for (int j = 0; j < configs.length && transparencyCapableGC == null; j++) {
if (AWTUtilities.isTranslucencyCapable(configs[j])) {
transparencyCapableGC = configs[j];
}
}
}
}
return transparencyCapableGC;
}
示例2: init
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
/**
* 初始化
*/
public void init()
{
MyTools.setWindowsMiddleShow(this,width,height);//设置窗体居中显示
new MyLabel(lbl登录, "../img/button/button_login", "png").addEvent();
new MyLabel(lbl最小化, "../img/button/login_minsize", "png").addEvent();
new MyLabel(lbl退出, "../img/button/login_exit", "png").addEvent();
new MyLabel(lbl多账号, "../img/button/login_duozhanghao", "png").addEvent();
new MyLabel(lbl设置, "../img/button/login_setting", "png").addEvent();
new MyLabel(lbl注册账号).addEvent();
initUserStatus();
AWTUtilities.setWindowOpaque(this, false);//设置窗体完全透明
addEvent();
this.setVisible(true);
main=new Main();
}
示例3: createAndShowGUI
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
private static void createAndShowGUI() {
System.setProperty("sun.java2d.noddraw","true");
final JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setMinimumSize(new Dimension(400,400));
frame.setMaximumSize(new Dimension(400,400));
frame.setLocationRelativeTo(null);
frame.setUndecorated(true);
frame.setAlwaysOnTop(true);
AWTUtilities.setWindowOpaque(frame,false);
frame.setLayout(new BoxLayout(frame.getContentPane(),BoxLayout.Y_AXIS));
JButton button = new JButton("test");
button.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
panel.setMaximumSize(new Dimension(Integer.MAX_VALUE,100));
panel.setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER));
frame.add(panel);
frame.pack();
}
});
frame.add(button);
frame.setVisible(true);
frame.pack();
}
示例4: initGUI
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
protected void initGUI()
{
// set dialog full transparent
setUndecorated(true);
AWTUtilities.setWindowOpaque(this, false);
this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
// init gui
JPanel contentPane = new JPanel();
contentPane.setLayout(new BorderLayout(0, 0));
contentPane.setOpaque(false);
setContentPane(contentPane);
// others setup
this.setFocusable(false);
this.setFocusableWindowState(false);
// this.setAlwaysOnTop(true);
this.setVisible(false);
}
示例5: actionPerformed
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e)
{
// fade out
for(float i=1.0f; i>=0;i-=0.05f)
try{
AWTUtilities.setWindowOpacity(this, i);
Thread.sleep(50);
}
catch (Exception e2){
}
// dispose it
if(timer != null)
timer.stop();
this.dispose();
}
示例6: main
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
public static void main(String[] args) {
JFrame frame=new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setUndecorated(true);
frame.setBounds(500,500,500,375);
AWTUtilities.setWindowOpaque(frame, false);
//设置窗口完全透明
JPanel pane = new JPanel(){
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.LIGHT_GRAY);
g.fill3DRect(10, 10, 100, 100, true);
}
};
frame.setContentPane(pane);
frame.setVisible(true);
}
示例7: mouseReleased
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
public void mouseReleased () {
if (isDrawRect) {
servoList.add (mouseX, mouseY);
isDrawRect = false;
}
servoList.removeOut ();
servoList.checkOut ();
servoList.checkClash ();
servoList.removeOut ();//////////////
servoList.fixInRange ();
servoList.CheckIdClash ();
timeLine.isBeginMove = false;
isMoveWindow = false;
AWTUtilities.setWindowOpacity(frame, 1.0f);
// for (int i=0; i < servoList.list.size (); i++) {
// Servo servo = servoList.list.get(i);
// println ("++"+servo.getPx1()+" "+servo.getPx2()+" "+servo.getPy1()+" "+ servo.getPy2());
// }
if (isMoveFace)
isMoveFace = false;
}
示例8: ScreenCapture
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
public ScreenCapture(Consumer<BufferedImage> onGet) {
this.onGet = onGet;
try {
robot = new Robot();
setUndecorated(true);
setExtendedState(JFrame.MAXIMIZED_BOTH);
AWTUtilities.setWindowOpaque(this, false);
addMouseMotionListener(this);
setAlwaysOnTop(true);
new Timer(10, event -> onGlobalMouseMove()).start();
hideCursor();
rawImage = robot.createScreenCapture(new Rectangle(0, 0, screenSize.width, screenSize.height));
addMouseListener(this);
} catch (AWTException e) {
e.printStackTrace();
}
}
示例9: setupDragMode
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
private void setupDragMode(JComponent f) {
JDesktopPane p = getDesktopPane(f);
Container parent = f.getParent();
dragMode = DEFAULT_DRAG_MODE;
if (p != null) {
String mode = (String)p.getClientProperty("JDesktopPane.dragMode");
Window window = SwingUtilities.getWindowAncestor(f);
if (window != null && !AWTUtilities.isWindowOpaque(window)) {
dragMode = DEFAULT_DRAG_MODE;
} else if (mode != null && mode.equals("outline")) {
dragMode = OUTLINE_DRAG_MODE;
} else if (mode != null && mode.equals("faster")
&& f instanceof JInternalFrame
&& ((JInternalFrame)f).isOpaque() &&
(parent == null || parent.isOpaque())) {
dragMode = FASTER_DRAG_MODE;
} else {
if (p.getDragMode() == JDesktopPane.OUTLINE_DRAG_MODE ) {
dragMode = OUTLINE_DRAG_MODE;
} else if ( p.getDragMode() == JDesktopPane.LIVE_DRAG_MODE
&& f instanceof JInternalFrame
&& ((JInternalFrame)f).isOpaque()) {
dragMode = FASTER_DRAG_MODE;
} else {
dragMode = DEFAULT_DRAG_MODE;
}
}
}
}
示例10: main
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
public static void main(String[] args) {
JDialog w = new JDialog();
w.setPreferredSize(new Dimension(100,200));
w.setUndecorated(true);
// w.setFocusableWindowState(false);
w.add(new JTextField("Test"));
// w.add(new JComponent() {
// /**
// * This will draw a black cross on screen.
// */
// protected void paintComponent(Graphics g) {
// g.setColor(Color.BLACK);
// g.fillRect(0, getHeight() / 2 - 10, getWidth(), 20);
// g.fillRect(getWidth() / 2 - 10, 0, 20, getHeight());
// }
//
// public Dimension getPreferredSize() {
// return new Dimension(100, 100);
// }
// });
w.pack();
w.setLocationRelativeTo(null);
w.setVisible(true);
w.setAlwaysOnTop(true);
/**
* This sets the background of the window to be transparent.
*/
AWTUtilities.setWindowOpaque(w, false);
// AWTUtilities.setWindowOpacity(w, 0.5f);
setTransparent(w);
}
示例11: fixFlickering
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
private static void fixFlickering(Window wnd, boolean opaque) {
try {
if (UIUtil.isUnderDarcula() && SystemInfo.isMac && Registry.is("darcula.fix.native.flickering") && wnd != null) {
AWTUtilities.setWindowOpaque(wnd, opaque);
}
} catch (Exception ignore) {}
}
示例12: showNewFrame
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
public void showNewFrame()
{
if(dialogForShowingPhoto == null)
{
dialogForShowingPhoto = new JDialog(
// bug of JDK1.7: can't repaint!
// SwingUtilities.getWindowAncestor(org.jb2011.ninepatch4j.demos.photoframe.Demo.this)
);
// set dialog full transparent
dialogForShowingPhoto.setUndecorated(true);
AWTUtilities.setWindowOpaque(dialogForShowingPhoto, false);
// contentPane default is opaque in Java1.7+
((JComponent)(dialogForShowingPhoto.getContentPane())).setOpaque(false);
dialogForShowingPhoto.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
dialogForShowingPhoto.setLocation(100,100);
// dialogForShowingPhoto.setLocationRelativeTo(null);
dialogForShowingPhoto.setAlwaysOnTop(true);//
}
dialogForShowingPhoto.setSize(Integer.parseInt(txtPhotoframeDialogWidth.getText().trim())
, Integer.parseInt(txtPhotoframeDialogHeight.getText().trim()));
// this.remove(panePhotoframe);
dialogForShowingPhoto.add(panePhotoframe);
dialogForShowingPhoto.setVisible(true);
btnHideTheFrame.setEnabled(true);
btnShowInFrame.setEnabled(false);
}
示例13: initGUI
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
protected void initGUI()
{
// set dialog full transparent
this.setAlwaysOnTop(true);
this.setUndecorated(true);
AWTUtilities.setWindowOpaque(this, false);
// this.setBackground(new Color(0,0,0,0));
// contentPane default is opaque in Java1.7+
((JComponent)(this.getContentPane())).setOpaque(false);
this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
// init main layout
toastPane = new ToastPane();
this.add(toastPane);
}
示例14: onFloatingBegin
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
@SuppressWarnings( "serial" )
@Override
public void onFloatingBegin( Tab draggedTab , Point grabPoint )
{
initialize( draggedTab , grabPoint );
if( dragImage != null )
{
if( dragImageWindow == null )
{
dragImageWindow = new Window( null )
{
@Override
public void paint( Graphics g )
{
Graphics2D g2 = ( Graphics2D ) g;
if( dragImage != null )
{
g2.drawImage( dragImage , 0 , 0 , null );
}
}
};
AWTUtilities.setWindowOpaque( dragImageWindow , false );
}
dragImageWindow.setSize( dragImage.getWidth( null ) , dragImage.getHeight( null ) );
dragImageWindow.setAlwaysOnTop( true );
}
}
示例15: AlertifyWindow
import com.sun.awt.AWTUtilities; //导入依赖的package包/类
/**
* Construct a new window.
*
* @param theme The theme to construct from.
* @param config The alert config.
*/
public AlertifyWindow(AlertifyTheme theme, AlertifyConfig config) {
AlertifyColorPair colors = theme.getColors(config.getType());
if (colors == null) {
throw new IllegalArgumentException("Theme does not have support for " + config.getType());
}
JLabel label = config.getLabel();
Optional<Font> font = Optional.ofNullable(config.getFont());
label.setFont(font.isPresent() ? font.get() : theme.getFont()); //checking null state to see which font to use
label.setForeground(colors.getForeground());
JPanel content = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5));
content.setBackground(colors.getBackground());
// Configure the unique theme properties
theme.configure(content);
content.add(label);
add(content);
Dimension contentSize = content.getPreferredSize();
actualWidth = Math.max(contentSize.width, 300);
actualHeight = Math.max(contentSize.height, 64);
setAlwaysOnTop(true);
setPreferredSize(new Dimension(actualWidth, actualHeight));
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
AWTUtilities.setWindowShape(this, new RoundRectangle2D.Double(0, 0, actualWidth, actualHeight, 4, 4));
}