⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 noteaddpanel.java

📁 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网!
💻 JAVA
字号:
    /* CRMS, customer relationship management system    Copyright (C) 2003  Service To Youth Council    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA    For further information contact the SYC ICT department on GPL@syc.net.au    98 Kermode Street    North Adelaide    South Australia    SA 5006     +61 (0)8 8367 0755    *//* * CallViewPanel.java * * Created on 27 March 2003, 00:11 */package crms.applet;import javax.swing.*;import java.awt.*;import java.awt.event.*;import javax.swing.border.*;import javax.swing.event.*;import java.util.*;import crms.vo.*;import crms.module.*;import crms.util.*;import crms.ui.*;import java.text.*;import java.beans.*;import java.io.*;import java.text.*;/** * * @author  dmurphy */public class NoteAddPanel extends CRMSPanel implements ItemListener  {	public static final int CLOSE_WINDOW = 0;        JPanel titlePanel = new JPanel();    CRMSPanel bodyPanel = CRMSPanel.getEmptyPanel();    JLabel headingLabel = new JLabel();        public static SimpleDateFormat df = new SimpleDateFormat("EEEE, d MMMM, yyyy");    public static SimpleDateFormat tf = new SimpleDateFormat("h:mm a");    JButton buttonSave = new JButton("Save Note");    JButton buttonReset = new JButton("Clear");    JButton buttonCancel = new JButton("Close");    JCheckBox accessLevel = new JCheckBox("Private");    JTextArea noteText = new JTextArea();    JScrollPane noteScrollPane = new JScrollPane(noteText);        JPanel buttonPanel = new JPanel();    EntityType noteType = null;    int noteReference = -1;        //Permission entityPermission = null;	CallbackDestination destination = null;    	public NoteAddPanel() {	}    /** Creates a new instance of CallViewPanel */    public NoteAddPanel(EntityType noteType, int noteReference, String title, Permission entityPermission) {        this.noteType = noteType;        this.noteReference = noteReference;        //this.entityPermission = entityPermission;        headingLabel.setText(title);    }	public void setNotes(EntityType noteType, int noteReference) {        this.noteType = noteType;        this.noteReference = noteReference;	}	public void setDestination(CallbackDestination new_dest) {		destination = new_dest;	}        public void init() {		final Object thisobj = this;        setLayout(new BorderLayout());        setBackground(Color.WHITE);/*        headingLabel.setFont(new java.awt.Font("Serif", 1, 18));        headingLabel.setBackground(Color.WHITE);                noteText.setWrapStyleWord(true);        noteText.setLineWrap(true);                titlePanel.add(headingLabel);        titlePanel.setBackground(Color.WHITE);        add(titlePanel, BorderLayout.NORTH);*/              buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));		buttonPanel.setBackground(Color.WHITE);        buttonPanel.add(buttonSave);        buttonPanel.add(buttonReset);        buttonPanel.add(buttonCancel);                buttonSave.addActionListener( new ActionListener() {           public void actionPerformed(ActionEvent ev) {               saveNote();				if (destination != null) {					destination.callback(thisobj, NoteAddPanel.CLOSE_WINDOW, new Object());				}               //PanelManager.getInstance().activatePanel(new NotesViewPanel(noteType, noteReference, entityPermission));           }        });                buttonReset.addActionListener( new ActionListener() {           public void actionPerformed(ActionEvent ev) {               refreshData();           }        });                buttonCancel.addActionListener( new ActionListener() {           public void actionPerformed(ActionEvent ev) {			if (destination != null) {				destination.callback(thisobj, NoteAddPanel.CLOSE_WINDOW, null);			}            //PanelManager.getInstance().activatePanel(new NotesViewPanel(noteType, noteReference, entityPermission));           }        });        bodyPanel.setLayout(new GridBagLayout());        bodyPanel.setBackground(Color.WHITE);                noteText.setRows(10);                Insets defaultInsets = new Insets(4,0,0,0);                bodyPanel.add(new JLabel("Date"),                  new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0        ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, defaultInsets, 0, 0));        bodyPanel.add(new JLabel(df.format(new Date())),                  new GridBagConstraints(1, 0, 3, 1, 0.0, 0.0        ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 167, 0));                bodyPanel.add(new JLabel("Time"),                  new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0        ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, defaultInsets, 0, 0));        bodyPanel.add(new JLabel(tf.format(new Date())),                  new GridBagConstraints(1, 1, 3, 1, 0.0, 0.0        ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 167, 0));        bodyPanel.add(new JLabel("Note"),                  new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0        ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, defaultInsets, 0, 0));        bodyPanel.add(noteScrollPane,                  new GridBagConstraints(1, 3, 3, 10, 0.0, 0.0        ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 167, 0));                // lubo: addd privacy 				bodyPanel.add(new JLabel("Private"),            new GridBagConstraints(0, 15, 1, 1, 0.0, 0.0        ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, defaultInsets, 0, 0));				bodyPanel.add(accessLevel,                  	  new GridBagConstraints(1, 15, 3, 1, 0.0, 0.0        ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 167, 0));		accessLevel.setBackground(Color.WHITE);                add(bodyPanel, BorderLayout.CENTER);        add(buttonPanel, BorderLayout.SOUTH);                setCurrentPanel(bodyPanel);                refreshData();    }        public void refreshData() {        noteText.setText("");		accessLevel.setSelected(false);    }        public void saveNote() {                Server server = ServerFactory.getInstance().getServer();                ServerCommand command = new ServerCommand(NoteModule.NOTES_ADD);                command.setParameter(NoteModule.PARAM_NOTE_TYPE, noteType.getCode());        command.setParameter(NoteModule.PARAM_NOTE_REFERENCE, String.valueOf(noteReference));        command.setParameter(NoteModule.PARAM_NOTE_TEXT, noteText.getText());                if (accessLevel.isSelected()) {					command.setParameter(NoteModule.PARAM_ACCESS_LEVEL, new Integer(1));        }        ServerResponse sr = server.sendCommand(command);    }    		/** Listens to the check boxes. */		public void itemStateChanged(ItemEvent e) {				int index = 0;				char c = '-';				Object source = e.getItemSelectable();				if (source == accessLevel) {						index = 0;						c = 'c';				} else  {						System.out.println("### Unknown object");				}				//Now that we know which button was pushed, find out				//whether it was selected or deselected.				if (e.getStateChange() == ItemEvent.DESELECTED) {					accessLevel.setSelected(true);				} else {					accessLevel.setSelected(false);				}					}			/**	 * Main class	 *	 * @param args	 */	public static void main(String[] args) {		JFrame frame = new JFrame("Utillity Bar");		NoteAddPanel ut = new NoteAddPanel(EntityType.COMPANY, -1, "test", null );		ut.init();		frame.getContentPane().add(ut);		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);		frame.pack();		frame.setVisible(true);	}    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -