javax.swing.SwingConstants#TRAILING源码实例Demo

下面列出了javax.swing.SwingConstants#TRAILING 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: HTMLLabel.java
public void setText(String value) {
    txt = value;
    
    Font font = getFont();
    Color fgColor = getForeground();
    Color bgColor = getBackground();
    
    value = value.replaceAll("\\n\\r|\\r\\n|\\n|\\r", "<br>"); //NOI18N
    value = value.replace("<code>", "<code style=\"font-size: " + font.getSize() + "pt;\">"); //NOI18N
    
    String fgText = "rgb(" + fgColor.getRed() + "," + fgColor.getGreen() + "," + fgColor.getBlue() + ")"; //NOI18N
    String bgText = isOpaque() ? "rgb(" + bgColor.getRed() + "," + bgColor.getGreen() + "," + bgColor.getBlue() + ")" : null; //NOI18N
    
    String alignText = null;
    switch (halign) {
        case SwingConstants.CENTER:
            alignText = "center"; //NOI18N
            break;
        case SwingConstants.RIGHT:
        case SwingConstants.TRAILING:
            alignText = "right"; //NOI18N
            break;
    }
    
    String bodyFlags = "text=\"" + fgText + "\""; //NOI18N
    if (bgText != null) bodyFlags += " bgcolor=\"" + bgText + "\""; //NOI18N
    if (alignText != null) bodyFlags += " align=\"" + alignText + "\""; //NOI18N
    
    super.setText("<html><body " + bodyFlags + " style=\"font-size: " + font.getSize() //NOI18N
                  + "pt; font-family: " + font.getName() + ";\">" + value + "</body></html>"); //NOI18N
}
 
源代码2 项目: visualvm   文件: HTMLLabel.java
public void setText(String value) {
    txt = value;
    
    Font font = getFont();
    Color fgColor = getForeground();
    Color bgColor = getBackground();
    
    value = value.replaceAll("\\n\\r|\\r\\n|\\n|\\r", "<br>"); //NOI18N
    value = value.replace("<code>", "<code style=\"font-size: " + font.getSize() + "pt;\">"); //NOI18N
    
    String fgText = "rgb(" + fgColor.getRed() + "," + fgColor.getGreen() + "," + fgColor.getBlue() + ")"; //NOI18N
    String bgText = isOpaque() ? "rgb(" + bgColor.getRed() + "," + bgColor.getGreen() + "," + bgColor.getBlue() + ")" : null; //NOI18N
    
    String alignText = null;
    switch (halign) {
        case SwingConstants.CENTER:
            alignText = "center"; //NOI18N
            break;
        case SwingConstants.RIGHT:
        case SwingConstants.TRAILING:
            alignText = "right"; //NOI18N
            break;
    }
    
    String bodyFlags = "text=\"" + fgText + "\""; //NOI18N
    if (bgText != null) bodyFlags += " bgcolor=\"" + bgText + "\""; //NOI18N
    if (alignText != null) bodyFlags += " align=\"" + alignText + "\""; //NOI18N
    
    super.setText("<html><body " + bodyFlags + " style=\"font-size: " + font.getSize() //NOI18N
                  + "pt; font-family: " + font.getName() + ";\">" + value + "</body></html>"); //NOI18N
}
 
源代码3 项目: spotbugs   文件: PreferencesFrame.java
private void addField(JPanel p, GridBagConstraints c, int y, String lbl, JComponent field) {
    c.gridy = y;
    JLabel l = new JLabel(lbl, SwingConstants.TRAILING);
    l.setLabelFor(field);
    c.anchor = GridBagConstraints.LINE_END;
    c.gridx = 0;
    p.add(l, c);
    c.anchor = GridBagConstraints.LINE_START;
    c.gridx = 1;
    p.add(field, c);
}
 
