|
|
|
ผมสร้างไว้หลายframe แต่ต้องการให้มันปิด frame เก่า เวลาเปิด frame ใหม่ |
|
|
|
|
|
|
|
คือผมต้องการกดปุ่ม AddData แล้วขึ้นอีกหน้า แต่มันไม่ยอมปิดหน้า MainWindow ลง
ลองพวก .closeFrame() ก็ error[color=black][list]
Code (Java)
package UIClass;
import java.util.Date;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
import javax.swing.JLabel;
import java.awt.Label;
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.event.CaretListener;
import javax.swing.event.CaretEvent;
import java.awt.event.InputMethodListener;
import java.awt.event.InputMethodEvent;
import javax.swing.JButton;
import javax.swing.JOptionPane;
//import BussinessClass.DialogMessge;
public class MainWindow {
private JFrame frame;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MainWindow window = new MainWindow();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public MainWindow() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JButton btnSearchData = new JButton("SearchData");
btnSearchData.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
SearchData SD = new SearchData();
SD.main(null);
}
});
btnSearchData.setBounds(88, 134, 101, 23);
frame.getContentPane().add(btnSearchData);
JButton btnExit = new JButton("Exit");
btnExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
btnExit.setBounds(176, 206, 101, 23);
frame.getContentPane().add(btnExit);
JButton btnAddData = new JButton("AddData");
btnAddData.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
AddData AD= new AddData();
AD.main(null);
}
});
btnAddData.setBounds(88, 68, 101, 23);
frame.getContentPane().add(btnAddData);
JButton btnDeleteData = new JButton("DeleteData");
btnDeleteData.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DeleteData DD = new DeleteData();
DD.main(null);
}
});
btnDeleteData.setBounds(244, 68, 101, 23);
frame.getContentPane().add(btnDeleteData);
JButton btnEdotData = new JButton("EditData");
btnEdotData.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
EditData ED = new EditData();
ED.main(null);
}
});
btnEdotData.setBounds(244, 134, 101, 23);
frame.getContentPane().add(btnEdotData);
}
}
Tag : Java, JAVA
|
|
|
|
|
|
Date :
2014-01-23 01:35:59 |
By :
bank_undersky |
View :
2371 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (Java)
this.setVisible(false);
|
|
|
|
|
Date :
2014-01-23 09:30:16 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|