当前位置: 首页>>代码示例>>Java>>正文


Java JLabel.setHorizontalTextPosition方法代码示例

本文整理汇总了Java中javax.swing.JLabel.setHorizontalTextPosition方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.setHorizontalTextPosition方法的具体用法?Java JLabel.setHorizontalTextPosition怎么用?Java JLabel.setHorizontalTextPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JLabel的用法示例。


在下文中一共展示了JLabel.setHorizontalTextPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTableCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table, 
                                               Object value,
                                               boolean isSelected, 
                                               boolean hasFocus,
                                               int row, 
                                               int column) {
    Component c = tableCellRenderer.getTableCellRendererComponent(table, 
            value, isSelected, hasFocus, row, column);
    if (c instanceof JLabel) {
        JLabel l = (JLabel) c;
        int modelColumn = table.convertColumnIndexToModel(column);
        Directive directive = getDirective(modelColumn);
        if (directive != EMPTY_DIRECTIVE) {
            l.setFont(l.getFont().deriveFont(Font.BOLD));
        }
        l.setHorizontalTextPosition(JLabel.LEFT);
        l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
    }
    return c;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:TableSorter.java

示例2: getTableCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table,
        Object value,
        boolean isSelected,
        boolean hasFocus,
        int row,
        int column) {
    Component c = tableCellRenderer.getTableCellRendererComponent(table,
            value, isSelected, hasFocus, row, column);
    if (c instanceof JLabel) {
        JLabel l = (JLabel) c;
        l.setHorizontalTextPosition(JLabel.LEFT);
        int modelColumn = table.convertColumnIndexToModel(column);
        l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
    }
    return c;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TableSorter.java

示例3: getTableCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table,
        Object value, boolean isSelected, boolean hasFocus, int row,
        int column) {

    Component c =
        tableCellRenderer.getTableCellRendererComponent(table, value,
            isSelected, hasFocus, row, column);

    if (c instanceof JLabel) {
        JLabel l = (JLabel) c;

        l.setHorizontalTextPosition(JLabel.LEFT);

        int modelColumn = table.convertColumnIndexToModel(column);

        l.setIcon(getHeaderRendererIcon(modelColumn,
                                        l.getFont().getSize()));
    }

    return c;
}
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:22,代码来源:TableSorter.java

示例4: initializeComponents

