이미지 아이콘에 대해서 ..(JButton)
ChocoHoilc
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.BevelBorder;
import javax.swing.border.SoftBevelBorder;
class Edit_Form implements ActionListener{
JFrame frame = null;
JMenuItem oneItem1, oneItem2, twoItem1;
JButton jla1, jla3, jla2;
JTextArea textArea;
Edit_Form(){
frame = new JFrame(에디트플러스);
frame.setLayout(new BorderLayout());
JMenuBar bar = new JMenuBar();JMenu one = new JMenu(파일);
oneItem1 = new JMenuItem(열기);
oneItem1.addActionListener(this);
one.add(oneItem1);
one.addSeparator();
oneItem2 = new JMenuItem(종료);
oneItem2.addActionListener(this);
one.add(oneItem2);
bar.add(one);
JMenu two = new JMenu(편집);
twoItem1 = new JMenuItem(지우기);
twoItem1.addActionListener(this);
two.add(twoItem1);
bar.add(two);
J
Panel top = new JPanel();
top.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
jla1 = new JButton(new ImageIcon(32.gif));
jla1.setBorderPainted ( false );//테두리색 없애기
//jla1.setContentAreaFilled( false );
//jla1.setBorder(null);//테두리색없애기
jla1.setOpaque(true);
jla1.setBounds(new Rectangle(7,32,355,27));
jla1.setMargin(new Insets(0,0,0,0));
jla1.setPreferredSize(new Dimension(20, 20));
jla1.setCursor(new Cursor(Cursor.HAND_CURSOR));
jla1.setToolTipText(열기);
jla1.addActionListener(this);
top.add(jla1);jla2 = new JButton(new ImageIcon(123.jpg));
jla2.setBorderPainted ( false );
jla2.setMargin(new Insets(0,0,0,0));
jla2.setPreferredSize(new Dimension(20, 20));
jla2.setCursor(new Cursor(Cursor.HAND_CURSOR));
jla2.setToolTipText(지우기);
jla2.addActionListener(this);
top.add(jla2);jla3 = new JButton(new ImageIcon(2.jpg));
jla3.setBorderPainted ( false );
jla3.setMargin(new Insets(0,0,0,0));
jla3.setPreferredSize(new Dimension(20, 20));
jla3.setCursor(new Cursor(Cursor.HAND_CURSOR));
jla3.setToolTipText(종료);
jla3.addActionListener(this);
top.add(jla3);
JPanel center = new JPanel();
textArea = new JTextArea();
JScrollPane pane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
pane.setPreferredSize(new Dimension(492, 323));
center.add(pane);
frame.setJMenuBar(bar);
frame.getContentPane().add(top, North);
frame.getContentPane().add(center, Center);
frame.setSize(500, 400);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent e){
Object source = e.getSource();
if(source == oneItem1 || source == jla1){//열기 메뉴
JFileChooser chooser = new JFileChooser();
int returnVal = chooser.showOpenDialog(frame);//showSaveDialog
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println(chooser.getSelectedFile().getName());
}
}
else if(source == oneItem2 || source == jla3){//종료 메뉴
System.exit(1);
}
else if(source == twoItem1 || source == jla2){//지우기 메뉴
textArea.setText();
}
}
public static void main(String saa[]){
new Edit_Form();
}
}
=================================================================
여기서 setOpaque 메서드를 사용해서
투명하게 한다음 버튼이미지를 넣으면
이미지 그대로 나타난다고 하던데 ..
어떻게 해야하는건가요?
동그란 이미지를 넣으면 버튼고유의 네모난 모양이 아닌
그 이미지 그대로인 동그랗게 넣고 싶은데
어떻게 해야하나요??
도와주세요 ㅠ ㅠ