Custom controls changed

cusax-fix
Yana Stamcheva 20 years ago
parent 290659415c
commit b490cf4a10

@ -23,10 +23,8 @@ public class SIPCommButton extends JButton {
private Image iconImage;
private int iconRightShift = 0;
private int iconLeftShift = 0;
private Image pressedImage;
public SIPCommButton() {
super();
@ -61,7 +59,7 @@ public SIPCommButton(Image iconImage) {
this.setIcon(new ImageIcon(this.bgImage));
}
public SIPCommButton(Image bgImage, Image rolloverImage, Image iconImage) {
public SIPCommButton (Image bgImage, Image rolloverImage, Image iconImage) {
super();
this.iconImage = iconImage;
@ -74,6 +72,36 @@ public SIPCommButton(Image bgImage, Image rolloverImage, Image iconImage) {
this.setIcon(new ImageIcon(this.bgImage));
}
public SIPCommButton ( Image bgImage,
Image rolloverImage,
Image pressedImage,
Image iconImage) {
super();
this.iconImage = iconImage;
this.bgImage = bgImage;
this.bgRolloverImage = rolloverImage;
this.pressedImage = pressedImage;
this.setPreferredSize(new Dimension(this.bgImage.getWidth(null),
this.bgImage.getHeight(null)));
this.setIcon(new ImageIcon(this.bgImage));
}
public SIPCommButton(Image bgImage, Image rolloverImage) {
super();
this.bgImage = bgImage;
this.bgRolloverImage = rolloverImage;
this.setPreferredSize(new Dimension(this.bgImage.getWidth(null),
this.bgImage.getHeight(null)));
this.setIcon(new ImageIcon(this.bgImage));
}
public void paint(Graphics g) {
g.drawImage(this.bgImage, 0, 0, this);
@ -82,9 +110,7 @@ public void paint(Graphics g) {
g.drawImage(this.iconImage,
(this.bgImage.getWidth(null) -
this.iconImage.getWidth(null)) / 2 +
this.iconRightShift -
this.iconLeftShift,
this.iconImage.getWidth(null)) / 2,
(this.bgImage.getHeight(null) -
this.iconImage.getHeight(null)) / 2, this);
}
@ -98,13 +124,31 @@ public void paint(Graphics g) {
g.drawImage(this.iconImage,
(this.bgImage.getWidth(null) -
this.iconImage.getWidth(null)) / 2 +
this.iconRightShift -
this.iconLeftShift,
this.iconImage.getWidth(null)) / 2,
(this.bgImage.getHeight(null) -
this.iconImage.getHeight(null)) / 2, this);
}
}
if (this.getModel().isPressed()) {
if(this.pressedImage != null) {
g.drawImage(this.pressedImage, 0, 0, this);
}
else {
g.setColor(LookAndFeelConstants.CONTACTPANEL_LINES_COLOR);
g.drawImage(this.bgRolloverImage, 0, 0, this);
if (this.iconImage != null) {
g.drawImage(this.iconImage,
(this.bgImage.getWidth(null) -
this.iconImage.getWidth(null)) / 2 + 1,
(this.bgImage.getHeight(null) -
this.iconImage.getHeight(null)) / 2 + 1, this);
}
}
}
}
public Image getBgImage () {
@ -130,20 +174,4 @@ public Image getIconImage() {
public void setIconImage(Image iconImage) {
this.iconImage = iconImage;
}
public void setIconRightShift (int iconRightShift) {
this.iconRightShift = iconRightShift;
}
public void setIconLeftShift (int iconLeftShift) {
this.iconLeftShift = iconLeftShift;
}
public int getIconRightShift (int iconRightShift) {
return this.iconRightShift;
}
public int getIconLeftShift (int iconLeftShift) {
return this.iconLeftShift;
}
}

@ -9,33 +9,26 @@ public class StatusIcon extends BufferedImage {
private Image bgImage;
private Image iconImage;
private int rightShift = 0;
public StatusIcon (Image bgImage, Image iconImage) {
this (bgImage, iconImage, 0);
}
public StatusIcon ( Image bgImage,
Image iconImage,
int rightShift) {
Image iconImage) {
super( bgImage.getWidth(null) + rightShift,
super( bgImage.getWidth(null),
bgImage.getHeight(null),
BufferedImage.TYPE_4BYTE_ABGR);
this.bgImage = bgImage;
this.iconImage = iconImage;
this.rightShift = rightShift;
this.getGraphics().drawImage (this.bgImage, 0, 0, null);
if (this.iconImage != null){
int x = (this.bgImage.getWidth(null) -
this.iconImage.getWidth(null)) + rightShift;
this.iconImage.getWidth(null)) / 2;
int y = (this.bgImage.getHeight(null) -
this.iconImage.getHeight(null));
this.iconImage.getHeight(null)) / 2;
this.getGraphics().drawImage ( this.iconImage,
x,
@ -56,14 +49,4 @@ public StatusIcon (Image image) {
this.getGraphics().drawImage (this.bgImage, 0, 0, null);
}
public StatusIcon (Image image, int rightShift) {
super( image.getWidth(null) + rightShift,
image.getHeight(null),
BufferedImage.TYPE_4BYTE_ABGR);
this.bgImage = image;
this.getGraphics().drawImage (this.bgImage, 0, 0, null);
}
}

@ -27,22 +27,10 @@
public class StatusSelectorBox extends SIPCommButton
implements ActionListener{
private SIPCommButton button;
private JPopupMenu popup;
private Object[] items;
private final Image statusSelectorBg = LookAndFeelConstants.STATUS_SELECTOR_BOX;
private final int width = statusSelectorBg.getWidth(null);
private final int height = statusSelectorBg.getHeight(null);
private final int iconX = (this.width - 24) / 2;
private final int iconY = (this.height - 16) / 2;
public StatusSelectorBox(Object[] items, Status currentStatus) {
super( LookAndFeelConstants.STATUS_SELECTOR_BOX,

Loading…
Cancel
Save