Allows to set an image background to main windows.

cusax-fix
Yana Stamcheva 18 years ago
parent c310e2f702
commit d6230b577e

@ -107,4 +107,4 @@ splashScreenTextColor=FFFFFF
splashScreenTitleColor=EAEAEA
# Background color for the contact list background.
contactListBackground=EFEFEF
contactListBackground=FFFFFF

Binary file not shown.

Before

Width:  |  Height:  |  Size: 751 B

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 916 B

After

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

@ -84,10 +84,12 @@ public SIPCommButton(Image bgImage, Image rolloverImage) {
*
* @param g The Graphics object.
*/
public void paintComponent(Graphics g) {
public void paintComponent(Graphics g)
{
AntialiasingManager.activateAntialiasing(g);
if (this.bgImage != null) {
if (this.bgImage != null)
{
// If there's no icon, we make grey the backgroundImage
// when disabled.
if (this.iconImage == null && !isEnabled()) {

@ -24,17 +24,19 @@ public class CallList
public CallList()
{
this.setOpaque(false);
this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
this.getSelectionModel().setSelectionMode(
ListSelectionModel.SINGLE_SELECTION);
this.setCellRenderer(new CallListCellRenderer());
this.setModel(listModel);
this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
this.addMouseListener(this);
}

@ -54,25 +54,23 @@ public CallListCellRenderer() {
super(new BorderLayout(5, 5));
this.setBackground(Color.WHITE);
this.setOpaque(true);
this.setOpaque(false);
this.dataPanel.setOpaque(false);
this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
this.nameLabel.setIconTextGap(2);
this.nameLabel.setPreferredSize(new Dimension(10, 25));
this.nameLabel.setFont(this.getFont().deriveFont(Font.BOLD));
this.dataPanel.add(nameLabel, BorderLayout.CENTER);
this.add(dataPanel, BorderLayout.CENTER);
this.add(dataPanel, BorderLayout.CENTER);
}
/**

@ -8,6 +8,7 @@
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.*;
import javax.swing.*;
@ -80,13 +81,14 @@ public CallListPanel(MainFrame mainFrame)
*/
private void initPanels()
{
this.scrollPane.getViewport().add(callList);
this.scrollPane.setViewport(new ScrollPaneBackground());
this.scrollPane.getViewport().setView(callList);
this.searchPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
this.searchPanel.add(searchLabel, BorderLayout.WEST);
this.searchPanel.add(searchComboBox, BorderLayout.CENTER);
this.searchPanel.add(pluginPanel, BorderLayout.NORTH);
this.add(searchPanel, BorderLayout.NORTH);
this.add(scrollPane, BorderLayout.CENTER);
}
@ -178,7 +180,7 @@ private void addToSearchComboBox(Object obj)
String allItem = Messages.getI18NString("all").getText();
if(!comboModel.contains(allItem)) {
if(!comboModel.contains(allItem)) {
searchComboBox.addItem(allItem);
}
@ -266,7 +268,7 @@ else if (filteredSearch){
new LoadLastCallsFromHistory().start();
filteredSearch = false;
filteredSearch = false;
}
}
@ -380,4 +382,53 @@ public void pluginComponentRemoved(PluginComponentEvent event)
this.pluginPanel.remove(c);
}
private class ScrollPaneBackground extends JViewport
{
BufferedImage bgImage;
TexturePaint texture;
public ScrollPaneBackground()
{
bgImage = ImageLoader.getImage(ImageLoader.MAIN_WINDOW_BACKGROUND);
// Rectangle rect
// = new Rectangle(0, 0,
// bgImage.getWidth(null),
// bgImage.getHeight(null));
// texture = new TexturePaint(bgImage, rect);
}
public void paintComponent(Graphics g)
{
// do the superclass behavior first
super.paintComponent(g);
g.setColor(new Color(
ColorResources.getColor("contactListBackground")));
// paint the background with the choosen color
g.fillRect(0, 0, getWidth(), getHeight());
// paint the image
if (bgImage != null)
{
Graphics2D g2 = (Graphics2D) g;
// g2.setPaint(texture);
g2.drawImage(bgImage,
this.getWidth() - bgImage.getWidth(),
this.getHeight() - bgImage.getHeight(),
this);
}
}
public void setView(JComponent view)
{
view.setOpaque(false);
super.setView(view);
}
}
}

@ -9,10 +9,12 @@
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.audionotifier.*;
import net.java.sip.communicator.service.protocol.*;
@ -34,41 +36,41 @@ public class DialPanel
private JComboBox phoneNumberCombo;
private JButton oneButton = new JButton(new ImageIcon(ImageLoader
.getImage(ImageLoader.ONE_DIAL_BUTTON)));
private DialButton oneButton = new DialButton(
ImageLoader.getImage(ImageLoader.ONE_DIAL_BUTTON));
private JButton twoButton = new JButton(new ImageIcon(ImageLoader
.getImage(ImageLoader.TWO_DIAL_BUTTON)));
private DialButton twoButton = new DialButton(
ImageLoader.getImage(ImageLoader.TWO_DIAL_BUTTON));
private JButton threeButton = new JButton(new ImageIcon(ImageLoader
.getImage(ImageLoader.THREE_DIAL_BUTTON)));
private DialButton threeButton = new DialButton(
ImageLoader.getImage(ImageLoader.THREE_DIAL_BUTTON));
private JButton fourButton = new JButton(new ImageIcon(ImageLoader
.getImage(ImageLoader.FOUR_DIAL_BUTTON)));
private DialButton fourButton = new DialButton(
ImageLoader.getImage(ImageLoader.FOUR_DIAL_BUTTON));
private JButton fiveButton = new JButton(new ImageIcon(ImageLoader
.getImage(ImageLoader.FIVE_DIAL_BUTTON)));
private DialButton fiveButton = new DialButton(
ImageLoader.getImage(ImageLoader.FIVE_DIAL_BUTTON));
private JButton sixButton = new JButton(new ImageIcon(ImageLoader
.getImage(ImageLoader.SIX_DIAL_BUTTON)));
private DialButton sixButton = new DialButton(
ImageLoader.getImage(ImageLoader.SIX_DIAL_BUTTON));
private JButton sevenButton = new JButton(new ImageIcon(ImageLoader
.getImage(ImageLoader.SEVEN_DIAL_BUTTON)));
private DialButton sevenButton = new DialButton(
ImageLoader.getImage(ImageLoader.SEVEN_DIAL_BUTTON));
private JButton eightButton = new JButton(new ImageIcon(ImageLoader
.getImage(ImageLoader.EIGHT_DIAL_BUTTON)));
private DialButton eightButton = new DialButton(
ImageLoader.getImage(ImageLoader.EIGHT_DIAL_BUTTON));
private JButton nineButton = new JButton(new ImageIcon(ImageLoader
.getImage(ImageLoader.NINE_DIAL_BUTTON)));
private DialButton nineButton = new DialButton(
ImageLoader.getImage(ImageLoader.NINE_DIAL_BUTTON));
private JButton starButton = new JButton(new ImageIcon(ImageLoader
.getImage(ImageLoader.STAR_DIAL_BUTTON)));
private DialButton starButton = new DialButton(
ImageLoader.getImage(ImageLoader.STAR_DIAL_BUTTON));
private JButton zeroButton = new JButton(new ImageIcon(ImageLoader
.getImage(ImageLoader.ZERO_DIAL_BUTTON)));
private DialButton zeroButton = new DialButton(
ImageLoader.getImage(ImageLoader.ZERO_DIAL_BUTTON));
private JButton diezButton = new JButton(new ImageIcon(ImageLoader
.getImage(ImageLoader.DIEZ_DIAL_BUTTON)));
private DialButton diezButton = new DialButton(
ImageLoader.getImage(ImageLoader.DIEZ_DIAL_BUTTON));
private JPanel dialPadPanel = new JPanel(new GridLayout(4, 3, 5, 5));
@ -91,7 +93,7 @@ public DialPanel(CallManager callManager)
this.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
this.dialPadPanel.setPreferredSize(new Dimension(140, 140));
this.dialPadPanel.setPreferredSize(new Dimension(150, 150));
this.init();
}
@ -391,4 +393,47 @@ else if (buttonName.equals("star"))
public void mouseReleased(MouseEvent e)
{
}
private class DialButton extends SIPCommButton
{
/**
* Creates an instance of <tt>MsgToolbarButton</tt>.
* @param iconImage The icon to display on this button.
*/
public DialButton(Image iconImage)
{
super( ImageLoader.getImage(ImageLoader.DIAL_BUTTON_BG),
ImageLoader.getImage(ImageLoader.DIAL_BUTTON_ROLLOVER_BG),
iconImage, null);
}
}
public void paintComponent(Graphics g)
{
// do the superclass behavior first
super.paintComponent(g);
g.setColor(new Color(
ColorResources.getColor("contactListBackground")));
// paint the background with the chosen color
g.fillRect(0, 0, getWidth(), getHeight());
BufferedImage bgImage
= ImageLoader.getImage(ImageLoader.MAIN_WINDOW_BACKGROUND);
// If we haven't specified a background image, we return.
if (bgImage == null)
return;
// paint the image
Graphics2D g2 = (Graphics2D) g;
// g2.setPaint(texture);
g2.drawImage(bgImage,
this.getWidth() - bgImage.getWidth(),
this.getHeight() - bgImage.getHeight(),
this);
}
}

@ -10,6 +10,7 @@
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import java.util.*;
import java.util.regex.*;
@ -121,7 +122,11 @@ public ChatConversationPanel(ChatConversationContainer chatContainer)
this.setWheelScrollingEnabled(true);
this.getViewport().add(chatEditorPane);
this.setViewport(new ScrollPaneBackground());
this.chatEditorPane.setOpaque(false);
this.getViewport().setView(chatEditorPane);
this.getVerticalScrollBar().setUnitIncrement(30);
@ -1127,4 +1132,53 @@ private String processImgTags(String message, String contentType)
}
return processedMessage.toString();
}
private class ScrollPaneBackground extends JViewport
{
BufferedImage bgImage;
TexturePaint texture;
public ScrollPaneBackground()
{
bgImage = ImageLoader.getImage(ImageLoader.MAIN_WINDOW_BACKGROUND);
// Rectangle rect
// = new Rectangle(0, 0,
// bgImage.getWidth(null),
// bgImage.getHeight(null));
// texture = new TexturePaint(bgImage, rect);
}
public void paintComponent(Graphics g)
{
// do the superclass behavior first
super.paintComponent(g);
g.setColor(new Color(
ColorResources.getColor("contactListBackground")));
// paint the background with the choosen color
g.fillRect(0, 0, getWidth(), getHeight());
// paint the image
if (bgImage != null)
{
Graphics2D g2 = (Graphics2D) g;
// g2.setPaint(texture);
g2.drawImage(bgImage,
this.getWidth() - bgImage.getWidth(),
this.getHeight() - bgImage.getHeight(),
this);
}
}
public void setView(JComponent view)
{
view.setOpaque(false);
super.setView(view);
}
}
}

