本文整理汇总了Java中java.awt.GraphicsDevice.WindowTranslucency类的典型用法代码示例。如果您正苦于以下问题:Java WindowTranslucency类的具体用法?Java WindowTranslucency怎么用?Java WindowTranslucency使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WindowTranslucency类属于java.awt.GraphicsDevice包,在下文中一共展示了WindowTranslucency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ToastWindow
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
private ToastWindow() {
setUndecorated(true);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
if (gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
setOpacity(0.55f);
}
setSize(250, 100);
setShape(new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), 10, 10));
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
}
});
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension resolution = toolkit.getScreenSize();
int x = (int) resolution.getWidth() - getWidth() - MARGIN;
int y = MARGIN;
setLocation(x, y);
setBackground(new Color(0f, 0f, 0f, 1f / 2f));
messageLabel = new JLabel();
messageLabel.setForeground(Color.WHITE);
messageLabel.setHorizontalAlignment(SwingConstants.CENTER);
add(messageLabel);
}
示例2: itemStateChanged
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
if (e.getSource() == this.cmbDevices) {
// get the new value
GraphicsDevice device = (GraphicsDevice)e.getItem();
// test for translucency support
if (!device.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
// if this device doesn't support translucency, then the translucent color/image backgrounds will not work
this.lblTranslucency.setText(Messages.getString("panel.general.preferences.display.translucent.warning"));
this.lblTranslucency.setIcon(Icons.WARNING);
} else {
this.lblTranslucency.setText("");
this.lblTranslucency.setIcon(null);
}
}
}
}
示例3: setOpacityProp
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
private void setOpacityProp() {
if (gDevice.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
setOpacity(ev.getOpacity());
} else {
if (NotifyConfig.getDebug()) {
System.out.println(CLASS_NAME+": Your System don't support the Opacity feature.");
}
}
}
示例4: setBorderType
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
private void setBorderType() {
switch (ev.getBorder()) {
case ROUNDED:
if (gDevice.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
setShape(new RoundRectangle2D.Double(0,0,getWidth(),getHeight(), 15, 15));
}
});
} else {
if (NotifyConfig.getDebug()) {
System.out.println(CLASS_NAME+": Your System don't support this Border feature.");
}
}
break;
case RAISED:
panel.setBorder(BorderFactory.createRaisedBevelBorder());
break;
case ETCHED:
panel.setBorder(BorderFactory.createEtchedBorder());
break;
default: // NONE
// do nothing
}
}
示例5: checkEffects
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
private void checkEffects() {
GraphicsDevice gd = getGraphicsConfiguration().getDevice();
if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
shapedCb.setEnabled(false);
}
if (!gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
transparencySld.setEnabled(false);
}
if (!gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
nonOpaqueChb.setEnabled(false);
}
}
示例6: actionPerformed
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if ("identify".equals(command)) {
// implementation note:
// we use JDialog here instead of JFrame because we don't want the task bar
// to show focusable windows. Using a JDialog allows it to part of the application
// and not a separate window.
int n = this.devices.length;
// identify the devices
JDialog[] dialogs = new JDialog[n];
// create the frames
for (int i = 0; i < n; i++) {
// get the device
GraphicsDevice device = this.devices[i];
// create a frame for each device
JDialog dialog = dialogs[i] = new JDialog(WindowUtilities.getParentWindow(this), "", ModalityType.MODELESS, WindowUtilities.getTranslucentConfiguration(device));
// create a label for each device
JLabel lblName = new JLabel(WindowUtilities.getDeviceName(device, i, Messages.getString("display.name.format")));
lblName.setFont(new Font(lblName.getFont().getName(), Font.PLAIN, 50));
lblName.setHorizontalAlignment(SwingConstants.CENTER);
// make sure the frame is sized and positioned correctly
GraphicsConfiguration gc = device.getDefaultConfiguration();
Rectangle r = gc.getBounds();
dialog.setUndecorated(true);
dialog.setFocusable(false);
dialog.setLayout(new BorderLayout());
dialog.add(lblName, BorderLayout.CENTER);
dialog.setLocation(r.x, r.y);
dialog.setMinimumSize(new Dimension(r.width, r.height));
// enable translucency if available
if (device.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
dialog.setBackground(new Color(0.0f, 0.0f, 0.0f, 0.0f));
}
dialog.setVisible(true);
}
// close the frames in a different thread
DelayCloseWindowTask.execute(1000, dialogs);
}
}
示例7: getWindowTranslucency
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
/**
* Returns the translucency support for this window.
* @return {@link WindowTranslucency}
*/
protected WindowTranslucency getWindowTranslucency() {
if (this.device.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
return WindowTranslucency.PERPIXEL_TRANSLUCENT;
} else if (this.device.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
return WindowTranslucency.TRANSLUCENT;
} else if (this.device.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
return WindowTranslucency.PERPIXEL_TRANSPARENT;
} else {
return null;
}
}
示例8: checkTranslucencyMode
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
private static void checkTranslucencyMode(WindowTranslucency arg) {
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
if (!gd.isWindowTranslucencySupported(arg)) {
System.err.println("'" + arg
+ "' translucency mode isn't supported.");
System.exit(-1);
}
}
示例9: main
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
/**
* @param args the command line arguments are ignored
*/
public static void main(String[] args) throws InterruptedException, InvocationTargetException {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
checkTranslucencyMode(WindowTranslucency.PERPIXEL_TRANSLUCENT);
checkTranslucencyMode(WindowTranslucency.PERPIXEL_TRANSPARENT);
Ruler ruler = new Ruler();
ruler.setVisible(true);
}
});
}
示例10: checkTranslucencyMode
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
private static boolean checkTranslucencyMode(WindowTranslucency arg) {
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
return gd.isWindowTranslucencySupported(arg);
}
示例11: SystemDialog
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
/**
* Full constructor.
* @param owner the dialog owner
*/
private SystemDialog(Window owner) {
super(owner, Messages.getString("dialog.system.title"), ModalityType.MODELESS);
// build the property listing
List<Pair<String, String>> properties = new ArrayList<Pair<String, String>>();
properties.add(Pair.of(Messages.getString("dialog.system.praisenter.version"), Version.getVersion()));
properties.add(Pair.of(Messages.getString("dialog.system.java"), SystemUtilities.getJavaVersion()));
properties.add(Pair.of(Messages.getString("dialog.system.vendor"), SystemUtilities.getJavaVendor()));
properties.add(Pair.of(Messages.getString("dialog.system.javaPath"), SystemUtilities.getJavaHomeDirectory()));
properties.add(Pair.of(Messages.getString("dialog.system.args"), SystemUtilities.getJvmArguments()));
properties.add(Pair.of(Messages.getString("dialog.system.os"), SystemUtilities.getOperatingSystem()));
properties.add(Pair.of(Messages.getString("dialog.system.architecture"), SystemUtilities.getArchitecture()));
properties.add(Pair.of(Messages.getString("dialog.system.cpus"), String.valueOf(Runtime.getRuntime().availableProcessors())));
properties.add(Pair.of(Messages.getString("dialog.system.locale"), Locale.getDefault().toString()));
properties.add(Pair.of(Messages.getString("dialog.system.separator"), FileUtilities.getSeparator()));
properties.add(Pair.of(Messages.getString("dialog.system.currentDirectory"), new File("").getAbsolutePath()));
properties.add(Pair.of(Messages.getString("dialog.system.userPath"), SystemUtilities.getUserHomeDirectory()));
properties.add(Pair.of(Messages.getString("dialog.system.basePath"), Constants.BASE_PATH));
properties.add(Pair.of(Messages.getString("dialog.system.desktopSupport"), String.valueOf(Desktop.isDesktopSupported())));
properties.add(Pair.of(Messages.getString("dialog.system.defaultDevice"), WindowUtilities.getDefaultDevice().getIDstring()));
GraphicsDevice[] devices = WindowUtilities.getDevices();
properties.add(Pair.of(Messages.getString("dialog.system.deviceCount"), String.valueOf(devices.length)));
for (GraphicsDevice device : devices) {
properties.add(Pair.of(MessageFormat.format(Messages.getString("dialog.system.translucencySupport"), device.getIDstring()), String.valueOf(device.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT))));
}
properties.add(Pair.of(Messages.getString("dialog.system.laf"), UIManager.getLookAndFeel().getName()));
properties.add(Pair.of(Messages.getString("dialog.system.debugEnabled"), String.valueOf(Main.isDebugEnabled())));
// create the verse queue table
@SuppressWarnings("serial")
JTable tblProperties = new JTable(new SystemTableModel(properties)) {
@Override
public String getToolTipText(MouseEvent event) {
Point p = event.getPoint();
int row = this.rowAtPoint(p);
if (row < 0) return super.getToolTipText();
// since sorting is allowed, we need to translate the view row index
// into the model row index
row = this.convertRowIndexToModel(row);
// get the text column value
TableModel model = this.getModel();
Object object = model.getValueAt(row, 1);
if (object != null) {
// get the text
return object.toString();
}
return super.getToolTipText(event);
}
};
tblProperties.setAutoCreateRowSorter(true);
tblProperties.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
tblProperties.setColumnSelectionAllowed(false);
tblProperties.setCellSelectionEnabled(false);
tblProperties.setRowSelectionAllowed(true);
tblProperties.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
tblProperties.getColumnModel().getColumn(0).setPreferredWidth(150);
tblProperties.getColumnModel().getColumn(1).setPreferredWidth(250);
JScrollPane scrProperties = new JScrollPane(tblProperties);
scrProperties.setBorder(null);
// set the size
this.setPreferredSize(new Dimension(550, 400));
Container container = this.getContentPane();
container.setLayout(new BorderLayout());
container.add(scrProperties, BorderLayout.CENTER);
this.pack();
}
示例12: PresentationWindow
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
/**
* Creates a new display window for the given device.
* @param device the device
* @param fullScreen true if the window should be full screen
* @param overlay true if the window should always be on top of other windows
*/
public PresentationWindow(GraphicsDevice device, boolean fullScreen, boolean overlay) {
super((Frame)null, "Praisenter Presentation Window", false, WindowUtilities.getTranslucentConfiguration(device));
// simple assignments
this.device = device;
this.fullScreen = fullScreen;
this.overlay = overlay;
// setup the dialog
this.setUndecorated(true);
// don't allow focus to transfer to the dialog
this.setAutoRequestFocus(false);
this.setFocusable(false);
this.setFocusableWindowState(false);
this.setFocusTraversalKeysEnabled(false);
WindowTranslucency translucency = this.getWindowTranslucency();
if (translucency == WindowTranslucency.PERPIXEL_TRANSLUCENT) {
// this is the best since all transitions will work
this.setBackground(new Color(0, 0, 0, 0));
LOGGER.debug("Per-pixel translucency supported (best).");
} else if (translucency == WindowTranslucency.TRANSLUCENT) {
LOGGER.debug("Only uniform translucency supported.");
} else if (translucency == WindowTranslucency.PERPIXEL_TRANSPARENT) {
LOGGER.debug("Only per-pixel transparency supported (only shaped windows possible).");
} else {
LOGGER.debug("Translucency/Transparency not supported.");
}
// get the device's default config
GraphicsConfiguration gc = this.device.getDefaultConfiguration();
// get its position and dimensions
Rectangle r = gc.getBounds();
// set the dialog location to the top left corner of the
// target display device
this.setLocation(r.x, r.y);
// a full screen display window has its size set to the
// height and width of the device
Dimension size = new Dimension(r.width, r.height);
this.setMinimumSize(size);
this.setPreferredSize(size);
// setup the display surface
Container container = this.getContentPane();
container.setLayout(new BorderLayout());
this.surface = new PresentationSurface();
this.surface.addPresentListener(this);
this.addWindowListener(this.surface);
if (Main.isDebugEnabled()) {
this.surface.setBorder(BorderFactory.createLineBorder(Color.RED, 10));
}
container.add(this.surface, BorderLayout.CENTER);
this.setAlwaysOnTop(overlay);
// make sure the panel is resized to fit the layout
this.pack();
}
示例13: isPerpixelTransparencySupported
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
public static boolean isPerpixelTransparencySupported () {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
return gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT);
}
示例14: isWindowTranslucencySupported
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
public static boolean isWindowTranslucencySupported() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
return gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT);
}
示例15: isTransitionSupportAvailable
import java.awt.GraphicsDevice.WindowTranslucency; //导入依赖的package包/类
/**
* Returns true if transitions are supported by the given device.
* @param device the device
* @return boolean
*/
public static final boolean isTransitionSupportAvailable(GraphicsDevice device) {
return device.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT);
}