Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.filoofox.main;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- public class Main extends JFrame {
- private JTextField txtfieldClicktext = new JTextField();
- private JLabel how_to_close = new JLabel();
- private JLabel how_to_close2 = new JLabel();
- private JLabel button_will_disappear = new JLabel();
- private JLabel clickstatus = new JLabel();
- private JLabel InsgesamtText = new JLabel();
- private JLabel showmenuText = new JLabel();
- private JLabel showclicksleft = new JLabel();
- private JLabel uebrigeclicks = new JLabel();
- private JLabel geklickt = new JLabel();
- private JLabel schongeklickt = new JLabel();
- private JButton Reset = new JButton();
- private JButton Rename = new JButton();
- private JButton closewindow = new JButton();
- private JButton b_howtoclose = new JButton();
- private JButton CLICK = new JButton();
- private JButton geklicktswitch = new JButton();
- private JToggleButton Insgesamt = new JToggleButton();
- private JToggleButton showmenu = new JToggleButton();
- private JToggleButton uebrig = new JToggleButton();
- boolean geklicktbool;
- boolean uebrigshown;
- boolean menu;
- boolean clickgesamt;
- int CloseOffset = 250;
- int ButtonMenuOffset = 30;
- int clicks;
- int clicks_left;
- public Main() {
- super();
- geklicktbool = true;
- uebrigshown = true;
- menu = true;
- clickgesamt = true;
- setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- int frameWidth = 1081;
- int frameHeight = 737;
- setSize(frameWidth, frameHeight);
- Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
- int x = (d.width - getSize().width) / 2;
- int y = (d.height - getSize().height) / 2;
- setLocation(x, y);
- setTitle("Viel Spaß");
- setResizable(true);
- Container cp = getContentPane();
- cp.setLayout(null);
- clicks = 0;
- clicks_left = 100000;
- menu = true;
- //text
- how_to_close.setText("Um dieses Fenster zu schließen, musst du den TaskManager öffnen!");
- how_to_close2.setText("Dies ist dazu da, dass du nicht ausversehen das Fenster schließt!");
- button_will_disappear.setText("Wenn du diesen Knopf drückst wird diese info und der knopf entfernt!");
- showmenuText.setText("Show-Menu:");
- CLICK.setText("Click!");
- InsgesamtText.setText("Insgesamt:");
- showclicksleft.setText("Übrig:");
- uebrigeclicks.setText("Du musst noch " + clicks_left + " mal Klicken!");
- clickstatus.setText(clicks + " || " + clicks_left);
- geklickt.setText("Geklickt:");
- schongeklickt.setText("Du hast schon " + clicks + " mal geklickt!");
- clickstatus.setFont(new Font("@Adobe Gothic Std B", Font.BOLD, 40));
- InsgesamtText.setFont(new Font("@Adobe Gothic Std B", Font.BOLD, 12));
- showmenuText.setFont(new Font("@Adobe Gothic Std B", Font.BOLD, 18));
- button_will_disappear.setFont(new Font("@Adobe Gothic Std B", Font.PLAIN, 10));
- CLICK.setFont(new Font("@Adobe Gothic Std B", Font.BOLD + Font.ITALIC, 60));
- InsgesamtText.setFont(new Font("@Adobe Gothic Std B", Font.BOLD, 20));
- showclicksleft.setFont(new Font("@Adobe Gothic Std B", Font.BOLD, 20));
- uebrigeclicks.setFont(new Font("@Adobe Gothic Std B", Font.BOLD, 30));
- geklickt.setFont(new Font("@Adobe Gothic Std B", Font.BOLD, 20));
- schongeklickt.setFont(new Font("@Adobe Gothic Std B", Font.BOLD, 40));
- how_to_close.setBounds(385 +CloseOffset, -135, 700, 300);
- how_to_close2.setBounds(402 +CloseOffset, -120, 700, 300);
- clickstatus.setBounds(420, 614, 414, 79);
- button_will_disappear.setBounds(390 +CloseOffset,-70,700,300);
- InsgesamtText.setBounds(1, 46, 110, 39);
- showmenuText.setBounds(1, -2, 110, 39);
- showclicksleft.setBounds(1, 94, 110, 39);
- uebrigeclicks.setBounds(290, 536, 7000, 79);
- geklickt.setBounds(1, 140, 110, 39);
- schongeklickt.setBounds(270, 456, 700, 79);
- cp.add(schongeklickt);
- cp.add(how_to_close);
- cp.add(how_to_close2);
- cp.add(button_will_disappear);
- cp.add(CLICK);
- cp.add(clickstatus);
- cp.add(showmenuText);
- cp.add(InsgesamtText);
- cp.add(showclicksleft);
- cp.add(uebrigeclicks);
- cp.add(geklickt);
- //ende text
- //textfields
- txtfieldClicktext.setText("Ändere den Text von dem Click-Button!");
- txtfieldClicktext.setBounds(2, 650, 220, 20);
- cp.add(txtfieldClicktext);
- //ende textfields
- //buttons
- b_howtoclose.setText("VERSTANDEN!");
- Rename.setText("Rename");
- Reset.setText("Reset");
- Insgesamt.setText("ON");
- showmenu.setText("ON");
- uebrig.setText("ON");
- geklicktswitch.setText("ON");
- b_howtoclose.setBounds(490 +CloseOffset,40,120,30);
- closewindow.setBounds(1034,0,30,30);
- Rename.setBounds(3, 671, 105, 25);
- Reset.setBounds(116, 671, 105, 25);
- CLICK.setBounds(326 , 211, 411, 209);
- uebrig.setBounds(111+ButtonMenuOffset, 100, 55, 33);
- Insgesamt.setBounds(111 +ButtonMenuOffset, 50, 57, 33);
- showmenu.setBounds(110 +ButtonMenuOffset, 2, 55, 33);
- geklicktswitch.setBounds(111+ButtonMenuOffset, 150, 55, 33);
- cp.add(b_howtoclose);
- cp.add(Rename);
- cp.add(Reset);
- cp.add(CLICK);
- cp.add(Insgesamt);
- cp.add(showmenu);
- cp.add(uebrig);
- cp.add(geklicktswitch);
- b_howtoclose.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- how_to_close.setBounds(0,0,0,0);
- how_to_close2.setBounds(0,0,0,0);
- button_will_disappear.setBounds(0,0,0,0);
- b_howtoclose.setBounds(0,0,0,0);
- cp.add(closewindow);
- }
- });
- //ende how to close button
- //Close button
- closewindow.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- System.exit(0);
- }
- });
- //ende Close button
- //rename ClickButton
- Rename.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- CLICK.setText(txtfieldClicktext.getText());
- }
- });
- // ende rename ClickButton
- //ResetName
- Reset.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- CLICK.setText("Click! ");
- }
- });
- //ende ResetName
- //Click
- CLICK.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- clicks_left = clicks_left - 1;
- clicks = clicks +1;
- clickstatus.setText(clicks + " || " + clicks_left);
- uebrigeclicks.setText("Du musst noch " + clicks_left + " mal Klicken!");
- schongeklickt.setText("Du hast schon " + clicks + " mal geklickt!");
- }
- });
- //ende Click
- //toggle Insgesamt
- Insgesamt.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (clickgesamt == true) {
- clickgesamt = false;
- Insgesamt.setText("OFF");
- Insgesamt.setForeground(Color.RED);
- clickstatus.setBounds(0,0,0,0);
- } else if (clickgesamt == false) {
- clickgesamt = true;
- Insgesamt.setText("ON");
- Insgesamt.setForeground(Color.GREEN);
- clickstatus.setBounds(320, 614, 414, 79);
- }
- }});
- //ende toggle Insgesamt
- //show menu
- showmenu.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (menu == true) {
- menu = false;
- showmenu.setText("OFF");
- showmenu.setForeground(Color.RED);
- } else if (clickgesamt == false) {
- menu = true;
- showmenu.setText("ON");
- showmenu.setForeground(Color.GREEN);
- }
- }
- });
- //ende show menu
- //übrig
- uebrig.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (uebrigshown == true) {
- uebrigshown = false;
- uebrig.setText("OFF");
- uebrig.setForeground(Color.RED);
- uebrigeclicks.setBounds(0,0,0,0);
- } else if (uebrigshown == false) {
- uebrigshown = true;
- uebrig.setText("ON");
- uebrig.setForeground(Color.GREEN);
- }
- }
- });
- //ende übrig
- //geklickt
- geklicktswitch.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- if (geklicktbool == true) {
- geklicktbool = false;
- geklicktswitch.setText("OFF");
- geklicktswitch.setForeground(Color.RED);
- schongeklickt.setBounds(0,0,0,0);
- } else if (geklicktbool == false) {
- geklicktbool = true;
- geklicktswitch.setText("ON");
- geklicktswitch.setForeground(Color.GREEN);
- schongeklickt.setBounds(270, 456, 700, 79);
- }
- }
- });
- //ende geklickt
- setVisible(true);
- } // end of public rvd
- // Anfang Methoden
- public static void main(String[] args) {
- new Main();
- } // end of main
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement