小编ste*_*out的帖子

如何添加一个将JPanel扩展到JFrame的类?

对于我的任务,我得到了这段代码:

// This class/method uses a  global variable that MUST be set before calling/using
// note: You can not call the paint routine directly, it is called when frame/window is shown
// look up the repaint() routine in the book
// Review Listings 8.5 and 8.6
//
public static class MyPanel extends JPanel {
 public void paintComponent (Graphics g) {
    int xpos,ypos;
    super.paintComponent(g);
    // set the xpos and ypos before you display the image
    xpos = 10; // you pick …
Run Code Online (Sandbox Code Playgroud)

java layout swing jpanel jframe

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×1

jframe ×1

jpanel ×1

layout ×1

swing ×1