Autor | Beitrag 39706 - 39720 |
---|---|
TokeeSo 24.6.07, 14:16 | jo das stimmt isch au besser so jez isch jo electro und house so in |
heimdallSo 24.6.07, 14:18 | oder das; http://www.youtube.com/watch?v=0Ujl-wr1Yuo&mode=related&search= |
ArkinaSo 24.6.07, 14:19 | electro mag ich gar nid... house isch au bitz besser worde, friehner hanis nid guet gfunde |
VentiSupportSo 24.6.07, 14:19 | soo ich wünsch euch ein ich gang go b-balle 1 mal bearbeitet, zuletzt So 24.6.07, 14:19 |
ArkinaSo 24.6.07, 14:20 | ade |
UrichSo 24.6.07, 14:21 | bb |
heimdallSo 24.6.07, 14:22 | so und ich go game. schalom! |
holysmokeSo 24.6.07, 14:25 | juhu es lauft ![]() // AWTDemo.java package gui; import java.awt.*; import java.awt.event.*; import java.util.*; public class AWTDemo extends Frame implements ActionListener { // attributes Button btnShow; Button btnHide; Frame clickMeFrame; Label lblClickMe; Random random; boolean hit; Frame topLebelFrame = this; int tryCount; //construvtors AWTDemo(){ this.initFrame(); } AWTDemo(String name){ super(name); this.initFrame(); } void initFrame(){ //set appearance this.setSize(300, 200); this.setLocation(200, 300); this.setBackground(Color.lightGray); //enable closing from top level window this.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent me){ System.exit(0); } }); //add component this.add(getPnlSouth(), BorderLayout.SOUTH); this.add(getLblTitle(), BorderLayout.NORTH); this.add(getPnlCenter(), BorderLayout.CENTER); // crate another top level window clickMeFrame = getClickMeFrame(); //set top level frame visible this.setVisible(true); // init other attributes hit = false; tryCount = 0; random = new Random(System.currentTimeMillis()); } protected Label getLblTitle() { Label l = new Label("Frame mit Panels und Layout-Managern" ![]() return l; } protected Button getBtnHide(){ Button b = new Button("Hide" ![]() b.addActionListener(this); return b; } protected Button getBtnShow(){ Button b = new Button("Show" ![]() b.addActionListener(this); return b; } protected Panel getPnlSouth() { Panel p = new Panel(); this.btnShow = getBtnShow(); this.btnShow.addActionListener(this); p.add(btnShow); this.btnHide = getBtnHide(); this.btnHide.addActionListener(this); p.add(btnHide); return p; } protected Panel getPnlCenter(){ // create a panel 2-dim array Panel[][] pgrid = new Panel[2][2]; pgrid[0][0] = new Panel(); pgrid[0][0].setBackground(Color.blue); pgrid[1][0] = new Panel(); pgrid[1][0].setBackground(Color.cyan); pgrid[0][1] = new Panel(); pgrid[0][1].setBackground(Color.green); pgrid[1][1] = new Panel(); pgrid[1][1].setBackground(Color.magenta); //create a panel to hold all pgrid panels Panel p = new Panel(); p.setBackground(Color.lightGray); p.setLayout(new GridLayout(2,2)); //add panels of 2-dim arr to the grid layout panel p.add(pgrid[0][0]); p.add(pgrid[1][0]); p.add(pgrid[0][1]); p.add(pgrid[1][1]); return p; } Frame getClickMeFrame(){ Frame f = new Frame(); f.setBounds(500,200, 500,300); f.setBackground(Color.yellow); f.setLayout(null); lblClickMe = new Label("click me ![]() ![]() lblClickMe .setBounds(40, 40, 80, 20); lblClickMe.addMouseListener(new MouseCatcher()); f.add(lblClickMe); f.setVisible(false); return f; } public void actionPerformed(ActionEvent ae){ if(ae.getSource() == btnShow){ clickMeFrame.setVisible(true); }else if(ae.getSource() == btnHide){ clickMeFrame.setVisible(false); } } public class MouseCatcher extends MouseAdapter{ public void mouseClicked(MouseEvent me){ if(hit) return; me.getComponent().getParent().setBackground(Color.magenta); me.getComponent().setBackground(Color.green); Label lbl = (Label) me.getComponent(); lbl.setText("GETROFFEN" ![]() Frame f = new Frame(); f.setLocation(300, 500); f.setSize(400, 100); f.setBackground(Color.lightGray); Label msg = new Label("Sie haben "+tryCount+" Versuche gebraucht"+ " ... Das Ende kommt in 5 Sekunden..." ![]() msg.setBackground(Color.yellow); f.add(msg); f.setVisible(true); hit = true; try{ Thread.sleep(5000); }catch (InterruptedException ie){ } System.exit(0); } public void mouseEntered(MouseEvent me) { if(hit) return; int width = me.getComponent().getParent().getWidth(); int height = me.getComponent().getParent().getHeight(); int newX; int newY; newX = random.nextInt(width- me.getComponent().getWidth()); newY = random.nextInt(height- 2 * me.getComponent().getHeight()) + me.getComponent().getHeight(); me.getComponent().setBackground(Color.cyan); try{ Thread.sleep(random.nextInt(200)); } catch (InterruptedException ie){ } me.getComponent().setLocation(newX, newY); System.out.println("width = "+ width); System.out.println("height = "+ height); System.out.println("newX = "+ newX); System.out.println("newY = "+ newY); System.out.println("hit = "+ hit); tryCount++; } public void mouseExited(MouseEvent me){ me.getComponent().setBackground(Color.lightGray); me.getComponent().getParent().setBackground(Color.white); } } public static void main(String[] args){ new AWTDemo("My first Frame" ![]() } } |
ArkinaSo 24.6.07, 14:26 | was söll das si? |
TokeeSo 24.6.07, 14:27 | spam nid umä holy ![]() |
holysmokeSo 24.6.07, 14:27 | e biispiel, und wemme uf "Show" klickt chunt e neus fänster wode muesch versueche ufe text klicke, de versuecht dir aber uszwiiche ![]() ![]() |
marciSo 24.6.07, 14:28 | oha woni scho "java" gseh ha ischs mr schlecht worde![]() ![]() ![]() |
ArkinaSo 24.6.07, 14:29 | ich chum do nid druss ![]() für mi isch das bahnhof |
holysmokeSo 24.6.07, 14:29 | i verstands au numme mit kopfweh, java isch ganz und garnit mini stärki ![]() |
ArkinaSo 24.6.07, 14:30 | was isch denn dini stärki? ![]() |