源代码4 项目: opensim-gui   文件: IKTasksTableModel.java
public void setValue(Object value) {
   IKTasksValueCell obj = (IKTasksValueCell)value;
   super.setFont(regularFont); // reset
   switch(obj.tasks.getValueType(obj.index)) {
      case FromFile: super.setValue(obj.tasks.isValidValue(obj.index) ?  IKTasksTableModel.FromFileStr : IKTasksTableModel.InvalidFromFileStr); break;
      case DefaultValue: super.setValue(((Double)obj.tasks.getDefaultValue(obj.index))); break;
      case ManualValue: super.setValue((Double)obj.tasks.getValue(obj.index)); super.setFont(boldFont); break;
   }
   super.setHorizontalAlignment(SwingConstants.TRAILING);
}
 
源代码5 项目: RipplePower   文件: LayoutStyle.java
private boolean isLeftAligned(AbstractButton button, int position) {
	if (position == SwingConstants.WEST) {
		boolean ltr = button.getComponentOrientation().isLeftToRight();
		int hAlign = button.getHorizontalAlignment();
		return ((ltr && (hAlign == SwingConstants.LEFT || hAlign == SwingConstants.LEADING))
				|| (!ltr && (hAlign == SwingConstants.TRAILING)));
	}
	return false;
}
 
源代码6 项目: RipplePower   文件: LayoutStyle.java
private boolean isRightAligned(AbstractButton button, int position) {
	if (position == SwingConstants.EAST) {
		boolean ltr = button.getComponentOrientation().isLeftToRight();
		int hAlign = button.getHorizontalAlignment();
		return ((ltr && (hAlign == SwingConstants.RIGHT || hAlign == SwingConstants.TRAILING))
				|| (!ltr && (hAlign == SwingConstants.LEADING)));
	}
	return false;
}
 
源代码7 项目: pdfxtk   文件: StyleEditor.java
static boolean validHorizontalKey(int key) {
  return ((key == SwingConstants.LEFT)    ||
   (key == SwingConstants.CENTER)  ||
   (key == SwingConstants.RIGHT)   ||
   (key == SwingConstants.LEADING) ||
   (key == SwingConstants.TRAILING));
}
 
源代码8 项目: opensim-gui   文件: IKTasksTableModel.java
public void setValue(Object value) {
   IKTasksWeightCell obj = (IKTasksWeightCell)value;
   if(obj.tasks.isLocked(obj.index)) super.setValue(IKTasksTableModel.LockedStr);
   else super.setValue((Double)obj.tasks.getWeight(obj.index));
   super.setHorizontalAlignment(SwingConstants.TRAILING);
}
 
源代码9 项目: desktopclient-java   文件: MainFrame.java
private static WebPanel createListPanel(final WebTable list,
                                        String overlayText,
                                        WebToggleButton button) {
    // overlay for empty list
    WebOverlay listOverlay = new WebOverlay(list);
    listOverlay.setOverlayMargin(20);
    final WebTextArea overlayArea = new WebTextArea();
    overlayArea.setText(overlayText);
    overlayArea.setLineWrap(true);
    overlayArea.setWrapStyleWord(true);
    overlayArea.setMargin(View.MARGIN_DEFAULT);
    overlayArea.setFontSize(View.FONT_SIZE_BIG);
    overlayArea.setEditable(false);
    BorderPainter<WebTextArea> borderPainter = new BorderPainter<>(Color.LIGHT_GRAY);
    borderPainter.setRound(15);
    overlayArea.setPainter(borderPainter);
    list.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            overlayArea.setVisible(list.getModel().getRowCount() == 0);
        }
    });
    overlayArea.setVisible(list.getModel().getRowCount() == 0);
    listOverlay.addOverlay(overlayArea, SwingConstants.CENTER, SwingConstants.CENTER);

    WebScrollPane scrollPane = new ComponentUtils.ScrollPane(listOverlay);
    scrollPane.setDrawBorder(false);

    // button as overlay
    button.setOpaque(false);
    button.setUndecorated(true);
    WebOverlay chatListOverlay = new WebOverlay(scrollPane,
            button, SwingConstants.TRAILING, SwingConstants.BOTTOM);
    chatListOverlay.setOverlayMargin(0, 0, View.GAP_BIG, View.GAP_BIG + SCROLL_BAR_WIDTH);
    // fixing overlay button paint bug on startup, dont wanna know whats happening here
    SwingUtils.delayInvokeLater(0, new Runnable() {
        @Override
        public void run() {
            TooltipManager.showOneTimeTooltip(list, new Point(1,1), "");
        }
    });

    return chatListOverlay;
}
 
源代码10 项目: importer-exporter   文件: ExportStatusDialog.java
private void initGUI(String impExpTitle, String impExpMessage) {
	setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	fileName = new JLabel(impExpMessage);
	fileName.setFont(fileName.getFont().deriveFont(Font.BOLD));
	messageLabel = new JLabel(" ");
	cancelButton = new JButton(Language.I18N.getString("common.button.cancel"));
	featureLabel = new JLabel(Language.I18N.getString("common.status.dialog.featureCounter"));
	appearanceLabel = new JLabel(Language.I18N.getString("common.status.dialog.appearanceCounter"));
	textureLabel = new JLabel(Language.I18N.getString("common.status.dialog.textureCounter"));

	featureCounterLabel = new JLabel("0", SwingConstants.TRAILING);
	appearanceCounterLabel = new JLabel("0", SwingConstants.TRAILING);
	textureCounterLabel = new JLabel("0", SwingConstants.TRAILING);
	featureCounterLabel.setPreferredSize(new Dimension(100, featureLabel.getPreferredSize().height));
	appearanceCounterLabel.setPreferredSize(new Dimension(100, appearanceLabel.getPreferredSize().height));
	textureCounterLabel.setPreferredSize(new Dimension(100, textureLabel.getPreferredSize().height));

	progressBar = new JProgressBar();

	setLayout(new GridBagLayout()); 
	{			
		main = new JPanel();
		add(main, GuiUtil.setConstraints(0,0,1.0,0.0,GridBagConstraints.BOTH,5,5,5,5));
		main.setLayout(new GridBagLayout());
		{
			int gridY = 0;

			main.add(fileName, GuiUtil.setConstraints(0,gridY++,0.0,0,GridBagConstraints.HORIZONTAL,5,5,5,5));
			main.add(messageLabel, GuiUtil.setConstraints(0,gridY++,0.0,0,GridBagConstraints.HORIZONTAL,5,5,0,5));
			main.add(progressBar, GuiUtil.setConstraints(0,gridY++,1.0,0.0,GridBagConstraints.HORIZONTAL,0,5,5,5));

			details = new JLabel("Details");
			main.add(details, GuiUtil.setConstraints(0,gridY++,1.0,0.0,GridBagConstraints.HORIZONTAL,5,5,0,5));

			row = new JPanel();
			row.setBackground(new Color(255, 255, 255));
			row.setBorder(BorderFactory.createEtchedBorder());
			main.add(row, GuiUtil.setConstraints(0,gridY++,1.0,0.0,GridBagConstraints.BOTH,0,5,5,5));
			row.setLayout(new GridBagLayout());
			{
				row.add(featureLabel, GuiUtil.setConstraints(0,0,0.0,0.0,GridBagConstraints.HORIZONTAL,5,5,1,5));
				row.add(featureCounterLabel, GuiUtil.setConstraints(1,0,1.0,0.0,GridBagConstraints.HORIZONTAL,5,5,1,5));
				row.add(appearanceLabel, GuiUtil.setConstraints(0,1,0.0,0.0,GridBagConstraints.HORIZONTAL,1,5,1,5));
				row.add(appearanceCounterLabel, GuiUtil.setConstraints(1,1,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,1,5));
				row.add(textureLabel, GuiUtil.setConstraints(0,2,0.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));
				row.add(textureCounterLabel, GuiUtil.setConstraints(1,2,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));

				if (showTileCounter) {
					tileLabel = new JLabel(Language.I18N.getString("common.status.dialog.tileCounter"));
					tileCounterLabel = new JLabel("n/a", SwingConstants.TRAILING);
					tileCounterLabel.setPreferredSize(new Dimension(100, tileCounterLabel.getPreferredSize().height));

					row.add(tileLabel, GuiUtil.setConstraints(0,3,0.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));
					row.add(tileCounterLabel, GuiUtil.setConstraints(1,3,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));
				}
			}
		}

		add(cancelButton, GuiUtil.setConstraints(0,1,0.0,0.5,GridBagConstraints.NONE,5,5,5,5));
	}

	pack();
	progressBar.setIndeterminate(true);

	addWindowListener(new WindowAdapter() {
		public void windowClosed(WindowEvent e) {
			eventDispatcher.removeEventHandler(ExportStatusDialog.this);
		}
	});
}
 
