Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
?
320 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Make the most of your online learning experience.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

604 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