コード例 #1
0
ファイル: fieldT.java プロジェクト: keispace/2048puzzle
	public static void Field1(){
		fieldT.Label();
		fieldT.panel();
		f1.setSize(400, 400);
		
		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); // 화면 픽셀 계산
		Dimension frm = f1.getSize();//창 크기 계산

		int xpos = (int)(screen.getWidth() / 2 - frm.getWidth() / 2); // 창 중앙 위치 계산
		int ypos = (int)(screen.getHeight() / 2 - frm.getHeight() / 2);


		f1.setLayout(new GridLayout(4, 4));// 프레임 레이아웃
		f1.setBackground(Color.cyan); //프레임 배경
		f1.addWindowListener(new WEventHandler());
		f1.addKeyListener(new KEventHandler());
		f1.setResizable(false);
		for(int i =0;i<4;i++){
			for(int j=0;j<4;j++){
				f1.add(p[i][j]);
			}
		}
		f1.setLocation(xpos, ypos);
		f1.setVisible(true);
	}
コード例 #2
0
ファイル: jogl.java プロジェクト: jpmaligne/Jogl
  public static void main(String[] args) {
    GLProfile glp = GLProfile.getDefault();
    GLCapabilities caps = new GLCapabilities(glp);
    GLCanvas canvas = new GLCanvas(caps);
    cube unCube = new cube();
    canvas.addGLEventListener(unCube);
    Frame frame = new Frame("AWT Window Test");
    FPSAnimator anim = new FPSAnimator(canvas, 60);
    anim.start();
    frame.setSize(400, 400);
    frame.add(canvas);
    frame.setVisible(true);

    frame.addKeyListener(
        new KeyListener() {

          @Override
          public void keyPressed(KeyEvent e) {
            // TODO Auto-generated method stub
            int keyCode = e.getKeyCode();
            unCube.handleKeyPress(keyCode); // Here is the handleKeyPress function's call
            frame.add(canvas);
          }

          @Override
          public void keyReleased(KeyEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void keyTyped(KeyEvent e) {
            // TODO Auto-generated method stub

          }
        });

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }
コード例 #3
0
  /**
   * Construct a {@link LabelControlKeyboard} to parse keypresses and generate servo commands.
   *
   * @param out Node to send {@link ImageData}s to.
   */
  public LabelControlKeyboard(final Node out) {
    super(out);
    System.out.println("Initializing LabelControlKeyboard");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            frame.setVisible(false);
          }
        });

    frame.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            // System.out.println("Keyboard: key pressed");
            switch (e.getKeyCode()) {
              case KeyEvent.VK_UP:
                {
                  System.out.println("LabelControlKeyboard: time between sends up");
                  out.process(ImageDataManip.create(Command.TIME_UP, 0));
                  break;
                }
              case KeyEvent.VK_DOWN:
                {
                  System.out.println("LabelControlKeyboard: time between sends down");
                  out.process(ImageDataManip.create(Command.TIME_DOWN, 0));
                  break;
                }
              default:
                {
                }
            }
          }
        });
    frame.setLayout(new GridLayout(3, 1));
    frame.add(new java.awt.Label("LABEL CONTROLS:  "));
    frame.add(new java.awt.Label("Increase time: Arrow Up"));
    frame.add(new java.awt.Label("Decrease time: Arrow Down"));
    frame.pack();
    frame.setVisible(true);
  }