private void initGUI(String windowTitle, 
		String statusTitle, 
		String statusMessage, 
		String statusDetails, 
		boolean setButton) {
	
	if (statusTitle == null)
		statusTitle = "";
	
	if (statusMessage == null)
		statusMessage = "";
	
	String[] details = null;
	if (statusDetails != null)
		details = statusDetails.split("<br\\s*/*>");
	
	setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	titleLabel = new JLabel(statusTitle);
	titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
	messageLabel = new JLabel(statusMessage);
	fileCounter = new JLabel(Language.I18N.getString("common.status.dialog.fileCounter"));
	fileCounterLabel = new JLabel("n/a", SwingConstants.TRAILING);
	button = new JButton(Language.I18N.getString("common.button.cancel"));		
	progressBar = new JProgressBar();

	setLayout(new GridBagLayout()); {
		main = new JPanel();
		add(main, GuiUtil.setConstraints(0,0,1.0,0.0,GridBagConstraints.BOTH,5,5,5,5));
		main.setLayout(new GridBagLayout());
		{
			main.add(titleLabel, GuiUtil.setConstraints(0,0,0.0,0.5,GridBagConstraints.HORIZONTAL,5,5,5,5));
			main.add(messageLabel, GuiUtil.setConstraints(0,1,0.0,0.5,GridBagConstraints.HORIZONTAL,5,5,0,5));
			main.add(progressBar, GuiUtil.setConstraints(0,2,1.0,0.0,GridBagConstraints.HORIZONTAL,0,5,5,5));

			if (details != null) {
				detailsLabel = new JLabel("Details");
				main.add(detailsLabel, GuiUtil.setConstraints(0,3,1.0,0.0,GridBagConstraints.HORIZONTAL,5,5,0,5));

				row = new JPanel();
				row.setBackground(new Color(255, 255, 255));
				row.setBorder(BorderFactory.createEtchedBorder());
				main.add(row, GuiUtil.setConstraints(0,4,1.0,0.0,GridBagConstraints.BOTH,0,5,5,5));
				row.setLayout(new GridBagLayout());
				{				
					int i = 0;
					for ( ; i < details.length; ++i) {
						JLabel detail = new JLabel(details[i]);
						detail.setBackground(row.getBackground());
						GridBagConstraints c = GuiUtil.setConstraints(0,i,1.0,0.0,GridBagConstraints.HORIZONTAL,i == 0 ? 5 : 2,5,i == details.length - 1 ? 5 : 0,5);
						c.gridwidth = 2;
						row.add(detail, c);
					}
					
					row.add(fileCounter, GuiUtil.setConstraints(0,i+1,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));
					row.add(fileCounterLabel, GuiUtil.setConstraints(1,i+1,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));
				}
			}
		}

		if (setButton)
			add(button, GuiUtil.setConstraints(0,1,0.0,0.0,GridBagConstraints.NONE,5,5,5,5));

		pack();
		progressBar.setIndeterminate(true);
		
		addWindowListener(new WindowAdapter() {
			public void windowClosed(WindowEvent e) {
				if (eventDispatcher != null)
					eventDispatcher.removeEventHandler(XMLValidationStatusDialog.this);
			}
		});
	}
}
 
