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

📄 viewpanel.java

📁 java实现的校园导航系统
💻 JAVA
字号:
package gilyou.liu;

import java.awt.Color;
import java.awt.Font;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.SystemColor;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextArea;


public class ViewPanel extends JPanel {

	private static final long serialVersionUID = 1L;
	public JButton showDetailButton = null;
	public String name = null;
	public String introduction = null;
	public JTextArea detailTextArea = null;
	/**
	 * This is the default constructor
	 */
	public ViewPanel() {
		super();
		initialize();
		this.setSize(this.getPreferredSize());
	}
	public ViewPanel(String name,String introduction){
		super();
		initialize();
		this.name = name;
		this.introduction = introduction;
	}
	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(87, 62);
		this.setLayout(null);
		this.setBackground(Color.blue);
		this.setForeground(Color.blue);
		this.setFont(new Font("Dialog", Font.BOLD, 12));
		this.add(getShowDetailButton(), null);
		this.add(getDetailTextArea(), null);
		this.setOpaque(false);
	}
	/**
	 * This method initializes showDetailButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getShowDetailButton() {
		if (showDetailButton == null) {
			showDetailButton = new JButton();
			showDetailButton.setBounds(new Rectangle(25, 43, 40, 18));
			showDetailButton.setMargin(new Insets(0, 0, 0, 0));
			showDetailButton.setForeground(SystemColor.inactiveCaption);
			showDetailButton.setText("Detail");
			showDetailButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
			showDetailButton.setToolTipText("显示详细信息");
			showDetailButton.addMouseListener(new MouseAdapter(){
				public void mouseEntered(MouseEvent e){
					showDetailButton.setBackground(Color.red);
				}
				public void mouseExited(MouseEvent e){
					showDetailButton.setBackground(Color.white);
				}
			});
		}
		return showDetailButton;
	}
	/**
	 * This method initializes detailTextArea	
	 * 	
	 * @return javax.swing.JTextArea	
	 */
	public JTextArea getDetailTextArea() {
		if (detailTextArea == null) {
			detailTextArea = new JTextArea();
			detailTextArea.setBounds(new Rectangle(0, 0, 87, 42));
			detailTextArea.setEditable(false);
			detailTextArea.setFont(new Font("",Font.BOLD,12));
			detailTextArea.setWrapStyleWord(false);
			detailTextArea.setLineWrap(true);
			detailTextArea.setOpaque(false);
			detailTextArea.setBackground(Color.gray);
		}
		return detailTextArea;
	}

}  //  @jve:decl-index=0:visual-constraint="430,186"

⌨️ 快捷键说明

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