java中Jframe问题
运行下段Jframe程序后会出现叠影怎么处理啊?谢谢啦!importjava.awt.Color;importjava.awt.Dimension;importjava....
运行下段Jframe程序后会出现叠影怎么处理啊?谢谢啦!
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.io.File;
import java.io.IOException;
import javax.swing.JFrame;
public class All extends JFrame {
File[] list = File.listRoots();
All(){
setTitle("各盘符容量");
setSize(400,350);
setBackground(Color.white);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Toolkit tkit=Toolkit.getDefaultToolkit();
Dimension screenSize=tkit.getScreenSize();
Dimension frameSize=this.getSize();
if (frameSize.height>screenSize.height)
{
frameSize.height=screenSize.height;
}
if (frameSize.width>screenSize.width)
{
frameSize.width=screenSize.width;
}
this.setLocation((screenSize.width-frameSize.width)/2,
(screenSize.height-frameSize.height)/2);
File[] list = File.listRoots();
show();
}
public void paint(Graphics g){
float f = 1024*1024*1024;
for (int i=0;i<(list.length);i++) {
System.out.println(list[i].toString()+(list[i]).getFreeSpace()/f);
g.drawString((list[i].toString()+(list[i]).getFreeSpace()/f), i*20, i*80);
}
}
public static void main(String[] args)throws InterruptedException,
IOException{
new All();
}
} 展开
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.io.File;
import java.io.IOException;
import javax.swing.JFrame;
public class All extends JFrame {
File[] list = File.listRoots();
All(){
setTitle("各盘符容量");
setSize(400,350);
setBackground(Color.white);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Toolkit tkit=Toolkit.getDefaultToolkit();
Dimension screenSize=tkit.getScreenSize();
Dimension frameSize=this.getSize();
if (frameSize.height>screenSize.height)
{
frameSize.height=screenSize.height;
}
if (frameSize.width>screenSize.width)
{
frameSize.width=screenSize.width;
}
this.setLocation((screenSize.width-frameSize.width)/2,
(screenSize.height-frameSize.height)/2);
File[] list = File.listRoots();
show();
}
public void paint(Graphics g){
float f = 1024*1024*1024;
for (int i=0;i<(list.length);i++) {
System.out.println(list[i].toString()+(list[i]).getFreeSpace()/f);
g.drawString((list[i].toString()+(list[i]).getFreeSpace()/f), i*20, i*80);
}
}
public static void main(String[] args)throws InterruptedException,
IOException{
new All();
}
} 展开
1个回答
展开全部
public void paint(Graphics g){
super.paint();//加上这个试试
float f = 1024*1024*1024;
for (int i=0;i<(list.length);i++) {
System.out.println(list[i].toString()+(list[i]).getFreeSpace()/f);
g.drawString((list[i].toString()+(list[i]).getFreeSpace()/f), i*20, i*80);
}
}
super.paint();//加上这个试试
float f = 1024*1024*1024;
for (int i=0;i<(list.length);i++) {
System.out.println(list[i].toString()+(list[i]).getFreeSpace()/f);
g.drawString((list[i].toString()+(list[i]).getFreeSpace()/f), i*20, i*80);
}
}
追问
貌似不行呢,
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询