ActionListener 에 관해 질문좀요~
연체리
/* 컴파일 ,실행 다 되거든요..(소스를 부분 가져온거라서 오류날수도있습니다.)
근데 시간표 버튼을 클릭햇을경우Note.java 란 파일이 안나타납니다..ㅠ.ㅠ
왜 안되는지.. 좀알려주세요... (메인화면이 나타나있는상태에서 시간표 버튼을 클릭하면
새로운창(메모장)이 열리는 것임)
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;public class Main extends JPanel implements ActionListener{
static JFrame jf;
static JPanel top,left;
JButtonschedule;
JPanel left_cen, left_cen_top;Main(){
setLayout(new BorderLayout());
left=new JPanel();
left.setLayout(new BorderLayout());
left_cen=new JPanel();
left_cen.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),메뉴선택,0,0,new Font(Serif,Font.LAYOUT_LEFT_TO_RIGHT,12)),BorderFactory.createEmptyBorder(1,1,1,1)));
left_cen.setLayout(new BorderLayout());
left_cen_top=new JPanel();
left_cen_top.setLayout(new GridLayout(2,1));schedule=new JButton( 시 간 표 );
schedule.setFont(new Font(고딕체,Font.BOLD,13));
schedule.addActionListener(this);
left_cen_top.add(schedule);
left_cen.add(left_cen_top,North);left.add(left_cen,Center);
add(left,Center);// 이벤 부분...
public void actionPerformed(ActionEvent ae){
if(ae.getSource()==schedule){
new Note(); //Note.java 파일은 메모장이거든요.. 제폴더에 Main.java 랑 같이있습니다.
}/* 메인부분 */
public static void main(String[] args){
JFrame.setDefaultLookAndFeelDecorated(true);
jf=new JFrame(AAAA);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setContentPane(new Main());
jf.setSize(1027,768);
jf.setVisible(true);
}
}
-
한국드립
그리고 jf랑 top,left 를 static으로 잡아놓은 이유가 뭔지요..
-
아메
new Note(); 바로위에다가 로그 달아보시고 거기까지 간다면 에러의 원인은 Note클래스에 있는거지요..