现在我在用UltraEdit。能不能贴出代码来呀?
解决方案 »
- 求简化下面的语句 谢谢 本人新手
- Java编程思想 第三版 中文版 哪里可以下载到? 谢谢
- 关于ArrayList的小问题 高手指点
- 初哥问3大问题,请入内指导指导
- Eclipse下java执行通过,拿到linux下hive中CREATE TEMPORARY FUNCTION失败
- 如何解析 FTP 的目录列表?100分相送。
- 帮忙解释这段话,除了100分还另有赠分。
- 我不好意思.
- deliver.pc是什么类型的文件?
- [snmp4j]snmp4j通过getBulk要求取数据timeout,可是通过wireshark截包发现网卡已经收到包了,请问是什么原因
- 类型转换的问题,请高手指点一下。
- Linux下面如何设置java环境?
ImageViewer.java
/**
@version 1.21 2002-06-19
@author Cay Horstmann
*/import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;/**
A program for viewing images.
*/
public class ImageViewer
{
public static void main(String[] args)
{
JFrame frame = new ImageViewerFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}/**
A frame with a label to show an image.
*/
class ImageViewerFrame extends JFrame
{
public ImageViewerFrame()
{
setTitle("ImageViewer");
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); // use a label to display the images
label = new JLabel();
Container contentPane = getContentPane();
contentPane.add(label); // set up the file chooser
chooser = new JFileChooser();
chooser.setCurrentDirectory(new File(".")); // set up the menu bar
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar); JMenu menu = new JMenu("File");
menuBar.add(menu); JMenuItem openItem = new JMenuItem("Open");
menu.add(openItem);
openItem.addActionListener(new
ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
// show file chooser dialog
int r = chooser.showOpenDialog(null); // if file selected, set it as icon of the label
if(r == JFileChooser.APPROVE_OPTION)
{
String name
= chooser.getSelectedFile().getPath();
label.setIcon(new ImageIcon(name));
}
}
}); JMenuItem exitItem = new JMenuItem("Exit");
menu.add(exitItem);
exitItem.addActionListener(new
ActionListener()
{
public void actionPerformed(ActionEvent event)
{
System.exit(0);
}
});
} private JLabel label;
private JFileChooser chooser;
private static final int DEFAULT_WIDTH = 300;
private static final int DEFAULT_HEIGHT = 400;
}
import java.awt.*;
import javax.swing.*;
public class Trial
{
JTextField tf1,tf2;
static JFrame f1;
JPanel p1;
public static void main(String args[])
{
f1=new JFrame("Sample Frame");
Trial tobj=new Trial();
f1.setVisible(true);
f1.setSize(300,300);
}
public Trial()
{
p1=new JPanel();
f1.getContentPane().add(p1);
tf1=new JTextField(10);
tf2=new JTextField(10);
tf1.setText("Hello!World!");
Font myfont=new Font("Time New Roman", Font.BOLD,18);
tf2.setFont(myfont);
tf2.setText("Hello!World!");
p1.add(tf1);
p1.add(tf2);
}
}
import java.awt.*;
import java.awt.event.*;public class Frame1 extends Frame
{
Frame1(String title)
{
super(title);
setSize(350,350);
Button button = new Button("你好");
add(button);
setVisible(true);
setLocation(300,200);
}
public static void main(String[] args)
{
new Frame1("我的第一个窗口!");
}
}
首先提醒你,这个窗口关不了!(因为没添加事件)