📄 showimage.java
字号:
/*
* showImage.java
*
* Created on 2006年10月7日, 下午1:13
*/
package boxgame;
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
/**
*
* @author freezing
*/
public class showImage extends javax.swing.JFrame {
private Image image;
/** Creates new form showImage */
public showImage(BufferedImage buf) {
initComponents();
image=this.createImage(210,210);
Graphics g=image.getGraphics();
g.drawImage(buf,0,0,this);
imageLabel.setIcon(new ImageIcon(image));
//this.add(imageLabel,BorderLayout.CENTER);
// this.setSize(300,250);
this.setLocation(300,100);
this.setVisible(false);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">//GEN-BEGIN:initComponents
private void initComponents() {
imageLabel = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("\u539f\u56fe");
imageLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
imageLabel.setBorder(new javax.swing.border.MatteBorder(null));
imageLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(imageLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(imageLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 235, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
//new showImage().setVisible(true);
}
});
}
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JLabel imageLabel;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -