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


Java JLabel.setBorder方法代码示例

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


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

示例1: initGUI

import javax.swing.JLabel; //导入方法依赖的package包/类
private void initGUI() {
	this.setIconImage(JMTImageLoader.loadImage(IMG_JWATICON).getImage());
	this.setResizable(false);
	this.setTitle("JWAT");
	this.setSize(CommonConstants.MAX_GUI_WIDTH_JWAT_STARTSCREEN, CommonConstants.MAX_GUI_HEIGHT_JWAT_STARTSCREEN);
	//Image image = new ImageIcon(imageURL).getImage();
	//image = image.getScaledInstance(400, 315, Image.SCALE_SMOOTH);
	JPanel eastPanel = new JPanel(new BorderLayout());
	eastPanel.add(Box.createVerticalStrut(5), BorderLayout.NORTH);
	JPanel buttonPanel = new JPanel(new GridLayout(buttonAction.length, 1, 2, 2));
	eastPanel.add(buttonPanel, BorderLayout.CENTER);
	for (AbstractAction element : buttonAction) {
		buttonPanel.add(createButton(element));
	}
	JLabel imageLabel = new JLabel();
	imageLabel.setBorder(BorderFactory.createEmptyBorder(BUTTONSIZE - 5, 1, 0, 0));
	//imageLabel.setIcon(new ImageIcon(image));
	imageLabel.setIcon(new ImageIcon(new ImageIcon(imageURL).getImage().getScaledInstance(400, 315, Image.SCALE_SMOOTH)));
	imageLabel.setHorizontalAlignment(SwingConstants.RIGHT);
	imageLabel.setVerticalAlignment(SwingConstants.NORTH);
	this.getContentPane().add(imageLabel, BorderLayout.CENTER);
	this.getContentPane().add(eastPanel, BorderLayout.EAST);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:24,代码来源:JWatStartScreen.java

示例2: getListCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Action[] actions = ((AbstractSummaryView.ActionsItem) value).getParent().getUserData().getActions();
    id = ((AbstractSummaryView.ActionsItem) value).getItemId();
    removeAll();
    labels = new HashMap<Component, Action>(actions.length);
    Component comp = dlcr.getListCellRendererComponent(list, "<html><a href=\"action\">ACTION_NAME</a>", index, isSelected, cellHasFocus); //NOI18N
    setBackground(comp.getBackground());
    for (Action a : actions) {
        JLabel label = getLabelFor((String) a.getValue(Action.NAME), isSelected ? comp.getForeground() : LINK_COLOR);
        label.setForeground(comp.getForeground());
        label.setBackground(comp.getBackground());
        label.setBorder(BorderFactory.createEmptyBorder());
        labels.put(label, a);
        add(label);
    }
    if (linkerSupport.getLinker(ActionHyperlink.class, id) == null) {
        linkerSupport.add(new ActionHyperlink(), id);
    }
    return this;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:SummaryCellRenderer.java

示例3: buildContentLoadingLabel

import javax.swing.JLabel; //导入方法依赖的package包/类
private JComponent buildContentLoadingLabel() {
    JLabel label = new JLabel( BundleSupport.getLabel( "ContentLoading" ) ); // NOI18N
    label.setHorizontalAlignment( JLabel.CENTER );
    label.setVerticalAlignment( JLabel.CENTER );
    label.setOpaque( false );
    Component header = getContentHeader();
    if( null != header ) {
        JPanel panel = new JPanel( new GridBagLayout() );
        panel.setOpaque( false );
        panel.add( header, new GridBagConstraints(0,0,1,1,1.0,1.0,
            GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0 ) );
        panel.add( label, new GridBagConstraints(0,1,1,1,1.0,1.0,
            GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0 ) );
        panel.setBorder( BorderFactory.createEmptyBorder(40, 0, 40, 0));
        return panel;
    }
    label.setBorder( BorderFactory.createEmptyBorder(40, 0, 40, 0));
    return label;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:RSSFeed.java

示例4: createAndShowGUI

import javax.swing.JLabel; //导入方法依赖的package包/类
private static void createAndShowGUI() {

        try {
            UIManager.setLookAndFeel(new TestLookAndFeel());

            JLabel label = new JLabel("Test Label");
            label.setSize(SIZE, SIZE);
            TitledBorder border = new TitledBorder("ABCDEF");
            label.setBorder(new TitledBorder(border));

            if (useLAF) {
                UIManager.setLookAndFeel(new NimbusLookAndFeel());
            } else {
                UIManager.getDefaults().put("LabelUI", MetalLabelUI.class.getName());
            }

            SwingUtilities.updateComponentTreeUI(label);

            paintToImage(label);

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:TitledBorderLabelUITest.java

示例5: createStatusBar

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * 
 */
protected JLabel createStatusBar()
{
	JLabel statusBar = new JLabel(mxResources.get("ready"));
	statusBar.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));

	return statusBar;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:11,代码来源:BasicGraphEditor.java

示例6: getTableCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
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);
	if (tableModel.hasError(row, column)) {
		if (errorHandlingCheckBox.isSelected()) {
			label.setBorder(WARNING_BORDER);
		} else {
			label.setBorder(ERROR_BORDER);
		}
	}
	return label;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:ConfigureDataView.java

示例7: createSetsCountLabel

import javax.swing.JLabel; //导入方法依赖的package包/类
private JLabel createSetsCountLabel() {
    JLabel label = new JLabel("Sets found: 0.");
    label.setOpaque(true);
    label.setBackground(Color.gray);
    label.setBorder(new EmptyBorder(10, 10, 10, 10));
    return label;
}
 
开发者ID:mlpinit,项目名称:GameOfSet,代码行数:8,代码来源:InfoPanel.java

示例8: createLeftPanel

import javax.swing.JLabel; //导入方法依赖的package包/类
void createLeftPanel() {
	Box leftBox = Box.createVerticalBox();
	leftBox.setOpaque(true);
	leftBox.setBackground(StaticResource.titleColor);

	JLabel title = new JLabel(getString("CONFIG_TITLE"));
	title.setForeground(Color.white);
	title.setFont(title.getFont().deriveFont(Font.BOLD,
			title.getFont().getSize() * 1.2f));
	title.setBorder(new EmptyBorder(20, 20, 20, 40));

	leftBox.add(title);

	centerPanel.add(leftBox, BorderLayout.WEST);

	arrLbl = new JLabel[9];

	for (int i = 0; i < 9; i++) {
		String id = "CONFIG_LBL" + (i + 1);
		arrLbl[i] = new JLabel(getString(id));
		arrLbl[i].setName(id);
		arrLbl[i].addMouseListener(clickHandler);
		arrLbl[i].setForeground(Color.white);
		arrLbl[i].setFont(plainFont);
		arrLbl[i].setBorder(new EmptyBorder(5, 20, 5, 20));
		leftBox.add(arrLbl[i]);
	}
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:29,代码来源:ConfigDialog.java

示例9: ContentSection

import javax.swing.JLabel; //导入方法依赖的package包/类
public ContentSection( String title, JComponent content, boolean maxSize ) {
    this( content, maxSize, 0 );
    JLabel lblTitle = new JLabel( title );
    lblTitle.setFont( SECTION_HEADER_FONT );

    lblTitle.setBorder( BorderFactory.createEmptyBorder(0, 0, 20, 0) );
    lblTitle.setForeground( Utils.getColor( COLOR_SECTION_HEADER ) );
    add( lblTitle, new GridBagConstraints(0,0,1,1,0.0,0.0,
            GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(6,0,0,0),0,0) );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ContentSection.java

示例10: TaskPanel

import javax.swing.JLabel; //导入方法依赖的package包/类
public TaskPanel(String name, Thread task) {
	super( new BorderLayout() );

	this.name = name;
	this.task = task;

	JLabel nameL = new JLabel(name);
	nameL.setBorder(BorderFactory.createEmptyBorder(1, 2, 1, 1));
	add(nameL, BorderLayout.NORTH);

	if (task instanceof StartStopThread) {
		JButton stopB = new JButton("X");
		stopB.setMargin( new Insets(0,1,0,1));
		stopB.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				TaskPanel.this.task.interrupt();
				((StartStopThread) TaskPanel.this.task).stopTask();
			}
		});
		add(stopB, BorderLayout.EAST);
	}
	JProgressBar pb = new JProgressBar();
	pb.setIndeterminate(true);
	add(pb);

	setBorder( BorderFactory.createLineBorder(Color.black));

	int minWidth = getMinimumSize().width;
	int minHeight = getMinimumSize().height;
	int maxWidth = getMaximumSize().width;

	setPreferredSize(new Dimension(minWidth, minHeight));
	setMaximumSize(new Dimension(maxWidth, minHeight));
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:35,代码来源:ProcessingDialog.java

示例11: ParameterizedCompletionDescriptionToolTip

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
 * Constructor.
 *
 * @param owner The parent window.
 * @param ac The parent auto-completion.
 * @param pc The completion being described.
 */
public ParameterizedCompletionDescriptionToolTip(Window owner,
		ParameterizedCompletionContext context,
		AutoCompletion ac, ParameterizedCompletion pc) {

	tooltip = new JWindow(owner);

	this.pc = pc;

	descLabel = new JLabel();
	descLabel.setBorder(BorderFactory.createCompoundBorder(
				TipUtil.getToolTipBorder(),
				BorderFactory.createEmptyBorder(2, 5, 2, 5)));
	descLabel.setOpaque(true);
	descLabel.setBackground(TipUtil.getToolTipBackground());
	// It appears that if a JLabel is set as a content pane directly, when
	// using the JDK's opacity API's, it won't paint its background, even
	// if label.setOpaque(true) is called.  You have to have a container
	// underneath it for it to paint its background.  Thus, we embed our
	// label in a parent JPanel to handle this case.
	//tooltip.setContentPane(descLabel);
	JPanel panel = new JPanel(new BorderLayout());
	panel.add(descLabel);
	tooltip.setContentPane(panel);

	// Give apps a chance to decorate us with drop shadows, etc.
	PopupWindowDecorator decorator = PopupWindowDecorator.get();
	if (decorator!=null) {
		decorator.decorate(tooltip);
	}

	updateText(0);

	tooltip.setFocusableWindowState(false);

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:43,代码来源:ParameterizedCompletionDescriptionToolTip.java

示例12: 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:HOMlab,项目名称:QN-ACTR-Release,代码行数:14,代码来源:WarningWindow.java

示例13: ImportClassPanel

import javax.swing.JLabel; //导入方法依赖的package包/类
/** Creates new form ImportClassPanel */
   public ImportClassPanel(List<TypeElement> priviledged, List<TypeElement> denied, Font font, JavaSource javaSource, int position, JTextComponent target ) {
       // System.err.println("priviledged=" + priviledged);
       // System.err.println("denied=" + denied);
       this.javaSource = javaSource;
       this.position = position;
       this.target = target;
       createModel(priviledged, denied);
       initComponents();
       setBackground(jList1.getBackground());
       
       if ( model.size() > 0) {
           jList1.setModel( model );
           setFocusable(false);        
           setNextFocusableComponent(jList1);
           jScrollPane1.setBackground( jList1.getBackground() );
           setBackground( jList1.getBackground() );
           if ( font != null ) {
               jList1.setFont(font);
           }
           int modelSize = jList1.getModel().getSize();
           if ( modelSize > 0 ) {
               jList1.setSelectedIndex(0);            
           }
           jList1.setVisibleRowCount( modelSize > 8 ? 8 : modelSize );
           jList1.setCellRenderer( new Renderer( jList1 ) );
           jList1.grabFocus();
       }
       else {            
           remove( jScrollPane1 );
           JLabel nothingFoundJL = new JLabel("<No Classes Found>");
           if ( font != null ) {
               nothingFoundJL.setFont(font);
           }
           nothingFoundJL.setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 4, 4, 4));
           nothingFoundJL.setEnabled(false);
           nothingFoundJL.setBackground(jList1.getBackground());
           //nothingFoundJL.setOpaque(true);
           add( nothingFoundJL );
       }

setA11Y();
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:ImportClassPanel.java

示例14: getTableCellRendererComponent

import javax.swing.JLabel; //导入方法依赖的package包/类
/**
   * Based on panel selected show markings and content related to its 
   * duration in the calendar.
   */
  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(ColorMap.NULLDAY);
          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(ColorMap.NOPROJECT);
		return label;
	}
      }



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



      if (d.equals(CalendarDate.today())) {
          label.setBorder(BorderFactory.createLineBorder(ColorMap.TODAY));
      }
      
// set foreground color
if (d.getCalendar().get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
          label.setForeground(ColorMap.SUNDAYTEXT);
      }
else { 		
	label.setForeground(ColorMap.DAYTEXT);
}

// set background color
if (currentPanel == null)
	label.setBackground(ColorMap.FREEBG);

else if (currentPanel.equals("TASKS") && (t != null) && 
	(d.inPeriod(t.getStartDate(), t.getEndDate()))) 
		label.setBackground(ColorMap.TASKBG);

else if(currentPanel.equals("NOTES") && 
CurrentProject.getNoteList().getNoteForDate(d) != null) 
			label.setBackground(ColorMap.NOTEBG);

else if(currentPanel.equals("EVENTS") && 
(!(EventsManager.getEventsForDate(d).isEmpty()))) 
			label.setBackground(ColorMap.EVENTBG);

else if(!isSelected)
	label.setBackground(ColorMap.FREEBG);
else {
	label.setBackground(ColorMap.DAYSELECT);
}
// always display NREvents
if (EventsManager.isNonRepeatingEventsForDate(d))
	label.setIcon(IconFontSwing.buildIcon(GoogleMaterialDesignIcons.PRIORITY_HIGH, 24, ColorMap.PRIORITY));
else
	label.setIcon(null);

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

示例15: createLeftLabel

import javax.swing.JLabel; //导入方法依赖的package包/类
private JLabel createLeftLabel(String key) {
    JLabel result = Utility.localizedLabel(key);
    result.setBorder(Utility.LEFTCELLBORDER);
    return result;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:6,代码来源:ReportTradePanel.java


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