?
Solved

How can I make an extra button on the top-right of my form near border icons?

Posted on 2003-11-23
8
Medium Priority
?
315 Views
Last Modified: 2010-04-17
Hello Experts!
I want to add some new buttons near the border icons (Close, Minimize,maximaise-Restore) and want to add glyphs or bitmaps as an icon on them. First, how can this be done so that I can define events for theses button when the user clicks on them. Secondly, is it possible to define hints for these buttons? If Yes, Please How?
Best regards,
<Email addresss removed by GhostMod, CS Moderator>
0
Comment
Question by:eisgzm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
8 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 9806570
Which language?
0
 
LVL 2

Accepted Solution

by:
override_y2k earned 200 total points
ID: 9807387
If you are using java then you must use listeners.

After a button is created, you will add a listener to it. Eg,
b.addActionListener(listener_object);
When the button is clicked, a call is made to the actionPerformed method defined in the class of the listener object. An ActionEvent object is passed as a parameter to it.

Here is a simple example using awt that sets up a frame, adds buttons and labels , and also adds action listeners and window listeners.

import java.awt.*;
import java.awt.event.*;

public class FrameTest extends Frame implements ActionListener {

  private static final String HELLO = "Hello";
  private static final String GOODBYE = "Goodbye";
  private String message = HELLO;
  private Panel counterPanel;
  private Button counterButton;
  private Label counterLabel;

  public FrameTest() {
    super("HelloGoodbye");
    counterLabel = new Label(message);
    counterButton = new Button("Click me");
    counterButton.addActionListener(this);
    counterPanel = new Panel();
    BorderLayout b = new BorderLayout();//Predefined awt layout
    this.setLayout(b);
    counterPanel.add(counterLabel, BorderLayout.CENTER);
    counterPanel.add(counterButton, BorderLayout.SOUTH);
    this.add(counterPanel);
    addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);;
      }
    });
    pack();
    setVisible(true);
    this.setSize(300,200);
  }

  public void actionPerformed(ActionEvent e) {
    if(message.equals(HELLO)) {
      message = GOODBYE;
    } else {
      message = HELLO;
    }
    counterLabel.setText(message);
    }

  public static void main(final String[] args) {
    FrameTest app = new FrameTest();

  }

}


Regards.
0
 
LVL 2

Expert Comment

by:override_y2k
ID: 9812787
I also find it worrying that you have asked 3 questions and have not awarded points for any of them to the experts.

0
 
LVL 2

Expert Comment

by:override_y2k
ID: 10318078
All Parts of Question Were Answered
0
 
LVL 3

Expert Comment

by:Phoenixric
ID: 10936972
I agree with override y2k, dont we have some control regarding this matter; someone posting a question and experts spend time and efforts finding the solution, but some very inconsiderate one leaves their question seems that they dont care. Why? hard to give points? WEll, this is just an opinion. . "Just be considerate for someones effort" Besides this is an expert-exchange not a childs play.

Close this question and give points to override y2k -> All Parts of the Question were answered.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Progress
Starting up a Project
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question