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

📄 gmconvpanel.java

📁 Gmail API for Java 一个gmail信箱的客户端
💻 JAVA
字号:
package siuying.gm.app.gmailer4j.ui;

import java.awt.*;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;

import siuying.gm.app.gmailer4j.GMailer4j;

import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;


/**
 * GMThreadPanel
 * A panel to display a conversation, with navigations on threads within a conversation
 * @author siuying
 * @version 0.2
 */

public class GMConvPanel extends JPanel {
  
  
  
  public JEditorPane 	txtContent 	= new JEditorPane();
  public JButton 		btnPrev 	= new JButton();
  public JButton 		btnNext 	= new JButton();
  public JLabel 		lblSubject 	= new JLabel();
  public JLabel 		lblSender 	= new JLabel();
  public JLabel 		lblDate 	= new JLabel();
  public JScrollPane	scrollPane	= new JScrollPane();
  

  public GMConvPanel() {
    try {
    	txtContent.addHyperlinkListener(new HyperlinkListener(){
    		public void hyperlinkUpdate(HyperlinkEvent evt) {
    			if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    	            JEditorPane pane = (JEditorPane)evt.getSource();
    	            GMailer4j.openBrowser(evt.getURL().toExternalForm());
    	            
    	        }
    		}
    	   });
    	jbInit();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }

  void jbInit() throws Exception {
  	
  	/*
  	 *	1.Initialize some objects we will need
  	 *	during the gui creation process. 
  	 */
  	BorderLayout mainLayout = new BorderLayout();
  	setLayout(mainLayout);
  	
  	JPanel northPanel = new JPanel();//will contain sender, subject, etc
  	JPanel centralPanel = new JPanel();//will contain the text zone
  	
  	add(northPanel, BorderLayout.NORTH);
  	add(centralPanel, BorderLayout.CENTER);
  	
  	/*
  	 * 	2.Setup the north panel using the magical
  	 * JGoodies form layout.
  	 */
  	FormLayout formLayout = new FormLayout(
  			"5dlu,400dlu",
			"2dlu,pref,2dlu,pref,2dlu,pref,2dlu"
  			);
  	northPanel.setLayout(formLayout);
  	
  	formLayout.setRowGroups(new int[][]{{2,4,6}});
  	CellConstraints cc = new CellConstraints();
  	northPanel.add(lblSubject, cc.xy(2,2));
  	northPanel.add(lblSender, cc.xy(2,4));
  	northPanel.add(lblDate, cc.xy(2,6));
  	
  	/*
  	 * 3.Setup the central panel
  	 */
  	scrollPane.setViewportView(txtContent);
  	centralPanel.setLayout(new BorderLayout());
  	centralPanel.add(scrollPane, BorderLayout.CENTER);
  	
  	/*
  	 * Some final settings for the components
  	 * of this view.
  	 */
  	txtContent.setEditable(false);
  	scrollPane.setAutoscrolls(true);
  	scrollPane.setWheelScrollingEnabled(true);
  	txtContent.setContentType("text/html");
  	
  }
}

⌨️ 快捷键说明

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