📄 imagepanel.java
字号:
package za.co.halo.SecureCommunications.gui.server;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
import javax.swing.JFrame;
/**
* This code was generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* *************************************
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED
* for this machine, so Jigloo or this code cannot be used legally
* for any corporate or commercial purpose.
* *************************************
*/
public class ImagePanel extends javax.swing.JPanel
{
private String path;
private String discription;
private ImageIcon image;
private JLabel imageLabel;
/**
* Auto-generated main method to display this
* JPanel inside a new JFrame.
*/
public static void main(String[] args)
{
JFrame frame = new JFrame();
//frame.getContentPane().add(new ImagePanel(name));
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
public ImagePanel(String path, String discription)
{
super();
this.path = path;
this.discription = discription;
initGUI();
}
private void initGUI()
{
try
{
setPreferredSize(new Dimension(610, 83));
this.setBackground(new Color(15,65,108));
image = createImageIcon(path,discription);
imageLabel = new JLabel(image);
imageLabel.setBounds(0,0,610,83);
this.add(imageLabel);
}
catch (Exception e)
{
e.printStackTrace();
}
}
protected static ImageIcon createImageIcon(String path, String description)
{
java.net.URL imgURL = ImagePanel.class.getResource(path);
if (imgURL != null)
{
return new ImageIcon(imgURL, description);
}
else
{
System.err.println("Couldn't find file: " + path);
return null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -