//在这个框架里
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.AbstractButton;
public class YWindow extends JFrame{
public YWindow(){
setLayout(null);
setTitle("管理系统");
setBounds(500,200,700,700);
setVisible(true);
//
validate();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
java,如何在窗口里添加背景图片
答案:2 悬赏:0 手机版
解决时间 2021-03-15 06:52
- 提问者网友:趣果有间
- 2021-03-14 18:07
最佳答案
- 五星知识达人网友:北城痞子
- 2021-03-14 19:10
在需要添加背景的组件的 paint事件中,绘一张图片
~
~
~
~
~
~
~
~
~
~
全部回答
- 1楼网友:荒野風
- 2021-03-14 20:02
import java.awt.color; import java.awt.frame; import java.awt.graphics; public class drawstring extends frame{ private static final int spacing = 20 ; //文字与图片边界的空白 private static final int wordnum = 7; //文字字号 private color strcolor; private stringbuffer message; private int picturewidth; private int picturehight; public void paint(graphics g){ color c = g.getcolor(); g.setcolor(strcolor); stringbuffer msg = message; int strnumperline = (picturewidth - spacing) / wordnum; int strlinenum = message.length() / strnumperline; for(int l=strlinenum,n=0 ;l<0; l--){ msg.substring(n, strnumperline); g.drawstring(msg.tostring(), wordnum, wordnum * strnumperline); n = strnumperline; } g.setcolor(c); //this.draw(g); } public drawstring(color strcolor, stringbuffer message, int picturewidth, int picturehight) { this.strcolor = strcolor; this.message = message; this.picturewidth = picturewidth; this.picturehight = picturehight; } }
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