Skip to content

Instantly share code, notes, and snippets.

@blackraccoon000
Created January 31, 2011 20:29
Show Gist options
  • Save blackraccoon000/804743 to your computer and use it in GitHub Desktop.
Save blackraccoon000/804743 to your computer and use it in GitHub Desktop.
PictTest
package Label;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by IntelliJ IDEA.
* User: white
* Date: 11/02/01
* Time: 4:47
* To change this template use File | Settings | File Templates.
*/
public class LabelA extends JFrame implements ActionListener{
JLabel label;
public static void main(String args[]){
LabelA frame = new LabelA("Pict Test");
frame.setVisible(true);
}
LabelA(String title){
setTitle(title);
setBounds(100,100,300,250);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ImageIcon icon = new ImageIcon("./src/main/java/pict/a1.jpg");
label = new JLabel(icon);
label.setText("NO");
JPanel p1 = new JPanel();
JButton btn = new JButton("click me");
btn.addActionListener(this);
p1.add(btn);
p1.setPreferredSize(new Dimension(130,80));
p1.add(label);
getContentPane().add(p1, BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent e){
label.setIcon(new ImageIcon("./src/main/java/pict/b1.jpg"));
label.setText("OK");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment