mark koorevaar

Greenhorn
+ Follow
since Jul 31, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by mark koorevaar

For what it's worth (posts are old but maybe it will help others with the same current problem).

My TitledMnemonicBorder accepts the title, focus component and mnemonic. The mnemonic will be displayed and when invoked the registered action will be performed which will result in requesting the focus for the focusableComponent.

public class TitledMnemonicBorder extends TitledBorder {

private char mnemonic;
private JComponent focusableComponent;


/**
* Constructor.
*
* @param string The title
* @param mnemonic The mnemonic to be shown
* @param focusableComponent The component that will receive the focus when the
* mnemonic is invoked
*/
public TitledMnemonicBorder(String string, char mnemonic, JComponent focusableComponent) {
super(string);
this.mnemonic = mnemonic;
this.focusableComponent = focusableComponent;
}

@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
super.paintBorder(c, g, x, y, width, height);
.. (see TitledBorder code)

// registers the mnemonic and its action to the component
jc.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
focusableComponent.requestFocus();
}
}, KeyStroke.getKeyStroke("alt "+ Character.toUpperCase(mnemonic)),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

.. (see TitledBorder code)
SwingUtilities2.drawStringUnderlineCharAt(jc, g, getTitle(),
getTitle().indexOf(mnemonic), textLoc.x, textLoc.y);

.. (see TitledBorder code)
}

}
15 years ago
I am confronted with a problem for wich i can't come up with the most efficient solution. I am trying to create a buttonpanel according to a windows traybar with the application buttons. When placing a button on the panel if there is less space left to display the full text of the button, the buttons need to be resized and an elips (...) is shown.
Has anyone encountered this problem and has a working solution for it ?

Thnx in advance !!
19 years ago