Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JButton;
- import javax.swing.JEditorPane;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- public class a {
- public String building_1;
- public String building_2;
- public String building_3;
- public String building_4;
- public String building_5;
- public JEditorPane showPyr;
- private JFrame Pyramid;
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- a window = new a();
- window.Pyramid.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- public a() {
- initialize();
- }
- private void initialize() {
- Pyramid = new JFrame();
- Pyramid.setResizable(false);
- Pyramid.setTitle("Pyramid");
- Pyramid.setBounds(100, 100, 250, 200);
- Pyramid.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- Pyramid.getContentPane().setLayout(null);
- building_1 = " ***** ";
- building_2 = " ***** \n ****** ";
- building_3 = " *** \n ***** \n ****** ";
- building_4 = " * \n *** \n ***** \n ****** ";
- JButton btnNewButton = new JButton("Start");
- btnNewButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- start_build();
- }
- });
- btnNewButton.setBounds(62, 139, 122, 23);
- Pyramid.getContentPane().add(btnNewButton);
- showPyr = new JEditorPane();
- showPyr.setEditable(false);
- showPyr.setBounds(0, 0, 242, 128);
- Pyramid.getContentPane().add(showPyr);
- }
- public void start_build(){
- showPyr.setText("");
- try {
- Thread.sleep(1);
- showPyr.setText(building_1);
- Thread.sleep(1);
- showPyr.setText(building_2);
- Thread.sleep(1);
- showPyr.setText(building_3);
- Thread.sleep(1);
- showPyr.setText(building_4);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement