use of java.awt.Dimension in project jna by java-native-access.
the class BalloonManagerDemo method main.
public static void main(String[] args) {
try {
System.setProperty("sun.java2d.noddraw", "true");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
}
JFrame f = new JFrame("Balloon Test");
final String BALLOON_TEXT = "<html><center>" + "This is some sample balloon text<br>" + "which has been formatted with html.<br>" + "Click to dismiss.</center></html>";
final JLabel content = new JLabel(BALLOON_TEXT);
content.setIconTextGap(10);
content.setBorder(new EmptyBorder(0, 8, 0, 8));
content.setSize(content.getPreferredSize());
content.setIcon(new InfoIcon());
JLabel label = new JLabel("Click anywhere for more information");
label.setHorizontalAlignment(SwingConstants.CENTER);
label.addMouseListener(new MouseAdapter() {
private MouseListener listener = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
hidePopup(e);
}
};
private Popup popup;
private void hidePopup(MouseEvent e) {
e.getComponent().removeMouseListener(listener);
if (popup != null)
popup.hide();
}
public void mousePressed(MouseEvent e) {
hidePopup(e);
popup = BalloonManager.getBalloon(e.getComponent(), content, e.getX(), e.getY());
popup.show();
content.getParent().addMouseListener(listener);
}
});
f.getContentPane().add(label);
f.pack();
f.setSize(new Dimension(300, 300));
f.setLocation(100, 100);
try {
// Force a load of JNA
WindowUtils.setWindowMask(f, WindowUtils.MASK_NONE);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
String msg = e.getMessage() + "\nError loading the JNA library";
JTextArea area = new JTextArea(msg);
area.setOpaque(false);
area.setFont(UIManager.getFont("Label.font"));
area.setEditable(false);
area.setColumns(80);
area.setRows(8);
area.setWrapStyleWord(true);
area.setLineWrap(true);
JOptionPane.showMessageDialog(null, new JScrollPane(area), "Library Load Error: " + System.getProperty("os.name") + "/" + System.getProperty("os.arch"), JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
}
use of java.awt.Dimension in project screenbird by adamhub.
the class PreviewPlayer method setScreenshot.
/**
* Sets the displayed screenshot on the PreviewPlayer.
* @param screenshot BufferedImage object of the screenshot to be displayed
* @param center Not used
* @param show true if to display PreviewPlayer after setting the displayed screenshot
*/
public void setScreenshot(final BufferedImage screenshot, boolean center, boolean show) {
BufferedImage image = screenshot;
// Get image size
imageSize.width = image.getWidth();
imageSize.height = image.getHeight();
Dimension displaySize = ScreenUtil.getScreenDimension(getGraphicsConfiguration().getDevice());
// Scale images if dimensions are larger than the current screen
if (imageSize.width > displaySize.width || imageSize.height > displaySize.height) {
// Allows previewing of larger external displays
// Adjust for full screen preview from external display
screenshotSize.width = (int) (displaySize.width * Settings.FULLSCREEN_PREVIEW_SCALE);
screenshotSize.height = (int) (displaySize.height * Settings.FULLSCREEN_PREVIEW_SCALE);
} else if (screenSize.equals(imageSize)) {
// For fullscreen display
// Adjust for full screen preview
screenshotSize.width = (int) (imageSize.width * Settings.FULLSCREEN_PREVIEW_SCALE);
screenshotSize.height = (int) (imageSize.height * Settings.FULLSCREEN_PREVIEW_SCALE);
} else {
// Adjust for custom screen preview
if (1.0 * (imageSize.width + 100) / displaySize.width >= Settings.FULLSCREEN_PREVIEW_SCALE || 1.0 * (imageSize.height + 100) / displaySize.height >= Settings.FULLSCREEN_PREVIEW_SCALE) {
screenshotSize.width = (int) (displaySize.width * Settings.FULLSCREEN_PREVIEW_SCALE);
screenshotSize.height = (int) (displaySize.height * Settings.FULLSCREEN_PREVIEW_SCALE);
} else {
screenshotSize.width = (int) (imageSize.width * Settings.CUSTOMSCREEN_PREVIEW_SCALE);
screenshotSize.height = (int) (imageSize.height * Settings.CUSTOMSCREEN_PREVIEW_SCALE);
}
}
// Change screen size
loadPlayerOffset();
this.jpImage.setImage(screenshot, screenshotSize.width, screenshotSize.height);
ScreenUtil.changeSize(jfPreviewPlayer.getFrame(), new Dimension(playerSize.width, playerSize.height));
if (centerPreviewPlayer) {
this.jfPreviewPlayer.loadSmartPosition(show);
}
}
use of java.awt.Dimension in project screenbird by adamhub.
the class PreviewPlayerForm method loadSmartPosition.
/**
* Moves the PreviewPlayer to the center of the screen.
* @param jSliderPreview
* @param show
*/
public synchronized void loadSmartPosition(boolean show) {
Dimension screenSize = ScreenUtil.getScreenDimension(getGraphicsConfiguration().getDevice());
Dimension playerSize = this.jfPreviewPlayer.getSize();
// Determines the cooridnates to center a form to the screen
int x = screenSize.width;
int y = screenSize.height;
int w = playerSize.width;
int h = playerSize.height;
x = (x / 2) - (w / 2);
y = (y / 2) - (h / 2);
this.jfPreviewPlayer.setLocation(x, y);
if (show) {
this.showPlayer();
}
}
use of java.awt.Dimension in project screenbird by adamhub.
the class RecorderPanel method centerRecorderPanel.
/**
* Centers Recorder Panel vertically and horizontally dynamically with any
* screen resolution. Pretty handy.
*/
private void centerRecorderPanel() {
Dimension screenSize = ScreenUtil.getScreenDimension(this.recorder.getScreen());
Dimension appletSize = UPLOAD_SIZE;
// Determines the cooridnates to center a form to the screen
int x = screenSize.width;
int y = screenSize.height;
int w = appletSize.width;
int h = appletSize.height;
x = (x / 2) - (w / 2);
y = (y / 2) - (h / 2);
this.jfRecorderPanel.controlSetLocation(x, y);
((JFrame) this.getParent().getParent().getParent().getParent()).pack();
}
use of java.awt.Dimension in project screenbird by adamhub.
the class RecorderPanel method initResizeTask.
/**
* Monitors the size of the recorder and adjusts it properly, depending
* on whether the recorder panel is visible or the upload form is visible.
*
* This does nothing on systems that support transparency.
*/
private void initResizeTask() {
if (AWTUtilities.isTranslucencyCapable(((ScreenRecorder) this.jfRecorderPanel).getGraphicsConfiguration())) {
log("Not doing resizing...");
return;
}
final RecorderPanel recorderPanel = this;
final Dimension recorderDimension = new Dimension(276, 62);
final Dimension uploadDimension = jpUpload.getPreferredSize();
final Dimension invisibleDimension = new Dimension(0, 0);
TimerTask tt = new TimerTask() {
@Override
public void run() {
boolean changed = false;
if (recorderPanel.recorderPanelBG1.isVisible() && !recorderDimension.equals(recorderPanel.getSize())) {
log("Resizing! " + recorderDimension + " " + ((JFrame) recorderPanel.jfRecorderPanel).getPreferredSize());
recorderPanel.setPreferredSize(recorderDimension);
recorderPanel.setMinimumSize(recorderDimension);
recorderPanel.setMaximumSize(recorderDimension);
recorderPanel.setSize(recorderDimension);
changed = true;
} else if (recorderPanel.jpUpload.isVisible() && !uploadDimension.equals(recorderPanel.getSize())) {
log("Resizing! " + uploadDimension + " " + ((JFrame) recorderPanel.jfRecorderPanel).getPreferredSize());
recorderPanel.setPreferredSize(uploadDimension);
recorderPanel.setMinimumSize(uploadDimension);
recorderPanel.setMaximumSize(uploadDimension);
recorderPanel.setSize(uploadDimension);
changed = true;
} else if (!recorderPanel.jpUpload.isVisible() && !recorderPanel.recorderPanelBG1.isVisible() && !invisibleDimension.equals(recorderPanel.getSize())) {
log("Resizing! " + uploadDimension + " " + ((JFrame) recorderPanel.jfRecorderPanel).getPreferredSize());
recorderPanel.setPreferredSize(invisibleDimension);
recorderPanel.setMinimumSize(invisibleDimension);
recorderPanel.setMaximumSize(invisibleDimension);
recorderPanel.setSize(invisibleDimension);
changed = true;
}
if (changed) {
((ScreenRecorder) recorderPanel.jfRecorderPanel).controlPack();
((ScreenRecorder) recorderPanel.jfRecorderPanel).repaint();
((ScreenRecorder) recorderPanel.jfRecorderPanel).getContentPane().repaint();
recorderPanel.repaint();
recorderPanel.recorderPanelBG1.repaint();
}
}
};
java.util.Timer timer = new java.util.Timer();
timer.scheduleAtFixedRate(tt, 0, 10);
}
Aggregations