Solved

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

Posted on 2003-11-23
8
313 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 50 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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Progress

717 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