?? viewpanel.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 + -