public ButtonDemo() {
    // Set the background color of messagePanel
    messagePanel.setBackground(Color.white);

    // Create Panel jpButtons to hold two Buttons "<=" and "right =>"
    JPanel jpButtons = new JPanel();
    jpButtons.add(jbtLeft);
    jpButtons.add(jbtRight);

    // Set keyboard mnemonics
    jbtLeft.setMnemonic('L');
    jbtRight.setMnemonic('R');

    // Set icons and remove text
    // jbtLeft.setIcon(new ImageIcon("image/left.gif"));
    // jbtRight.setIcon(new ImageIcon("image/right.gif"));
    // jbtLeft.setText(null);
    // jbtRight.setText(null);

    // Set tool tip text on the buttons
    jbtLeft.setToolTipText("Move message to left");
    jbtRight.setToolTipText("Move message to right");

    // Place panels in the frame
    setLayout(new BorderLayout());
    add(messagePanel, BorderLayout.CENTER);
    add(jpButtons, BorderLayout.SOUTH);

    // Register listeners with the buttons
    jbtLeft.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            messagePanel.moveLeft();
          }
        });
    jbtRight.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            messagePanel.moveRight();
          }
        });
  }
Example #2
2
  public DisplayClock() {
    // Create an analog clock for the current time
    StillClock clock = new StillClock();

    // Display hour, minute, and seconds in the message panel
    MessagePanel messagePanel =
        new MessagePanel(clock.getHour() + ":" + clock.getMinute() + ":" + clock.getSecond());
    messagePanel.setCentered(true);
    messagePanel.setForeground(Color.blue);
    messagePanel.setFont(new Font("Courie", Font.BOLD, 16));

    // Add the clock and message panel to the frame
    add(clock);
    add(messagePanel, BorderLayout.SOUTH);
  }
 private void showMessage(String text) {
   myLoadingPanel.stopLoading();
   ((CardLayout) getLayout()).show(this, MESSAGE_LAYER);
   myMessagePanel.setText(text);
 }
Example #4
0
	public TestFontMetrics () {
		MessagePanel messagePanel = new MessagePanel ("");
      
		messagePanel.setFont(new Font("SansSerif", Font.BOLD, 20));
      
		messagePanel.setCentered(true);
      
		getContentPane().add(messagePanel);
		getContentPane().add(jbtRefresh);
				
	        //ButtonListener btListener = new ButtonLIstener();

		//jbtRefresh.addActionListener(btListener);
	}