mirror of https://github.com/sipwise/jitsi.git
- Added set/getSize and set/getLocation methods to the UIService.cusax-fix
parent
04d5a4c7e3
commit
0c40c5109a
@ -0,0 +1,168 @@
|
||||
package net.java.sip.communicator.impl.gui.main.menus;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.i18n.*;
|
||||
import net.java.sip.communicator.impl.gui.utils.*;
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
|
||||
public class AboutWindow
|
||||
extends JDialog
|
||||
implements ActionListener,
|
||||
ExportedWindow
|
||||
{
|
||||
private WindowBackground mainPanel = new WindowBackground();
|
||||
|
||||
private JLabel versionLabel = new JLabel(" "
|
||||
+ System.getProperty("sip-communicator.version"));
|
||||
|
||||
public AboutWindow()
|
||||
{
|
||||
this.setModal(false);
|
||||
this.setResizable(false);
|
||||
|
||||
this.setTitle(
|
||||
Messages.getI18NString("aboutWindowTitle",
|
||||
new String[]{ GuiActivator.getResources()
|
||||
.getSettingsString("applicationName")}).getText());
|
||||
|
||||
this.mainPanel.setLayout(null);
|
||||
|
||||
this.versionLabel.setFont(Constants.FONT.deriveFont(12));
|
||||
this.versionLabel.setForeground(new Color(
|
||||
GuiActivator.getResources().getColor("splashScreenTitleColor")));
|
||||
this.versionLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
|
||||
|
||||
this.mainPanel.add(versionLabel);
|
||||
|
||||
Insets insets = mainPanel.getInsets();
|
||||
versionLabel.setBounds(370 + insets.left, 307 + insets.top, 200, 20);
|
||||
|
||||
this.getContentPane().add(mainPanel);
|
||||
|
||||
// Close the splash screen on simple click or Esc.
|
||||
this.getGlassPane().addMouseListener(new MouseAdapter()
|
||||
{
|
||||
public void mouseClicked(MouseEvent e)
|
||||
{
|
||||
AboutWindow.this.close(false);
|
||||
}
|
||||
});
|
||||
|
||||
this.getGlassPane().setVisible(true);
|
||||
|
||||
ActionMap amap = this.getRootPane().getActionMap();
|
||||
|
||||
amap.put("close", new CloseAction());
|
||||
|
||||
InputMap imap = this.getRootPane().getInputMap(
|
||||
JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
|
||||
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
|
||||
}
|
||||
|
||||
protected void close(boolean isEscaped)
|
||||
{
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* The action invoked when user presses Escape key.
|
||||
*/
|
||||
private class CloseAction extends AbstractAction
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
AboutWindow.this.close(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the window background in order to have a background image.
|
||||
*/
|
||||
private class WindowBackground
|
||||
extends JPanel
|
||||
{
|
||||
private Image bgImage;
|
||||
|
||||
public WindowBackground()
|
||||
{
|
||||
this.setOpaque(true);
|
||||
|
||||
bgImage = ImageLoader.getImage(
|
||||
ImageLoader.ABOUT_WINDOW_BACKGROUND);
|
||||
|
||||
this.setPreferredSize(new Dimension(bgImage.getWidth(this),
|
||||
bgImage.getHeight(this)));
|
||||
}
|
||||
|
||||
protected void paintComponent(Graphics g)
|
||||
{
|
||||
super.paintComponent(g);
|
||||
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
g2.drawImage(bgImage, 0, 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the <tt>ExportedWindow.getIdentifier()</tt> method.
|
||||
*/
|
||||
public WindowID getIdentifier()
|
||||
{
|
||||
return ExportedWindow.ABOUT_WINDOW;
|
||||
}
|
||||
|
||||
/**
|
||||
* This dialog could not be minimized.
|
||||
*/
|
||||
public void minimize()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This dialog could not be maximized.
|
||||
*/
|
||||
public void maximize()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the <tt>ExportedWindow.bringToFront()</tt> method. Brings
|
||||
* this window to front.
|
||||
*/
|
||||
public void bringToFront()
|
||||
{
|
||||
this.toFront();
|
||||
}
|
||||
|
||||
public static void activateAntialiasing(Graphics g)
|
||||
{
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
}
|
||||
|
||||
/**
|
||||
* The source of the window
|
||||
* @return the source of the window
|
||||
*/
|
||||
public Object getSource()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,199 @@
|
||||
/*
|
||||
* 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.main.menus;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.i18n.*;
|
||||
import net.java.sip.communicator.impl.gui.utils.*;
|
||||
import net.java.sip.communicator.service.contactlist.*;
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
import net.java.sip.communicator.service.gui.Container;
|
||||
|
||||
public class MoreButton
|
||||
extends JLabel
|
||||
implements PluginComponent,
|
||||
MouseListener,
|
||||
FocusListener
|
||||
{
|
||||
private Image iconImage;
|
||||
|
||||
private boolean isMouseOver = false;
|
||||
|
||||
private JPopupMenu menu = new JPopupMenu();
|
||||
|
||||
private Hashtable menuItemsTable = new Hashtable();
|
||||
|
||||
public MoreButton()
|
||||
{
|
||||
super(new ImageIcon(ImageLoader.getImage(ImageLoader.MORE_BUTTON)),
|
||||
JLabel.CENTER);
|
||||
|
||||
this.setVerticalTextPosition(SwingConstants.BOTTOM);
|
||||
this.setHorizontalTextPosition(SwingConstants.CENTER);
|
||||
|
||||
this.setToolTipText(Messages.getI18NString("more").getText());
|
||||
|
||||
this.addMouseListener(this);
|
||||
|
||||
this.addFocusListener(this);
|
||||
}
|
||||
|
||||
public Object getComponent()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getConstraints()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Container getContainer()
|
||||
{
|
||||
return Container.CONTAINER_MAIN_TOOL_BAR;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.getText();
|
||||
}
|
||||
|
||||
public void setMouseOver(boolean isMouseOver)
|
||||
{
|
||||
this.isMouseOver = isMouseOver;
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
public void setCurrentContact(MetaContact metaContact)
|
||||
{
|
||||
}
|
||||
|
||||
public void setCurrentContactGroup(MetaContactGroup metaGroup)
|
||||
{
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent e)
|
||||
{
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e)
|
||||
{
|
||||
this.setMouseOver(true);
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e)
|
||||
{
|
||||
this.setMouseOver(false);
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e)
|
||||
{
|
||||
requestFocus();
|
||||
|
||||
if (!menu.isVisible())
|
||||
{
|
||||
menu.setLocation(
|
||||
getLocationOnScreen().x,
|
||||
getLocationOnScreen().y + getHeight());
|
||||
|
||||
menu.setVisible(true);
|
||||
}
|
||||
else
|
||||
menu.setVisible(false);
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the position of this component in the container, where it
|
||||
* will be added.
|
||||
* @return 0 to indicate the first position in the container.
|
||||
*/
|
||||
public int getPositionIndex()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void focusGained(FocusEvent arg0)
|
||||
{
|
||||
}
|
||||
|
||||
public void focusLost(FocusEvent arg0)
|
||||
{
|
||||
menu.setVisible(false);
|
||||
}
|
||||
|
||||
public void addMenuItem(final JComponent c)
|
||||
{
|
||||
String name = c.getToolTipText();
|
||||
|
||||
if (!this.containsItem(name))
|
||||
{
|
||||
JMenuItem item = new JMenuItem(name);
|
||||
item.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
MouseEvent mouseEvent
|
||||
= new MouseEvent(c,
|
||||
MouseEvent.MOUSE_PRESSED,
|
||||
System.currentTimeMillis(),
|
||||
MouseEvent.BUTTON1,
|
||||
c.getX(),
|
||||
c.getY(),
|
||||
1,
|
||||
false);
|
||||
|
||||
MouseListener[] listeners = c.getMouseListeners();
|
||||
|
||||
for (int i = 0; i < listeners.length; i++)
|
||||
{
|
||||
MouseListener l = listeners[i];
|
||||
l.mousePressed(mouseEvent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.menu.add(item);
|
||||
this.menuItemsTable.put(name, item);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeMenuItem(JComponent c)
|
||||
{
|
||||
String name = c.getToolTipText();
|
||||
Component item = (Component) this.menuItemsTable.get(name);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
this.menu.remove(item);
|
||||
menuItemsTable.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
public int getItemsCount()
|
||||
{
|
||||
return menuItemsTable.size();
|
||||
}
|
||||
|
||||
public boolean containsItem(String name)
|
||||
{
|
||||
return menuItemsTable.containsKey(name);
|
||||
}
|
||||
|
||||
public boolean isNativeComponent()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue