자바 단 추 를 누 르 면 다른 창 이 나타 납 니 다.
3004 단어 Java
LoginFrame.java:
package winRelation;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class LoginFrame extends JFrame {
JButton button = new JButton(" ");
class LoginOKAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, " !");
new MainFrame();
setVisible(false);
}
}
public LoginFrame(){
super();
this.setResizable(false);
this.setSize(new Dimension(300, 205));
this.setTitle(" ");
this.setLayout(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLocation(300, 200);
this.setVisible(true);
this.getContentPane().add(button, null);
button.setBounds(new Rectangle(111, 70, 78, 27));
button.addActionListener(new LoginOKAction());//
}
public static void main(String[] args) {
new LoginFrame();
}
}
MainFrame.java:
package winRelation;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JToolBar;
public class MainFrame extends JFrame{
private static final JDesktopPane DESKTOP_PANE = new JDesktopPane();
public MainFrame() {
super(" ");
setSize(640, 480);
//
JMenuBar menuBar = new JMenuBar();
this.setJMenuBar(menuBar);
JMenu menu1 = new JMenu(" 1");
JMenu menu101 = new JMenu(" 101");
JMenuItem menu10101 = new JMenuItem(" 10101");
JMenuItem menu102 = new JMenuItem(" 102");
menu102.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addIFame(new InternalFrame());
}
});
menu101.add(menu10101);
menu1.add(menu101);
menu1.add(menu102);
JMenu menu2 = new JMenu(" 2");
menuBar.add(menu1);
menuBar.add(menu2);
this.getContentPane().add(DESKTOP_PANE);
this.setVisible(true);
}
public static void addIFame(JInternalFrame iframe) { //
DESKTOP_PANE.add(iframe);
}
public static void main(String[] args) {
new MainFrame();
}
}
(MainFrame )InternalFrame.java:
package winRelation;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
public class InternalFrame extends JInternalFrame{
public InternalFrame() {
super();
setClosable(true);
setIconifiable(true);
setTitle(" ");
setBounds(50,50,400,300);
setVisible(true);
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
JPA + QueryDSL 계층형 댓글, 대댓글 구현(2)이번엔 전편에 이어서 계층형 댓글, 대댓글을 다시 리팩토링해볼 예정이다. 이전 게시글에서는 계층형 댓글, 대댓글을 구현은 되었지만 N+1 문제가 있었다. 이번에는 그 N+1 문제를 해결해 볼 것이다. 위의 로직은 이...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.