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

📄 messagecenter.java

📁 企业内部管理系统
💻 JAVA
字号:
package viewtuba1;

import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.AbstractAction;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JToolBar;
import javax.swing.JToolTip;
import javax.swing.KeyStroke;
import javax.swing.ScrollPaneConstants;

import model.ClockLabel;

import control.DemoAction;
import control.DemoAction1;
import control.DemoAction2;
import control.DemoAction3;
import control.DemoAction4;

public class MessageCenter extends JFrame {

	private static JTextArea textArea;

	static MessageCenter frame;

	final JComboBox combo;
	
	JLabel label_7;
	
	JPanel panel_3;

	public static void main(String args[]) {
		try {
			frame = new MessageCenter();
			frame.setVisible(true);
			frame.setTitle("MessageCenter");
			frame.setResizable(false);
			frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the frame
	 */
	public MessageCenter() {
		super();
		// public void paintComponent(Graphics g){
		// ImageIcon img = new ImageIcon("image/back1.gif");
		// g.drawImage(img.getImage(), 0, 0, this);
		// super.paintComponents(g);
		// }
		getContentPane().setLayout(null);
		// getContentPane().paintComponents(g);
		setBounds(100, 100, 500, 375);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JMenuBar menuBar = new JMenuBar();
		this.setJMenuBar(menuBar);
		final JMenu formatMenu = new JMenu("Edit Menu");
		formatMenu.setMnemonic('E');
		final JToolBar toolBar = new JToolBar();
		combo = new JComboBox();
		combo.addItem("特色背景一");
		combo.addItem("特色背景二");
		combo.addItem("特色背景三");
		combo.addItem("特色背景四");
		combo.addItem("特色背景五");
		combo.addItem("特色背景六");
		combo.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				// (JComboBox)e.getSource( )).getSelectedItem( );
				String[] fonts = { "特色背景一", "特色背景二", "特色背景三", "特色背景四", "特色背景五",
						"特色背景六" };
				String[] fonts1 = { "image/back1.gif", "image/back2.gif",
						"image/back3.gif", "image/back4.gif",
						"image/back5.gif", "image/back6.gif" };
				for (int i = 0; i < combo.getItemCount(); i++) {
//					System.out.println(combo.getItemAt(i).toString());
					if (combo.getSelectedItem().toString() == fonts[i]) {
						Icon icon = new ImageIcon(fonts1[i]); 
						label_7.setIcon(icon);	
					}
				}
			}

		});
		// final JToolTip openToolItem = new JToolTip();
		toolBar.setBounds(0, 0, 492, 46);
		getContentPane().add(toolBar);

		DemoAction openAction = new DemoAction("open", new ImageIcon(
				"image/open.gif"), "打开", 'L');
		DemoAction1 saveAction = new DemoAction1("goto", new ImageIcon(
				"image/goto.gif"), "转向聊天室", 'R');
		DemoAction2 lockAction = new DemoAction2("lock", new ImageIcon(
				"image/lock.gif"), "锁定", 'N');
		DemoAction3 unlockAction = new DemoAction3("unlock", new ImageIcon(
				"image/unlock.gif"), "解锁", 'M');
		DemoAction4 exitAction = new DemoAction4("exit", new ImageIcon(
				"image/exit.gif"), "退出", 'F');
		menuBar.add(formatMenu);
		formatMenu.add(openAction);
		formatMenu.add(saveAction);
		formatMenu.add(lockAction);
		formatMenu.add(unlockAction);
		formatMenu.addSeparator();
		formatMenu.add(exitAction);
		toolBar.add(openAction);
		toolBar.add(saveAction);
		toolBar.add(lockAction);
		toolBar.add(unlockAction);
		toolBar.add(exitAction);
		toolBar.add(combo);
		final JSplitPane splitPane = new JSplitPane();
		splitPane.setResizeWeight(0.94);
		splitPane.setBounds(0, 64, 492, 207);
		getContentPane().add(splitPane);

		final JScrollPane scrollPane = new JScrollPane();
		scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		splitPane.setLeftComponent(scrollPane);

		final JPanel panel_2 = new JPanel();
		panel_2.setLayout(null);
		scrollPane.setViewportView(panel_2);

		panel_3 = new JPanel();
//		{
//			public void paintComponent(Graphics g) {
//				g.setColor(Color.blue);
//				Image img = new ImageIcon("image/back4.gif").getImage();
//				g.drawImage(img, 0, 0, null);
//			}
//
//		};
		panel_3.setLayout(null);
		panel_3.setBounds(0, 0, 389, 186);
		panel_2.add(panel_3);

//		label_7 = new JLabel(new ImageIcon("image/back4.gif"));
		Icon icon1 = new ImageIcon("image/back4.gif");
		label_7 = new JLabel();
		label_7.setIcon(icon1);
		label_7.setBounds(0, 0, 389, 186);
		panel_3.add(label_7);
		panel_3.setOpaque(false);
		textArea = new JTextArea();
		textArea.setBounds(0, 0, 389, 186);
		panel_2.add(textArea);

		final JScrollPane scrollPane_1 = new JScrollPane();
		splitPane.setRightComponent(scrollPane_1);

		final JPanel panel = new JPanel();
		panel.setLayout(new GridLayout(4, 3));
		scrollPane_1.setViewportView(panel);

		final JPanel panel_1_3 = new JPanel();
		panel_1_3.setLayout(new FlowLayout());
		panel.add(panel_1_3);

		final JLabel label = new JLabel(new ImageIcon("image/1.gif"));
		panel_1_3.add(label);

		final JLabel label_1 = new JLabel(new ImageIcon("image/2.gif"));
		panel_1_3.add(label_1);

		final JPanel panel_1_2 = new JPanel();
		panel_1_2.setLayout(new FlowLayout());
		panel.add(panel_1_2);
		final JLabel label_2 = new JLabel(new ImageIcon("image/3.gif"));
		// label_2.setIcon("image/1.gif");
		panel_1_2.add(label_2);

		final JLabel label_3 = new JLabel(new ImageIcon("image/4.gif"));
		panel_1_2.add(label_3);

		final JPanel panel_1_1 = new JPanel();
		panel_1_1.setLayout(new FlowLayout());
		panel.add(panel_1_1);

		final JLabel label_4 = new JLabel(new ImageIcon("image/5.gif"));
		panel_1_1.add(label_4);

		final JLabel label_5 = new JLabel(new ImageIcon("image/6.gif"));
		panel_1_1.add(label_5);

		final JPanel panel_1 = new JPanel();
		panel_1.setLayout(new FlowLayout());
		panel.add(panel_1);

		final JLabel label_6 = new JLabel();
		label_6.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		label_6.setText("系统时间:");
		label_6.setBounds(327, 277, 81, 33);
		getContentPane().add(label_6);

		final JLabel label_6_1 = new ClockLabel();
		label_6_1.setBounds(411, 277, 81, 33);
		getContentPane().add(label_6_1);

	}

	public void update(Graphics g) {
		// TODO Auto-generated method stub
		super.update(g);
	}

	public static MessageCenter getFrame() {
		return frame;
	}

	public static JTextArea getTextArea() {
		return textArea;
	}

	public JLabel getLabel_7() {
		return label_7;
	}

}

⌨️ 快捷键说明

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