disable call and hangup buttons, and buttons in chat contact panel.

cusax-fix
Yana Stamcheva 20 years ago
parent f9cd6dbd06
commit 48301a03f2

@ -6,10 +6,17 @@
*/
package net.java.sip.communicator.impl.gui.lookandfeel;
import javax.swing.GrayFilter;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.IconUIResource;
import javax.swing.plaf.metal.MetalLookAndFeel;
import net.java.sip.communicator.impl.gui.utils.LightGrayFilter;
/**
* The default SIP-Communicator look&feel.
*
@ -60,4 +67,12 @@ protected void initClassDefaults(UIDefaults table) {
};
table.putDefaults(uiDefaults);
}
public Icon getDisabledIcon(JComponent component, Icon icon) {
if (icon instanceof ImageIcon) {
return new IconUIResource(new ImageIcon(LightGrayFilter.
createDisabledImage(((ImageIcon)icon).getImage())));
}
return null;
}
}

@ -4,7 +4,6 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.main;
import java.awt.BorderLayout;
@ -94,7 +93,11 @@ private void init() {
this.minimizeButtonPanel.add(restoreButton);
this.add(minimizeButtonPanel,BorderLayout.SOUTH);
this.add(minimizeButtonPanel,BorderLayout.SOUTH);
//Disable all unused buttons.
this.callButton.setEnabled(false);
this.hangupButton.setEnabled(false);
}
public JComboBox getPhoneNumberCombo() {

@ -12,7 +12,6 @@
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.GrayFilter;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.plaf.IconUIResource;
@ -20,6 +19,7 @@
import net.java.sip.communicator.impl.gui.utils.AntialiasingManager;
import net.java.sip.communicator.impl.gui.utils.Constants;
import net.java.sip.communicator.impl.gui.utils.ImageLoader;
import net.java.sip.communicator.impl.gui.utils.LightGrayFilter;
/**
* @author Yana Stamcheva
@ -96,14 +96,23 @@ public SIPCommButton(Image bgImage, Image rolloverImage) {
public void paintComponent(Graphics g) {
AntialiasingManager.activateAntialiasing(g);
if(this.bgImage != null)
g.drawImage(this.bgImage, 0, 0, this);
if(this.bgImage != null){
// If there's no icon, we make grey the backgroundImage
// when disabled.
if(this.iconImage == null && !isEnabled()){
Image disabledImage = new ImageIcon(
LightGrayFilter.createDisabledImage(bgImage)).getImage();
g.drawImage(disabledImage, 0, 0, this);
}
else
g.drawImage(this.bgImage, 0, 0, this);
}
if (this.iconImage != null) {
if (this.iconImage != null) {
if(!isEnabled()){
this.iconImage = new ImageIcon(
GrayFilter.createDisabledImage(iconImage)).getImage();
this.iconImage = new ImageIcon(LightGrayFilter
.createDisabledImage(iconImage)).getImage();
}
// draw the button icon depending the current button layout
if (this.iconLayout.equals(SIPCommButton.CENTER_ICON_LAYOUT))

@ -109,6 +109,10 @@ public void init(){
this.add(personPhotoLabel, BorderLayout.WEST);
this.add(mainPanel, BorderLayout.CENTER);
//Disabled all unused buttons.
this.callButton.setEnabled(false);
this.infoButton.setEnabled(false);
this.sendFileButton.setEnabled(false);
}
public void paintComponent(Graphics g){

@ -0,0 +1,40 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.utils;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageProducer;
import javax.swing.GrayFilter;
/**
* An image filter that "disables" an image by turning
* it into a grayscale image, and brightening the pixels
* in the image. Used by buttons to create an image for
* a disabled button. Creates a more brighter image than
* the javax.swing.GrayFilter.
*
* @author Yana Stamcheva
*/
public class LightGrayFilter extends GrayFilter {
public LightGrayFilter(boolean b, int p) {
super(b, p);
}
/**
* Creates a disabled image
*/
public static Image createDisabledImage (Image i) {
LightGrayFilter filter = new LightGrayFilter(true, 65);
ImageProducer prod = new FilteredImageSource(i.getSource(), filter);
Image grayImage = Toolkit.getDefaultToolkit().createImage(prod);
return grayImage;
}
}
Loading…
Cancel
Save