コード例 #4
0
ファイル: VlcPlayer.java プロジェクト: vyloy/lnvc
  /** Creates new form VlcPlayer */
  public VlcPlayer() {
    vlcPlayerPanel = this;
    initComponents();
    positionSlider.setValue(0);
    mediaPlayerComponent = new MyEmbeddedMediaPlayerComponent();
    add(mediaPlayerComponent, BorderLayout.CENTER);

    MyMediaPlayerEventAdater mediaPlayerEventAdapter =
        new MyMediaPlayerEventAdater() {

          @Override
          public void finished(MediaPlayer mediaPlayer) {
            super.finished(mediaPlayer);
            stopButton.setEnabled(false);
            playButton.setEnabled(true);
            pauseButton.setEnabled(false);
            skipPreviousButton.setEnabled(false);
            skipNextButton.setEnabled(false);
            fullScreenButton.setEnabled(false);
            pauseButton.setText("暂停");
            pauseButton.setIcon(
                new javax.swing.ImageIcon(
                    getClass()
                        .getResource(
                            "/com/lorent/common/resource/images/media-playback-pause-8.png")));
          }

          @Override
          public void paused(MediaPlayer mediaPlayer) {
            super.paused(mediaPlayer);
            pauseButton.setText("继续");
            pauseButton.setIcon(
                new javax.swing.ImageIcon(
                    getClass()
                        .getResource(
                            "/com/lorent/common/resource/images/media-playback-start-8.png")));
          }

          @Override
          public void playing(MediaPlayer mediaPlayer) {
            super.playing(mediaPlayer);
            playButton.setEnabled(false);
            stopButton.setEnabled(true);
            pauseButton.setEnabled(true);
            skipPreviousButton.setEnabled(true);
            skipNextButton.setEnabled(true);
            fullScreenButton.setEnabled(true);
            pauseButton.setText("暂停");
            pauseButton.setIcon(
                new javax.swing.ImageIcon(
                    getClass()
                        .getResource(
                            "/com/lorent/common/resource/images/media-playback-pause-8.png")));
          }

          @Override
          public void stopped(MediaPlayer mediaPlayer) {
            super.stopped(mediaPlayer);
            stopButton.setEnabled(false);
            playButton.setEnabled(true);
            pauseButton.setEnabled(false);
            skipPreviousButton.setEnabled(false);
            skipNextButton.setEnabled(false);
            fullScreenButton.setEnabled(false);
            pauseButton.setText("暂停");
            pauseButton.setIcon(
                new javax.swing.ImageIcon(
                    getClass()
                        .getResource(
                            "/com/lorent/common/resource/images/media-playback-pause-8.png")));
          }

          @Override
          public void positionChanged(MediaPlayer mediaPlayer, float newPosition) {
            super.positionChanged(mediaPlayer, newPosition);

            final float temp = newPosition;

            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    int position = (int) (temp * 1000.0f);
                    //						log.info("positionChanged:  oldposition: "+mediaPlayerComponent
                    //								.getMediaPlayer().getPosition()+" newposition: "+temp);
                    positionSlider.setValue(position);
                    positionProgressBar.setValue(position);
                  }
                });
          }
        };

    mediaPlayerComponent.getMediaPlayer().addMediaPlayerEventListener(mediaPlayerEventAdapter);
    //		executorService.scheduleAtFixedRate(new UpdateRunnable(
    //				mediaPlayerComponent.getMediaPlayer()), 0L, 1L,
    //				TimeUnit.SECONDS);
    //		fullscreenWindow.setExtendedState(state)

    fullscreenWindow.setAlwaysOnTop(true);
    fullscreenWindow.setFocusable(true);
    fullscreenWindow.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent e) {
            log.info("fullscreenframe.mouseClicked");
          }
        });
    fullscreenWindow.addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowClosing(WindowEvent e) {
            mediaPlayerComponent.getMediaPlayer().setFullScreen(false);
          }
        });
    fullscreenWindow.addKeyListener(
        new KeyAdapter() {

          @Override
          public void keyPressed(KeyEvent e) {

            if (e.getID() == KeyEvent.KEY_PRESSED) {
              if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                if (fullscreenWindow.isVisible()) {
                  mediaPlayerComponent.getMediaPlayer().setFullScreen(false);
                }
              }
            }
          }
        });
    fullscreenWindow.setUndecorated(true);
    //		fullscreenDialog.setResizable(false);
    //
    //	GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(fullscreenframe);
  }