import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Lab11_4 extends JApplet { Container c ; JButton plainBtn, fancyBtn ; JTextArea textArea ; ImageIcon plane1,plane2; public void init () { c = getContentPane(); c.setLayout( new FlowLayout() ); plainBtn = new JButton("Plain Button"); c.add( plainBtn ); //plane1 = new ImageIcon("m1.gif"); //plane2 = new ImageIcon("m2.gif"); fancyBtn = new JButton("Fancy Button"); //fancyBtn = new JButton("Fancy Button",plane1); //fancyBtn.setRolloverIcon(plane2); c.add( fancyBtn ); ButtonHandler handler = new ButtonHandler(); fancyBtn.addActionListener( handler ); plainBtn.addActionListener( handler ); setSize(280, 200); textArea = new JTextArea(5,40); textArea.setEditable(false); c.add(textArea); } private class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent event) { JOptionPane.showMessageDialog( Lab11_4.this ,"You pressed : " + event.getActionCommand() ); } } }
import java.awt.Color; import javax.swing.ImageIcon; import javax.swing.JApplet; import javax.swing.JButton; public class yahoo extends JApplet { private JButton button,picture; public void init() { setBackground(Color.PINK); button = new JButton("clilck here"); ImageIcon pic = new ImageIcon("flower.jpg"); picture=new JButton(pic); add(button); add(picture); } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง