如何在不同分辨率的双屏显示系统指定窗口的位置 系统支持双屏显示,两个显示器设置为不同的分辨率,一个为1024×768(32真彩色)一个为1600×1200(256色),程序需要双屏显示,其中主程序在第一个屏幕,在程序中通过命令行外部调用另一个程序,并且要显示到第二个屏幕上,请问如何实现?或者我如何在子程序中设置其显示位置为第二个显示器? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 去看一下java.awt.GraphicsDevice类的API文档,里面有示例代码 ToolKit类的getScreenSize()方法只能得到主显示屏幕的显示尺寸,要得到其他屏幕的显示尺寸需要用到GraphicsConfiguration类和GraphicsDevice类,具体方法自己去查文档吧。 JFrame frame = new JFrame();.................... // Center of the screen. Rectangle screenRect = frame.getGraphicsConfiguration().getBounds(); Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(frame.getGraphicsConfiguration()); int centerWidth = screenRect.width < MainFrame.newContentPane.getSize().width ? screenRect.x : screenRect.x + screenRect.width/2 - frame.getSize().width/2; int centerHeight = screenRect.height < frame.getSize().height ? screenRect.y : screenRect.y + screenRect.height/2 - frame.getSize().height/2; centerHeight = centerHeight < screenInsets.top ? screenInsets.top : centerHeight; // centerWidth = (screenRect.width - 800)/2; centerHeight = (screenRect.height - 700)/2; centerHeight = centerHeight < screenInsets.top ? screenInsets.top : centerHeight; frame.setLocation(centerWidth, centerHeight); 请问为什么这个程序播放不成音乐呢? 帮我看看 表格输出数据库的代码为何有异常 think in java上的一个例子 功力不够!请问这个怎么写,有关类和对象的! [求助]一个关于多态性的问题,请各位指教 初学者问题 大家来看看哦 JNI问题,各位高手多多指教??? 最近苦于做Application时,对输入数据进行校验、去空格、转字符集……有没有什么好的模式可以解决这些问题? 如何在一个类文件中,显示另一个类文件中的记录集,(有分) kill 线程的方法? 子类对象调用覆盖的方法? 求用JAVA编写的远程屏幕监控程序源代码
....................
// Center of the screen.
Rectangle screenRect = frame.getGraphicsConfiguration().getBounds();
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(frame.getGraphicsConfiguration()); int centerWidth = screenRect.width < MainFrame.newContentPane.getSize().width ?
screenRect.x :
screenRect.x + screenRect.width/2 - frame.getSize().width/2;
int centerHeight = screenRect.height < frame.getSize().height ?
screenRect.y :
screenRect.y + screenRect.height/2 - frame.getSize().height/2; centerHeight = centerHeight < screenInsets.top ?
screenInsets.top : centerHeight; //
centerWidth = (screenRect.width - 800)/2;
centerHeight = (screenRect.height - 700)/2; centerHeight = centerHeight < screenInsets.top ?
screenInsets.top : centerHeight;
frame.setLocation(centerWidth, centerHeight);