我无法识别我的奇怪显示器的原始分辨率,因此我必须为它设置自定义分辨率.问题是java无法识别它,因为它不在Win7的"已批准"列表中,因此全屏模式会"卡住".Netbeans出乎意料地全屏,所以必须有办法解决这个问题.谁知道呢?
//编辑(2010年3月29日):看起来NetBeans假装全屏而不是实际进入全屏独占模式,因此实际上这可能无法解决.现在,我也在假装它.看起来像java应该将活动的 DisplayMode 识别为有效.
此示例重现了此问题:
package resolutionexample;
import java.awt.Dimension;
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable(){
public void run() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
DisplayMode currentDM = gd.getDisplayMode();
boolean currentInAvailable = false;
System.out.println("Available resolutions:");
for ( DisplayMode availDM : gd.getDisplayModes() ){
//System.out.println(availDM.getWidth() + "x" + availDM.getHeight());
if ( availDM.equals(currentDM) ){
currentInAvailable = true;
}
}
System.out.println("Current resolution: " + currentDM.getWidth() …Run Code Online (Sandbox Code Playgroud) 这个算法刚停止在我的页面上工作(它已经工作了一年多):
<div class="classA" id="specific1">
<a href="#">Link Text</a>
</div>
.classA a {
style: actual style;
}
Run Code Online (Sandbox Code Playgroud)
a标签不再采用css中的样式.现在为了让我的标签拿起样式,我必须专门给它们一个类,这有效:
<div class="classA" id="specific1">
<a class="classB" href="#">Link Text</a>
</div>
Run Code Online (Sandbox Code Playgroud)
IE7或FireFox4最近有什么变化会破坏第一个算法吗?我宁愿修复css而不是在几个页面上的所有相关标签上插入一个类.
编辑以更好地显示实际样式:
这不再有效(链接有香草100% - 蓝色 - 下划线样式),但已经工作了一段时间.请注意,它最初是为IE6设计的,在切换到IE7后幸存下来,但随后又停止了它的风格.希望这有助于所有慷慨地试图回答的人!
-- HTML --
<div class="ovalButton" id="oval1"><a href="#">LinkText</a></div>
-- CSS --
* {
margin: 0;
padding: 0;
overflow: hidden;
font-family: verdana, arial, sans-serif;
}
.ovalButton {
position: absolute;
width: 150px;
height: 60px;
}
.ovalbutton a {
background: url("logo_butn.gif") no-repeat;
display: block;
color: #0063B5;
width: 150px;
height: 60px;
overflow: hidden;
font-size: …Run Code Online (Sandbox Code Playgroud) 任何人都可以解释以下行为吗?该方法应该对加载的图像进行缩放,使其尽可能大,但不能超过某些范围.
private final File imageFile;
private final ImageLoaderListener listener;
private final int idealWidth;
private final int idealHeight;
private final float idealRatio;
@Override
protected BufferedImage doInBackground() throws Exception {
BufferedImage origImage;
BufferedImage scaledImage;
int origHeight;
int origWidth;
float imgRatio;
// Load the image.
try {
origImage = ImageIO.read( imageFile );
origHeight = origImage.getHeight();
origWidth = origImage.getWidth();
imgRatio = origWidth / origHeight;
//imgRatio = 5/7;
} catch (Exception e){
JOptionPane.showMessageDialog( AppFrame.getAppFrame(),
"Could not load the image.", "Error Loading Image",
JOptionPane.ERROR_MESSAGE );
return …Run Code Online (Sandbox Code Playgroud)