[Zerofile-svn] SF.net SVN: zerofile: [58] trunk/src
Status: Pre-Alpha
Brought to you by:
karl-bengtsson
|
From: <kar...@us...> - 2007-11-27 21:08:58
|
Revision: 58
http://zerofile.svn.sourceforge.net/zerofile/?rev=58&view=rev
Author: karl-bengtsson
Date: 2007-11-27 13:09:02 -0800 (Tue, 27 Nov 2007)
Log Message:
-----------
*) Added (more or less empty) About-window where we can brag about how great we are.
*) Modified the LayoutManager for the main window to use BorderLayout, and put the contact list inside a ScrollPane, providing scroll bars and a more balanced look.
*) Did likewise for the chat window.
So now our application looks a little bit more professional, at least on a Mac. Please try it out on other platforms.
Modified Paths:
--------------
trunk/src/ZeroFileChatWindow.java
trunk/src/ZeroFileMainWindow.java
trunk/src/ZeroFileSettingsWindow.java
Added Paths:
-----------
trunk/src/ZeroFileAboutWindow.java
Added: trunk/src/ZeroFileAboutWindow.java
===================================================================
--- trunk/src/ZeroFileAboutWindow.java (rev 0)
+++ trunk/src/ZeroFileAboutWindow.java 2007-11-27 21:09:02 UTC (rev 58)
@@ -0,0 +1,27 @@
+import java.awt.*;
+import javax.swing.*;
+
+/**
+ *
+ */
+
+/**
+ * @author Karl Bengtsson
+ *
+ */
+public class ZeroFileAboutWindow {
+ private static JFrame _aboutWindowFrame;
+ private static JLabel _aboutText;
+
+ public static void showAboutWindow()
+ {
+ _aboutWindowFrame = new JFrame();
+ _aboutWindowFrame.setTitle("About ZeroFile");
+ _aboutWindowFrame.setSize(new Dimension(300,200));
+ _aboutWindowFrame.setLayout(new BorderLayout(10,10));
+ _aboutText = new JLabel();
+ _aboutText.setText("Hell jeas!");
+ _aboutWindowFrame.add(_aboutText,BorderLayout.CENTER);
+ _aboutWindowFrame.setVisible(true);
+ }
+}
Modified: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java 2007-11-27 15:38:23 UTC (rev 57)
+++ trunk/src/ZeroFileChatWindow.java 2007-11-27 21:09:02 UTC (rev 58)
@@ -8,23 +8,12 @@
*/
public class ZeroFileChatWindow {
private JFrame _chatWindowFrame;
- private JTextArea _chatTextArea;
+ private JTextArea _chatTextArea = new JTextArea();;
+ private JScrollPane _chatTextAreaPane = new JScrollPane(_chatTextArea);
private JPanel _bottomPanel;
private JTextField _entryTextField;
private JButton _sendButton;
private XMPPLinkLocalChatSession _session;
- /*public ZeroFileChatWindow(Socket sock)
- {
- this.ZeroFileChatWindowInit();
- _session = new XMPPLinkLocalChatSession(this,sock);
- }
- public ZeroFileChatWindow(XMPPLinkLocalHost hostToChatWith)
- {
- this.ZeroFileChatWindowInit();
- hostToChatWith.updateData();
- this.setWindowTitle(hostToChatWith.toString());
- _session = new XMPPLinkLocalChatSession(this,hostToChatWith);
- }*/
public ZeroFileChatWindow(XMPPLinkLocalChatSession sess)
{
@@ -42,29 +31,50 @@
_chatTextArea.append("\n"+s);
}
+ public void sendMessage(String str)
+ {
+ printText(str);
+ _session.sendMessage(str);
+ _entryTextField.setText("");
+ }
+
private void ZeroFileChatWindowInit()
{
_chatWindowFrame = new JFrame();
- _chatWindowFrame.setLayout(new GridLayout(0,1,1,1));
+ _chatWindowFrame.setLayout(new BorderLayout(1,1));
_chatWindowFrame.setLocation(0,400);
_chatWindowFrame.setSize(new Dimension(300,200));
- _chatTextArea = new JTextArea();
- _chatWindowFrame.add(_chatTextArea);
+ _chatTextAreaPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ _chatWindowFrame.add(_chatTextAreaPane,BorderLayout.CENTER);
_bottomPanel = new JPanel();
- _chatWindowFrame.add(_bottomPanel);
+ _chatWindowFrame.add(_bottomPanel,BorderLayout.SOUTH);
_bottomPanel.setLayout(new GridLayout(1,0,1,1));
_entryTextField = new JTextField();
_sendButton = new JButton("Send");
_bottomPanel.add(_entryTextField);
+ _entryTextField.addKeyListener(
+ new KeyListener()
+ {
+ public void keyPressed(KeyEvent e)
+ {
+ }
+ public void keyReleased(KeyEvent e)
+ {
+ }
+ public void keyTyped(KeyEvent e)
+ {
+ if (e.getKeyChar() == '\n')
+ {
+ sendMessage(_entryTextField.getText());
+ }
+ }
+ });
_bottomPanel.add(_sendButton);
_chatWindowFrame.setVisible(true);
_sendButton.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent sendButtonPress){
- String message = _entryTextField.getText();
- printText(message);
- _session.sendMessage(message);
- _entryTextField.setText("");
+ sendMessage(_entryTextField.getText());
}
}
);
Modified: trunk/src/ZeroFileMainWindow.java
===================================================================
--- trunk/src/ZeroFileMainWindow.java 2007-11-27 15:38:23 UTC (rev 57)
+++ trunk/src/ZeroFileMainWindow.java 2007-11-27 21:09:02 UTC (rev 58)
@@ -1,6 +1,5 @@
import java.awt.*;
import java.awt.event.*;
-
import javax.swing.*;
public class ZeroFileMainWindow
@@ -16,8 +15,9 @@
private static JMenu _helpMenu;
private static JMenuItem _aboutMenuItem;
private static JComboBox _statusLista;
- private static DefaultListModel _contactListModel = new DefaultListModel();;
- private static JList _contactList = new JList(_contactListModel);;
+ private static DefaultListModel _contactListModel = new DefaultListModel();
+ private static JList _contactList = new JList(_contactListModel);
+ private static JScrollPane _contactListPane = new JScrollPane(_contactList);
static boolean containsHost(XMPPLinkLocalHost h)
{
@@ -29,7 +29,6 @@
static void addHost(XMPPLinkLocalHost h)
{
- //System.out.println("forsoker adda: " + h.toString());
h.updateData();
_contactListModel.addElement(h);
}
@@ -71,10 +70,15 @@
_helpMenu = new JMenu("Help");
_mainMenuBar.add(_helpMenu);
_aboutMenuItem = new JMenuItem("About..");
+ _aboutMenuItem.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent e) {
+ ZeroFileAboutWindow.showAboutWindow();
+ }
+ });
_helpMenu.add(_aboutMenuItem);
// Layout, sizes, and the connection of the JMenuBar
- _mainWindowFrame.setLayout(new GridLayout(0,1,1,1));
+ _mainWindowFrame.setLayout(new BorderLayout(1,1));
_mainWindowFrame.setMinimumSize(new Dimension(120,300));
_mainWindowFrame.setSize(new Dimension(150,400));
_mainWindowFrame.setJMenuBar(_mainMenuBar);
@@ -83,7 +87,7 @@
String[] statusModes = {"Available","Away","Do not disturb"};
_statusLista = new JComboBox(statusModes);
_statusLista.setMaximumSize(new Dimension(20,100));
- _mainWindowFrame.add(_statusLista);
+ _mainWindowFrame.add(_statusLista,BorderLayout.NORTH);
_statusLista.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e)
{
@@ -97,8 +101,6 @@
});
// Contact list
- //_contactListModel = new DefaultListModel();
- //_contactList = new JList(_contactListModel);
_contactList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
_contactList.setLayoutOrientation(JList.VERTICAL);
_contactList.setSize(500,700);
@@ -122,11 +124,11 @@
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() == 2)
- //new ZeroFileChatWindow((XMPPLinkLocalHost)_contactList.getSelectedValue());
new XMPPLinkLocalChatSession((XMPPLinkLocalHost)_contactList.getSelectedValue());
}
});
- _mainWindowFrame.add(_contactList);
+ _contactListPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ _mainWindowFrame.add(_contactListPane,BorderLayout.CENTER);
// Show the window
_mainWindowFrame.setVisible(true);
Modified: trunk/src/ZeroFileSettingsWindow.java
===================================================================
--- trunk/src/ZeroFileSettingsWindow.java 2007-11-27 15:38:23 UTC (rev 57)
+++ trunk/src/ZeroFileSettingsWindow.java 2007-11-27 21:09:02 UTC (rev 58)
@@ -7,7 +7,7 @@
* @author Richard
*/
-public class ZeroFileSettingsWindow
+public class ZeroFileSettingsWindow
{
static void startSettingsWindow()
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|