源代码12 项目: importer-exporter   文件: ImportStatusDialog.java
private void initGUI(String impExpTitle, String impExpMessage) {
	setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	fileName = new JLabel(impExpMessage);
	fileName.setFont(fileName.getFont().deriveFont(Font.BOLD));
	mesageLabel = new JLabel(" ");
	cancelButton = new JButton(Language.I18N.getString("common.button.cancel"));
	featureLabel = new JLabel(Language.I18N.getString("common.status.dialog.featureCounter"));
	appearanceLabel = new JLabel(Language.I18N.getString("common.status.dialog.appearanceCounter"));
	textureLabel = new JLabel(Language.I18N.getString("common.status.dialog.textureCounter"));
	fileCounter = new JLabel(Language.I18N.getString("common.status.dialog.fileCounter"));
	fileCounterLabel = new JLabel("n/a", SwingConstants.TRAILING);
	featureCounterLabel = new JLabel("0", SwingConstants.TRAILING);
	appearanceCounterLabel = new JLabel("0", SwingConstants.TRAILING);
	textureCounterLabel = new JLabel("0", SwingConstants.TRAILING);

	featureCounterLabel.setPreferredSize(new Dimension(100, featureLabel.getPreferredSize().height));
	appearanceCounterLabel.setPreferredSize(new Dimension(100, appearanceLabel.getPreferredSize().height));
	textureCounterLabel.setPreferredSize(new Dimension(100, textureLabel.getPreferredSize().height));

	progressBar = new JProgressBar();

	setLayout(new GridBagLayout()); 
	{			
		main = new JPanel();
		add(main, GuiUtil.setConstraints(0,0,1.0,0.0,GridBagConstraints.BOTH,5,5,5,5));
		main.setLayout(new GridBagLayout());
		{
			main.add(fileName, GuiUtil.setConstraints(0,0,0.0,0,GridBagConstraints.HORIZONTAL,5,5,5,5));
			main.add(mesageLabel, GuiUtil.setConstraints(0,1,0.0,0,GridBagConstraints.HORIZONTAL,5,5,0,5));
			main.add(progressBar, GuiUtil.setConstraints(0,2,1.0,0.0,GridBagConstraints.HORIZONTAL,0,5,5,5));

			details = new JLabel("Details");
			main.add(details, GuiUtil.setConstraints(0,3,1.0,0.0,GridBagConstraints.HORIZONTAL,5,5,0,5));

			row = new JPanel();
			row.setBackground(new Color(255, 255, 255));
			row.setBorder(BorderFactory.createEtchedBorder());
			main.add(row, GuiUtil.setConstraints(0,4,1.0,0.0,GridBagConstraints.BOTH,0,5,5,5));
			row.setLayout(new GridBagLayout());
			{
				row.add(featureLabel, GuiUtil.setConstraints(0,0,0.0,0.0,GridBagConstraints.HORIZONTAL,5,5,1,5));
				row.add(featureCounterLabel, GuiUtil.setConstraints(1,0,1.0,0.0,GridBagConstraints.HORIZONTAL,5,5,1,5));
				row.add(appearanceLabel, GuiUtil.setConstraints(0,1,0.0,0.0,GridBagConstraints.HORIZONTAL,1,5,1,5));
				row.add(appearanceCounterLabel, GuiUtil.setConstraints(1,1,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,1,5));
				row.add(textureLabel, GuiUtil.setConstraints(0,2,0.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));
				row.add(textureCounterLabel, GuiUtil.setConstraints(1,2,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));
				row.add(fileCounter, GuiUtil.setConstraints(0,3,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));
				row.add(fileCounterLabel, GuiUtil.setConstraints(1,3,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));
			}
		}

		add(cancelButton, GuiUtil.setConstraints(0,1,0.0,0.5,GridBagConstraints.NONE,5,5,5,5));
	}

	pack();
	progressBar.setIndeterminate(true);

	addWindowListener(new WindowAdapter() {
		public void windowClosed(WindowEvent e) {
			eventDispatcher.removeEventHandler(ImportStatusDialog.this);
		}
	});
}