I'm trying to create a MessageBox Creator.
I Have tried to hide the Creator when the Message Box Opens and then show when the Message Box Closes. I am using the following plugins for Eclipse Neon:
- WindowBuilder
- Swing Designer
to help me create the program.
A similar one is here but it did not help: Click Me
The source code is here:
package org.us.me.****.messagebox.creator;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JProgressBar;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class MessageBoxCreator {
private JFrame frmD;
private JTextField txtMessageGoesHere;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MessageBoxCreator window = new MessageBoxCreator();
window.frmD.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public MessageBoxCreator() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmD = new JFrame();
frmD.setTitle("MessageBox: Creator");
frmD.setBounds(100, 100, 260, 113);
frmD.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmD.getContentPane().setLayout(null);
JTextField MessageBox = new JTextField();
MessageBox.setText("Message goes here...");
MessageBox.setBounds(10, 11, 222, 20);
frmD.getContentPane().add(MessageBox);
MessageBox.setColumns(10);
JButton btnGenerate = new JButton("Generate");
btnGenerate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, MessageBox);
}
});
btnGenerate.setBounds(10, 42, 86, 23);
frmD.getContentPane().add(btnGenerate);
}
}
Please Help.