Java Code Examples for java.awt.Toolkit#getScreenResolution()

The following examples show how to use java.awt.Toolkit#getScreenResolution() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MousePrintRecorder.java    From sc2gears with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new Recorder.
 */
public Recorder() {
	super( "Mouse Print Recorder" );
	
	WhatToSave whatToSave_;
	try {
		whatToSave_ = WhatToSave.values()[ Settings.getInt( Settings.KEY_SETTINGS_MISC_MOUSE_PRINT_WHAT_TO_SAVE ) ];
	} catch ( final IllegalArgumentException iae ) {
		whatToSave_ = WhatToSave.values()[ Settings.getDefaultInt( Settings.KEY_SETTINGS_MISC_MOUSE_PRINT_WHAT_TO_SAVE ) ];
	}
	whatToSave = whatToSave_;
	
	samplingTime = Settings.getInt( Settings.KEY_SETTINGS_MISC_MOUSE_PRINT_SAMPLING_TIME );
	
	final Toolkit toolkit = Toolkit.getDefaultToolkit();
	screenResolution = toolkit.getScreenResolution();
	final Dimension screenSize = toolkit.getScreenSize();
	buffer = new BufferedImage( screenSize.width, screenSize.height, BufferedImage.TYPE_INT_RGB );
	dataStream = whatToSave.saveBinaryData ? new ByteArrayOutputStream( 100000 ) : null;
	
	setRecorderFrameRefreshRate( RECORDER_REFRESH_RATES[ Settings.getInt( Settings.KEY_MOUSE_PRINT_REFRESH_RATE ) ] );
}
 
Example 2
Source File: JasperDesignViewer.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
private void initComponents() {//GEN-BEGIN:initComponents
	pnlMain = new javax.swing.JPanel();

	setTitle("JasperDesignViewer");
	setIconImage(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/jricon.GIF")).getImage());
	addWindowListener(new java.awt.event.WindowAdapter() {
		@Override
		public void windowClosing(java.awt.event.WindowEvent evt) {
			exitForm();
		}
	});

	pnlMain.setLayout(new java.awt.BorderLayout());

	getContentPane().add(pnlMain, java.awt.BorderLayout.CENTER);

	pack();
	
	Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
	java.awt.Dimension screenSize = toolkit.getScreenSize();
	int screenResolution = toolkit.getScreenResolution();
	float zoom = ((float) screenResolution) / net.sf.jasperreports.swing.JRViewerPanel.REPORT_RESOLUTION;
	
	int height = (int) (550 * zoom);
	if (height > screenSize.getHeight())
	{
		height = (int) screenSize.getHeight();
	}		
	int width = (int) (750 * zoom);
	if (width > screenSize.getWidth())
	{
		width = (int) screenSize.getWidth();
	}
	
	java.awt.Dimension dimension = new java.awt.Dimension(width, height);
	setSize(dimension);
	setLocation((screenSize.width-width)/2,(screenSize.height-height)/2);
}
 
Example 3
Source File: JasperViewer.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
private void initComponents() {//GEN-BEGIN:initComponents
	pnlMain = new javax.swing.JPanel();

	setTitle("JasperViewer");
	setIconImage(new javax.swing.ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/jricon.GIF")).getImage());
	addWindowListener(new java.awt.event.WindowAdapter() {
		@Override
		public void windowClosing(java.awt.event.WindowEvent evt) {
			exitForm();
		}
	});

	pnlMain.setLayout(new java.awt.BorderLayout());

	getContentPane().add(pnlMain, java.awt.BorderLayout.CENTER);

	pack();

	Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
	java.awt.Dimension screenSize = toolkit.getScreenSize();
	int screenResolution = toolkit.getScreenResolution();
	float zoom = ((float) screenResolution) / net.sf.jasperreports.swing.JRViewerPanel.REPORT_RESOLUTION;

	int height = (int) (550 * zoom);
	if (height > screenSize.getHeight())
	{
		height = (int) screenSize.getHeight();
	}
	int width = (int) (750 * zoom);
	if (width > screenSize.getWidth())
	{
		width = (int) screenSize.getWidth();
	}

	java.awt.Dimension dimension = new java.awt.Dimension(width, height);
	setSize(dimension);
	setLocation((screenSize.width-width)/2,(screenSize.height-height)/2);
}
 
Example 4
Source File: AbstractUnitConverter.java    From LGoodDatePicker with MIT License 5 votes vote down vote up
/**
 * Returns the components screen resolution or the default screen resolution if the component is
 * null or has no toolkit assigned yet.
 *
 * @param c the component to ask for a toolkit
 * @return the component's screen resolution
 */
protected int getScreenResolution(Component c) {
    if (c == null) {
        return getDefaultScreenResolution();
    }

    Toolkit toolkit = c.getToolkit();
    return toolkit != null
            ? toolkit.getScreenResolution()
            : getDefaultScreenResolution();
}