本文整理匯總了Java中javax.swing.JLabel.add方法的典型用法代碼示例。如果您正苦於以下問題:Java JLabel.add方法的具體用法?Java JLabel.add怎麽用?Java JLabel.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.add方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initTitlePanel
import javax.swing.JLabel; //導入方法依賴的package包/類
private void initTitlePanel(){
preYear = new JLabel("<<", JLabel.CENTER);
preMonth = new JLabel("<", JLabel.CENTER);
center = new JLabel("", JLabel.CENTER);
centercontainer = new JLabel("", JLabel.CENTER);
nextMonth = new JLabel(">", JLabel.CENTER);
nextYear = new JLabel(">>", JLabel.CENTER);
preYear.setToolTipText("Last Year");
preMonth.setToolTipText("Last Month");
nextMonth.setToolTipText("Next Month");
nextYear.setToolTipText("Next Year");
preYear.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 10, 0, 0));
preMonth.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 15, 0, 0));
nextMonth.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 0, 0, 15));
nextYear.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 0, 0, 10));
centercontainer.setLayout(new java.awt.BorderLayout());
centercontainer.add(preMonth,java.awt.BorderLayout.WEST);
centercontainer.add(center,java.awt.BorderLayout.CENTER);
centercontainer.add(nextMonth,java.awt.BorderLayout.EAST);
this.add(preYear,java.awt.BorderLayout.WEST);
this.add(centercontainer,java.awt.BorderLayout.CENTER);
this.add(nextYear,java.awt.BorderLayout.EAST);
this.setPreferredSize(new java.awt.Dimension(210, 25));
updateDate();
preYear.addMouseListener(new MyMouseAdapter(preYear, Calendar.YEAR, -1));
preMonth.addMouseListener(new MyMouseAdapter(preMonth, Calendar.MONTH, -1));
nextMonth.addMouseListener(new MyMouseAdapter(nextMonth, Calendar.MONTH, 1));
nextYear.addMouseListener(new MyMouseAdapter(nextYear, Calendar.YEAR, 1));
}