@ -52,6 +52,8 @@ public ChatRoomsList(MainFrame mainFrame)
this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
this.setOpaque(false);
this.setModel(listModel);
this.setCellRenderer(new ChatRoomsListCellRenderer());

@ -39,9 +39,7 @@ public ChatRoomsListCellRenderer()
{
super(new BorderLayout());
this.setBackground(Color.WHITE);
this.setOpaque(true);
this.setOpaque(false);
this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

@ -8,12 +8,14 @@
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.chat.*;
import net.java.sip.communicator.impl.gui.main.chat.conference.*;
import net.java.sip.communicator.impl.gui.utils.*;
/**
* The <tt>ChatRoomsListPanel</tt> is the panel that contains the
@ -44,9 +46,9 @@ public ChatRoomsListPanel(MainFrame frame)
this.treePanel.add(chatRoomsList, BorderLayout.NORTH);
this.treePanel.setBackground(Color.WHITE);
this.getViewport().add(treePanel);
this.treePanel.setOpaque(false);
this.setViewport(new ScrollPaneBackground());
this.getViewport().setView(treePanel);
this.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
@ -111,4 +113,52 @@ else if(selectedValue instanceof ChatRoomWrapper)
}
}
private class ScrollPaneBackground extends JViewport
{
BufferedImage bgImage;
TexturePaint texture;
public ScrollPaneBackground()
{
bgImage = ImageLoader.getImage(ImageLoader.MAIN_WINDOW_BACKGROUND);
// Rectangle rect
// = new Rectangle(0, 0,
// bgImage.getWidth(null),
// bgImage.getHeight(null));
// texture = new TexturePaint(bgImage, rect);
}
public void paintComponent(Graphics g)
{
// do the superclass behavior first
super.paintComponent(g);
g.setColor(new Color(
ColorResources.getColor("contactListBackground")));
// paint the background with the choosen color
g.fillRect(0, 0, getWidth(), getHeight());
// paint the image
if (bgImage != null)
{
Graphics2D g2 = (Graphics2D) g;
// g2.setPaint(texture);
g2.drawImage(bgImage,
this.getWidth() - bgImage.getWidth(),
this.getHeight() - bgImage.getHeight(),
this);
}
}
public void setView(JComponent view)
{
view.setOpaque(false);
super.setView(view);
}
}
}

@ -85,6 +85,8 @@ public ContactList(MainFrame mainFrame)
this.setModel(listModel);
this.setOpaque(false);
this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
this.getSelectionModel().setSelectionMode(

@ -54,23 +54,23 @@ public ContactListCellRenderer(MainFrame mainFrame) {
super(new BorderLayout());
this.mainFrame = mainFrame;
this.setBackground(Color.WHITE);
buttonsPanel = new JPanel();
buttonsPanel.setLayout(new GridLayout(1, 0));
this.buttonsPanel.setOpaque(false);
this.buttonsPanel.setName("buttonsPanel");
this.setOpaque(true);
this.setOpaque(false);
this.nameLabel.setOpaque(false);
this.buttonsPanel.setOpaque(false);
this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
this.nameLabel.setIconTextGap(2);
this.nameLabel.setPreferredSize(new Dimension(10, 17));
this.add(nameLabel, BorderLayout.CENTER);
this.add(nameLabel, BorderLayout.CENTER);
}
/**

@ -9,6 +9,7 @@
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.*;
import javax.swing.*;
@ -62,8 +63,12 @@ public ContactListPanel(MainFrame mainFrame) {
this.mainFrame = mainFrame;
this.chatWindowManager = mainFrame.getChatWindowManager();
this.getViewport().add(treePanel);
this.treePanel.setOpaque(false);
this.setViewport(new ScrollPaneBackground());
this.getViewport().setView(treePanel);
this.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
@ -573,4 +578,53 @@ else if (selectedValue instanceof MetaContactGroup) {
}
}
}
private class ScrollPaneBackground extends JViewport
{
BufferedImage bgImage;
TexturePaint texture;
public ScrollPaneBackground()
{
bgImage = ImageLoader.getImage(ImageLoader.MAIN_WINDOW_BACKGROUND);
// Rectangle rect
// = new Rectangle(0, 0,
// bgImage.getWidth(null),
// bgImage.getHeight(null));
// texture = new TexturePaint(bgImage, rect);
}
public void paintComponent(Graphics g)
{
// do the superclass behavior first
super.paintComponent(g);
g.setColor(new Color(
ColorResources.getColor("contactListBackground")));
// paint the background with the choosen color
g.fillRect(0, 0, getWidth(), getHeight());
// paint the image
if (bgImage != null)
{
Graphics2D g2 = (Graphics2D) g;
// g2.setPaint(texture);
g2.drawImage(bgImage,
this.getWidth() - bgImage.getWidth(),
this.getHeight() - bgImage.getHeight(),
this);
}
}
public void setView(JComponent view)
{
view.setOpaque(false);
super.setView(view);
}
}
}

@ -204,6 +204,13 @@ public class ImageLoader {
* ============================APPLICATION ICONS =========================
* -----------------------------------------------------------------------
*/
/**
* The background of the main window and chat window.
*/
public static final ImageID MAIN_WINDOW_BACKGROUND
= new ImageID("MAIN_WINDOW_BACKGROUND");
/**
* An empty 16x16 icon used for alignment.
*/
@ -568,8 +575,17 @@ public class ImageLoader {
public static final ImageID LEAVE_ICON
= new ImageID("LEAVE_ICON");
public static final ImageID WINDOW_LOGO
= new ImageID("WINDOW_LOGO");
/**
* Background image of the dial button.
*/
public static final ImageID DIAL_BUTTON_BG
= new ImageID("DIAL_BUTTON_BG");
/**
* Background image when rollover on the dial button.
*/
public static final ImageID DIAL_BUTTON_ROLLOVER_BG
= new ImageID("DIAL_BUTTON_ROLLOVER_BG");
// ///////////////////// Edit Text Toolbar icons //////////////////////////
@ -1050,22 +1066,30 @@ public static Smiley getSmiley(String smileyString) {
* @param imageID The identifier of the image.
* @return The image for the given identifier.
*/
public static BufferedImage getImage(ImageID imageID) {
public static BufferedImage getImage(ImageID imageID)
{
BufferedImage image = null;
if (loadedImages.containsKey(imageID)) {
if (loadedImages.containsKey(imageID))
{
image = (BufferedImage) loadedImages.get(imageID);
} else {
}
else
{
String path = Images.getString(imageID.getId());
try {
if (path == null)
return null;
try
{
image = ImageIO.read(ImageLoader.class.getClassLoader()
.getResource(path));
loadedImages.put(imageID, image);
} catch (Exception exc) {
}
catch (Exception exc)
{
log.error("Failed to load image:" + path, exc);
}
}

@ -43,7 +43,8 @@ public static String getString(String key)
catch (MissingResourceException exc)
{
logger.warn("Failed to find image for path " + key, exc);
return '!' + key + '!';
}
return null;
}
}

@ -62,6 +62,8 @@ TEXT_ITALIC_ROLLOVER_BUTTON=resources/images/impl/gui/buttons/textItalicRollover
TEXT_UNDERLINED_ROLLOVER_BUTTON=resources/images/impl/gui/buttons/textUnderlinedRollover.png
DIAL_BUTTON=resources/images/impl/gui/buttons/dialButton.png
INVITE_DIALOG_ICON=resources/images/impl/gui/common/inviteDialogIcon.png
DIAL_BUTTON_BG=resources/images/impl/gui/buttons/dialButtonBg.png
DIAL_BUTTON_ROLLOVER_BG=resources/images/impl/gui/buttons/dialButtonRolloverBg.png
MSG_TOOLBAR_BUTTON_BG=resources/images/impl/gui/buttons/msgToolbarBg.png
MSG_TOOLBAR_ROLLOVER_BUTTON_BG=resources/images/impl/gui/buttons/msgToolBarRolloverBg.png
@ -188,4 +190,6 @@ LEAVE_ICON=resources/images/impl/gui/common/leave.png
WINDOW_LOGO=resources/images/impl/gui/common/windowLogo.png
STATUS_SEPARATOR_ICON=resources/images/impl/gui/common/statusSeparator1.png
STATUS_SEPARATOR_ICON=resources/images/impl/gui/common/statusSeparator1.png
MAIN_WINDOW_BACKGROUND=resources/images/impl/gui/common/mainWindowBackground.png
Loading…
Cancel
Save