import javax.swing.JLabel; //导入方法依赖的package包/类
private void initializeComponents() {
	progressText = new JLabel(new ImageIcon(ImageTools.scaleToHeight(ImageTools.getResourceImage("iconsmall.png"), 50, false)));
	progressText.setForeground(Color.white);
	progressText.setVerticalTextPosition(JLabel.BOTTOM);
	progressText.setHorizontalTextPosition(JLabel.CENTER);
	cancelButton = new JButton("Cancel");
	
	setContentPane(new JPanel() {
		private static final long serialVersionUID = -8098561857624764691L;
		@Override
		public void paintComponent(Graphics g) {
			setOpaque(false);
			super.paintComponent(g);
			paintBG((Graphics2D) g);
		}
	});
	cancelButton.addActionListener(ae -> {if(onCancel != null) onCancel.actionPerformed(ae);});
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:19,代码来源:ProgressFrame.java

示例5: LabelFrame

import javax.swing.JLabel; //导入方法依赖的package包/类
public LabelFrame()
{
   super("Testing JLabel");
   setLayout(new FlowLayout()); // set frame layout

   // JLabel constructor with a string argument
   label1 = new JLabel("Label with text");
   label1.setToolTipText("This is label1");
   add(label1); // add label1 to JFrame

   // JLabel constructor with string, Icon and alignment arguments
   Icon bug = new ImageIcon(getClass().getResource("bug1.png"));
   label2 = new JLabel("Label with text and icon", bug, 
      SwingConstants.LEFT);
   label2.setToolTipText("This is label2");
   add(label2); // add label2 to JFrame

   label3 = new JLabel(); // JLabel constructor no arguments
   label3.setText("Label with icon and text at bottom");
   label3.setIcon(bug); // add icon to JLabel
   label3.setHorizontalTextPosition(SwingConstants.CENTER);
   label3.setVerticalTextPosition(SwingConstants.BOTTOM);
   label3.setToolTipText("This is label3");
   add(label3); // add label3 to JFrame
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:26,代码来源:LabelFrame.java

示例6: getNoSelectionComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
protected Component getNoSelectionComponent()
{
	JLabel label = new JLabel(getNoSelectionText());

	// Centre it!
	label.setVerticalAlignment(SwingConstants.CENTER);
	label.setHorizontalAlignment(SwingConstants.CENTER);
	label.setVerticalTextPosition(SwingConstants.CENTER);
	label.setHorizontalTextPosition(SwingConstants.CENTER);

	return label;
}
 
开发者ID:equella,项目名称:Equella,代码行数:13,代码来源:AbstractListWithView.java

示例7: initialize

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Initialize the panel
 */
private void initialize() {
	// Initialize dialog layout
	
	JPanel panel = new JPanel(new BorderLayout(BORDERSIZE / 2, BORDERSIZE / 2));
	panel.setBorder(BorderFactory.createEmptyBorder(BORDERSIZE, BORDERSIZE, BORDERSIZE, BORDERSIZE));
	// Adds website image
	JPanel tmpPanel = new JPanel(new BorderLayout(BORDERSIZE, BORDERSIZE));
	// Adds polimi description
	HtmlPanel titleLabel = new HtmlPanel();
	titleLabel.setText(GraphStartScreen.HTML_CONTENT_TITLE_HREF);
	titleLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
	titleLabel.setAlignmentY(Component.CENTER_ALIGNMENT);
	titleLabel.setOpaque(false);
	tmpPanel.add(titleLabel, BorderLayout.CENTER);

	// Adds application title
	title = new JLabel();
	title.setHorizontalTextPosition(SwingConstants.RIGHT);
	title.setHorizontalAlignment(SwingConstants.CENTER);
	title.setIconTextGap(BORDERSIZE);
	tmpPanel.add(title, BorderLayout.SOUTH);

	panel.add(tmpPanel, BorderLayout.NORTH);

	// Adds text area
	mainArea = new JPanel();
	mainArea.setOpaque(false);
	BoxLayout mainLayout = new BoxLayout(mainArea, BoxLayout.Y_AXIS);
	mainArea.setLayout(mainLayout);
	
	panel.add(mainArea, BorderLayout.CENTER);

	JLabel legal = new JLabel(LEGAL);
	panel.add(legal, BorderLayout.SOUTH);
	panel.setPreferredSize(new Dimension(600,480));
	JScrollPane scroll = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	this.add(scroll, BorderLayout.CENTER);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:42,代码来源:AboutDialogPanel.java

示例8: getEntry

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * This is used to create components to be shown inside box
 * @param text text to be displayed inside box
 * @return created component
 */
private Component getEntry(String text) {
	JLabel label = new JLabel("<HTML>" + text + "</HTML>");
	label.setIcon(JMTImageLoader.loadImage("Warning"));
	label.setIconTextGap(BORDER);
	label.setHorizontalTextPosition(SwingConstants.RIGHT);
	label.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
	return label;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:14,代码来源:WarningWindow.java

示例9: TestWizardPanel

import javax.swing.JLabel; //导入方法依赖的package包/类
public TestWizardPanel() {
	counter++;
	name = "Panel " + counter;
	JLabel jl = new JLabel("<html><center>This is <b>" + name + "</b>.<br>Have a nice day!</center></html>");
	jl.setHorizontalAlignment(SwingConstants.CENTER);
	jl.setHorizontalTextPosition(SwingConstants.CENTER);
	jl.setFont(new Font("Arial", Font.PLAIN, 16));
	jl.setBorder(BorderFactory.createEtchedBorder());

	setLayout(new BorderLayout());

	add(jl, BorderLayout.CENTER);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:14,代码来源:TestWizardPanel.java

示例10: updateOnArmiesChange

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Updates the JLabel that belongs to <code>countryInfo</code> with the new
 * number of armies on that country.
 *
 * @param countryInfo
 */
@Override
public void updateOnArmiesChange(CountryInfo countryInfo) {

    JLabel label = countryLabelMap.get(countryInfo.getName());
    label.setForeground(Color.WHITE);
    label.setText(Integer.toString(countryInfo.getArmies()));
    label.setHorizontalTextPosition(JLabel.CENTER);
    label.setIcon(new ImageIcon("src/resources/images/labelCountry/" + countryInfo.getPlayerColor() + "label1.png"));

    repaint(label);
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:18,代码来源:GUI.java

示例11: getTableCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(
      JTable table,
      Object value,
      boolean isSelected,
      boolean hasFocus,
      int row,
      int column) {
      
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
String currentPanel = ((AppFrame)App.getFrame()).workPanel.dailyItemsPanel.getCurrentPanel();

if (d == null) {
          label.setEnabled(false);
	label.setIcon(null);
          label.setBackground(new Color(212, 246, 246));
          return label;
      }
      
if (!isSelected) {
	CalendarDate cpsd = CurrentProject.get().getStartDate();
          CalendarDate cped = CurrentProject.get().getEndDate();
          if (!(((d.after(cpsd)) && (d.before(cped))) || (d.equals(cpsd)) || (d.equals(cped)))) {
		label.setBackground(new Color(212, 246, 246));
		return label;
	}
      }		


label.setHorizontalTextPosition(2);
label.setEnabled(true);



      if (d.equals(CalendarDate.today())) {
          label.setBorder(BorderFactory.createLineBorder(new Color(100, 100, 128)));
      }
      
// set foreground color
if (d.getCalendar().get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
          label.setForeground(new Color(255, 0, 0));
      }
else { 		
	label.setForeground(Color.BLACK);
}

// set background color
if (currentPanel == null)
	label.setBackground(Color.WHITE);

else if (currentPanel.equals("TASKS") && (t != null) && 
	(d.inPeriod(t.getStartDate(), t.getEndDate()))) 
		label.setBackground(new Color(212, 246, 246));

else if(currentPanel.equals("NOTES") && 
CurrentProject.getNoteList().getNoteForDate(d) != null) 
			label.setBackground(new Color(212, 246, 246));

else if(currentPanel.equals("EVENTS") && 
(!(EventsManager.getEventsForDate(d).isEmpty()))) 
			label.setBackground(new Color(212, 246, 246));

else if(!isSelected)
	label.setBackground(Color.WHITE);
		
// always display NREvents
if (EventsManager.isNREventsForDate(d))
	label.setIcon(evIcon);
else
	label.setIcon(null);

      return label;
  }
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:73,代码来源:JNCalendarCellRenderer.java

示例12: getTableCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(
      JTable table,
      Object value,
      boolean isSelected,
      boolean hasFocus,
      int row,
      int column) {
      
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
String currentPanel = ((AppFrame)App.getFrame()).workPanel.dailyItemsPanel.getCurrentPanel();

if (d == null) {
          label.setEnabled(false);
	label.setIcon(null);
          label.setBackground(ColorPanels.highlightColor1);
          return label;
      }
      
if (!isSelected) {
	CalendarDate cpsd = CurrentProject.get().getStartDate();
          CalendarDate cped = CurrentProject.get().getEndDate();
          if (!(((d.after(cpsd)) && (d.before(cped))) || (d.equals(cpsd)) || (d.equals(cped)))) {
          	label.setBackground(ColorPanels.highlightColor1);
		return label;
	}
      }		


label.setHorizontalTextPosition(2);
label.setEnabled(true);



      if (d.equals(CalendarDate.today())) {
          label.setBorder(BorderFactory.createLineBorder(new Color(100, 100, 128)));
      }
      
// set foreground color
if (d.getCalendar().get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
          label.setForeground(new Color(255, 0, 0));
      }
else { 		
	label.setForeground(Color.BLACK);
}

// set background color
if (currentPanel == null)
	label.setBackground(ColorPanels.highlightColor1);

else if (currentPanel.equals("TASKS") && (t != null) && 
	(d.inPeriod(t.getStartDate(), t.getEndDate()))) 
		label.setBackground( new Color(230, 255, 230));

else if(currentPanel.equals("NOTES") && 
CurrentProject.getNoteList().getNoteForDate(d) != null) 
			label.setBackground(new Color(255,245,200));

else if(currentPanel.equals("EVENTS") && 
(!(EventsManager.getEventsForDate(d).isEmpty()))) 
			label.setBackground(new Color(255,230,230));

else if(!isSelected)
	label.setBackground(ColorPanels.highlightColor1);
		
// always display NREvents
if (EventsManager.isNREventsForDate(d))
	label.setIcon(evIcon);
else
	label.setIcon(null);

      return label;
  }
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:73,代码来源:JNCalendarCellRenderer.java

示例13: GlassProgressPane

import javax.swing.JLabel; //导入方法依赖的package包/类
protected GlassProgressPane(final String messageText, final int total, final Component activeComponent,
	final boolean stopClosing, final AdvancedSwingWorker<?> worker, final boolean cancellable)
{
	super(activeComponent, stopClosing);

	this.worker = worker;

	message = new JLabel(messageText);
	message.setForeground(Color.WHITE);
	message.setHorizontalAlignment(SwingConstants.CENTER);
	message.setHorizontalTextPosition(SwingConstants.CENTER);

	Font font = message.getFont();
	message.setFont(new Font(font.getFamily(), Font.BOLD, (int) (font.getSize() * 1.2)));

	progress = new JProgressBar();
	setTotal(total);

	// We cannot I18N the button text, as this class is initialised before
	// CurrentLocale.
	cancel = new JButton("Cancel");
	cancel.addActionListener(new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent e)
		{
			cancel.setEnabled(false);
			GlassProgressPane.this.worker.interrupt();
		}
	});

	final int height1 = message.getPreferredSize().height;
	final int height2 = progress.getPreferredSize().height;
	final int height3 = cancel.getPreferredSize().height;
	final int width1 = cancel.getPreferredSize().width;

	final int[] rows = {height3, TableLayout.FILL, height1, height2, TableLayout.FILL, height3,};
	final int[] cols = {width1, TableLayout.FILL, 100, TableLayout.FILL, width1,};

	setLayout(new TableLayout(rows, cols));
	setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
	add(message, new Rectangle(0, 2, 5, 1));
	add(progress, new Rectangle(2, 3, 1, 1));
	add(cancel, new Rectangle(4, 5, 1, 1));

	setCancellable(cancellable);
}
 
开发者ID:equella,项目名称:Equella,代码行数:48,代码来源:GlassProgressPane.java

示例14: ProgressPanel

import javax.swing.JLabel; //导入方法依赖的package包/类
public ProgressPanel() {
  super();

  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

  progressTotal = new SafeJProgressBar();
  progressTotal.setAlignmentX(CENTER_ALIGNMENT);
  progressTotal.setMaximumSize(new Dimension(250, progressTotal
          .getPreferredSize().height));
  progressTotal.setIndeterminate(true);

  progressSingle = new SafeJProgressBar();
  progressSingle.setAlignmentX(CENTER_ALIGNMENT);
  progressSingle.setMaximumSize(new Dimension(250, progressTotal
          .getPreferredSize().height));
  progressSingle.setIndeterminate(true);
  progressSingle.setVisible(false);
  progressSingle.setMinimum(0);
  progressSingle.setMaximum(100);

  message = new JLabel("");
  message.setIcon(new ProgressIcon(48, 48));
  message.setHorizontalTextPosition(SwingConstants.RIGHT);
  message.setHorizontalAlignment(SwingConstants.CENTER);
  message.setAlignmentX(CENTER_ALIGNMENT);

  dlMsg = new JLabel("Downloading CREOLE Plugin...");
  dlMsg.setIcon(new DownloadIcon(48, 48));
  dlMsg.setHorizontalTextPosition(SwingConstants.RIGHT);
  dlMsg.setHorizontalAlignment(SwingConstants.CENTER);
  dlMsg.setAlignmentX(CENTER_ALIGNMENT);
  dlMsg.setVisible(false);

  add(Box.createVerticalGlue());
  add(message);
  add(Box.createVerticalStrut(5));
  add(progressTotal);
  add(Box.createVerticalStrut(10));
  add(dlMsg);
  add(Box.createVerticalStrut(5));
  add(progressSingle);
  add(Box.createVerticalGlue());

  addComponentListener(this);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:46,代码来源:ProgressPanel.java

示例15: setup

import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public void setup(Set<String> grantedPrivileges, String name)
{
	getButtonActions(actions);

	listFilled = false;
	model = new GenericListModel<NameValue>();

	list = new JList<>(model);
	list.addMouseListener(new ListDoubleClickListener(list, editAction));
	list.addMouseListener(new ListPopupListener(list, actions));
	list.addListSelectionListener(new ListSelectionListener()
	{
		@Override
		public void valueChanged(ListSelectionEvent e)
		{
			updateButtons();
		}
	});

	JScrollPane scroll = new JScrollPane(list);

	JLabel heading = new JLabel(name);
	heading.setHorizontalAlignment(SwingConstants.CENTER);
	heading.setHorizontalTextPosition(SwingConstants.CENTER);

	JButton refreshButton = new JTextlessButton(refreshAction);
	refreshButton.setBorderPainted(false);
	refreshButton.setIconTextGap(0);
	refreshButton.setBorder(null);

	JComponent buttonsComp = createButtonsPanel();

	final int width1 = refreshButton.getPreferredSize().width;
	final int height1 = refreshButton.getPreferredSize().height;
	final int height2 = buttonsComp.getPreferredSize().height;

	final int[] rows = {5, height1, 5, TableLayout.FILL, 5, height2,};
	final int[] cols = {width1, TableLayout.FILL, width1, 5};

	everything = new JPanel(new TableLayout(rows, cols, 0, 0));
	everything.add(heading, new Rectangle(1, 1, 1, 1));
	everything.add(refreshButton, new Rectangle(2, 1, 1, 1));
	everything.add(scroll, new Rectangle(0, 3, 3, 1));
	everything.add(buttonsComp, new Rectangle(0, 5, 3, 1));

	updateButtons();
}
 
开发者ID:equella,项目名称:Equella,代码行数:49,代码来源:AdminToolList.java


注:本文中的javax.swing.JLabel.setHorizontalTextPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。