本文整理了Java中javax.swing.JTextField.getFont()
方法的一些代码示例,展示了JTextField.getFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextField.getFont()
方法的具体详情如下:
包路径:javax.swing.JTextField
类名称:JTextField
方法名:getFont
暂无
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Returns true if the given mouse event occurred within a highlight h on label.
*/
public static boolean isInHighlight(MouseEvent e, JTextField label, Highlighter h) {
Highlight[] hls = h.getHighlights();
if(hls == null || hls.length == 0)
return false;
Highlight hl = hls[0];
FontMetrics fm = label.getFontMetrics(label.getFont());
int offset = getCharOffset(fm, label.getText(), e.getX());
return hl.getStartOffset() <= offset && offset < hl.getEndOffset();
}
代码示例来源:origin: org.softsmithy.lib/softsmithy-lib-swing
@Override
public Font getDefaultFont() {
return super.getFont();
}
代码示例来源:origin: org.softsmithy.lib/lib-core
@Override
public Font getDefaultFont() {
return super.getFont();
}
代码示例来源:origin: stanfordnlp/CoreNLP
private boolean addHighlight(JTextField label, MouseEvent mouseEvent1, MouseEvent mouseEvent2) {
//Two parts: adding the highlight on the label, and scrolling the list appropriately
//HighlightUtils handles the first part, we handle the second part here
boolean highlightSuccessful = HighlightUtils.addHighlight(label, mouseEvent1, mouseEvent2);
FontMetrics fm = label.getFontMetrics(label.getFont());
int firstXpos = mouseEvent1.getX();
int lastXpos = mouseEvent2.getX();
int firstOffset = getCharOffset(fm, label.getText(), firstXpos);
int lastOffset = getCharOffset(fm, label.getText(), lastXpos);
if(lastOffset != firstOffset) {
if(firstOffset > lastOffset) {
int tmp = firstOffset;
firstOffset = lastOffset;
lastOffset = tmp;
}
Rectangle curVisible = list.getVisibleRect();
if(lastXpos > curVisible.x+curVisible.width) {
list.scrollRectToVisible(new Rectangle(new Point(lastXpos-curVisible.width, curVisible.y), curVisible.getSize()));
} else if(lastXpos < curVisible.x) {
list.scrollRectToVisible(new Rectangle(new Point(lastXpos, curVisible.y), curVisible.getSize()));
}
list.repaint();
return highlightSuccessful;
} else
return false;
}
代码示例来源:origin: IanDarwin/javasrc
public void stateChanged(ChangeEvent evt) {
JSlider sl = (JSlider)evt.getSource();
Font oldf = tf.getFont();
Font newf = oldf.deriveFont((float)sl.getValue());
tf.setFont(newf);
}
});
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Highlight the given label from the first mouse event to the second
* Returns true if the highlight was successful, false otherwise.
*/
public static boolean addHighlight(JTextField label, MouseEvent mouseEvent1, MouseEvent mouseEvent2) {
FontMetrics fm = label.getFontMetrics(label.getFont());
int firstXpos = mouseEvent1.getX();
int lastXpos = mouseEvent2.getX();
int firstOffset = getCharOffset(fm, label.getText(), firstXpos);
int lastOffset = getCharOffset(fm, label.getText(), lastXpos);
if(lastOffset != firstOffset) {
if(firstOffset > lastOffset) {
int tmp = firstOffset;
firstOffset = lastOffset;
lastOffset = tmp;
}
try {
label.getHighlighter().removeAllHighlights();
label.getHighlighter().addHighlight(firstOffset, lastOffset, new DefaultHighlighter.DefaultHighlightPainter(Color.yellow));
return true;
} catch (BadLocationException e1) {
return false;
}
} else
return false;
}
代码示例来源:origin: fr.ifremer/isis-fish
protected void createServerPublicKeyFile() {
$objectMap.put("serverPublicKeyFile", serverPublicKeyFile = new JTextField());
serverPublicKeyFile.setName("serverPublicKeyFile");
serverPublicKeyFile.setColumns(15);
serverPublicKeyFile.setColumns(28);
serverPublicKeyFile.setEditable(false);
if (serverPublicKeyFile.getFont() != null) {
serverPublicKeyFile.setFont(serverPublicKeyFile.getFont().deriveFont((float) 12));
}
SwingUtil.setComponentHeight(serverPublicKeyFile,25);
}
代码示例来源:origin: edu.stanford.nlp/stanford-corenlp
/**
* Returns true if the given mouse event occurred within a highlight h on label.
*/
public static boolean isInHighlight(MouseEvent e, JTextField label, Highlighter h) {
Highlight[] hls = h.getHighlights();
if(hls == null || hls.length == 0)
return false;
Highlight hl = hls[0];
FontMetrics fm = label.getFontMetrics(label.getFont());
int offset = getCharOffset(fm, label.getText(), e.getX());
return hl.getStartOffset() <= offset && offset < hl.getEndOffset();
}
代码示例来源:origin: mikaelhg/openblocks
/**
* Whenever the search bar loses focus and has an empty document,
* put "Search blocks" in gray italics.
*/
private void resetSearchBar() {
if (searchBar.getText().trim().equals("")) {
Font font = searchBar.getFont();
searchBar.setFont(new Font(font.getName(), Font.ITALIC, font.getSize()));
searchBar.setForeground(Color.GRAY);
searchBar.setText(defaultText);
}
}
代码示例来源:origin: fr.ifremer/isis-fish
protected void createServerPrivateKeyFile() {
$objectMap.put("serverPrivateKeyFile", serverPrivateKeyFile = new JTextField());
serverPrivateKeyFile.setName("serverPrivateKeyFile");
serverPrivateKeyFile.setColumns(15);
serverPrivateKeyFile.setColumns(28);
serverPrivateKeyFile.setEditable(false);
if (serverPrivateKeyFile.getFont() != null) {
serverPrivateKeyFile.setFont(serverPrivateKeyFile.getFont().deriveFont((float) 12));
}
SwingUtil.setComponentHeight(serverPrivateKeyFile,25);
}
代码示例来源:origin: fr.ifremer/isis-fish
protected void createMailTo() {
$objectMap.put("mailTo", mailTo = new JTextField());
mailTo.setName("mailTo");
mailTo.setColumns(15);
mailTo.setColumns(30);
if (mailTo.getFont() != null) {
mailTo.setFont(mailTo.getFont().deriveFont((float) 11));
}
SwingUtil.setComponentHeight(mailTo,20);
}
代码示例来源:origin: fr.ifremer/isis-fish
protected void createArchivePath() {
$objectMap.put("archivePath", archivePath = new JTextField());
archivePath.setName("archivePath");
archivePath.setColumns(15);
archivePath.setColumns(30);
if (archivePath.getFont() != null) {
archivePath.setFont(archivePath.getFont().deriveFont((float) 11));
}
SwingUtil.setComponentHeight(archivePath,25);
}
代码示例来源:origin: stackoverflow.com
public static void main(String [] args) {
JFrame frame = new JFrame();
JTextField small = new JTextField("small");
JTextField big = new JTextField("big");
big.setFont(big.getFont().deriveFont(Font.BOLD, 40));
big.setPreferredSize(new Dimension(123, 20));
big.setMaximumSize(new Dimension(123, 20));
frame.setLayout(new FlowLayout());
frame.add(small);
frame.add(big);
frame.setVisible(true);
}
代码示例来源:origin: fr.ifremer/isis-fish
protected void createServerPrivateKeyFile() {
$objectMap.put("serverPrivateKeyFile", serverPrivateKeyFile = new JTextField());
serverPrivateKeyFile.setName("serverPrivateKeyFile");
serverPrivateKeyFile.setColumns(15);
serverPrivateKeyFile.setColumns(28);
if (serverPrivateKeyFile.getFont() != null) {
serverPrivateKeyFile.setFont(serverPrivateKeyFile.getFont().deriveFont((float) 12));
}
SwingUtil.setComponentHeight(serverPrivateKeyFile,25);
serverPrivateKeyFile.addKeyListener(JAXXUtil.getEventListener(KeyListener.class, "keyReleased", this, "doKeyReleased__on__serverPrivateKeyFile"));
}
代码示例来源:origin: mucommander/mucommander
/**
* Sets row height based on current cell's font and border, revalidates and repaints this JTable.
*/
private void setRowHeight() {
// JTable.setRowHeight() revalidates and repaints the JTable.
// Note that it's important here to use the cell editor's font rather than the cell renderer's: if this method is called
// as a result to a font changed event, we do not know which class' fontChanged event will be called first.
setRowHeight(2*CellLabel.CELL_BORDER_HEIGHT + Math.max(getFontMetrics(filenameEditor.filenameField.getFont()).getHeight(), (int)FileIcons.getIconDimension().getHeight()));
// Filename editor's row resize disabled because of Java bug #4398268 which prevents new rows from being visible after setRowHeight(row, height) has been called :/
// setRowHeight(Math.max(getFontMetrics(cellRenderer.getCellFont()).getHeight()+cellRenderer.CELL_BORDER_HEIGHT, editorRowHeight));
}
代码示例来源:origin: kiegroup/droolsjbpm-integration
public ScrollingBanner() {
super();
ticks = new ConcurrentLinkedQueue<StockTick>();
setBackground(Color.BLACK);
setForeground(Color.GREEN);
setFont(new JTextField().getFont().deriveFont(Font.BOLD));
setPreferredSize(new Dimension(500, 20));
}
代码示例来源:origin: Var3D/var3dframe
public void setFontSize(int fontSize){
textField.setFont(new Font(null,0,fontSize));
textMessage.setFont(textField.getFont());
}
代码示例来源:origin: org.scijava/scijava-ui-swing
private void initPrompt(String text) {
prompt.setText(text);
prompt.setFont(textField.getFont().deriveFont(Font.ITALIC));
prompt.setForeground(changeAlpha(textField.getForeground(), 128));
prompt.setBorder(new EmptyBorder(textField.getInsets()));
prompt.setHorizontalAlignment(SwingConstants.LEADING);
textField.setLayout(new BorderLayout());
textField.add(prompt);
updatePromptVisibility();
}
代码示例来源:origin: net.sf.ingenias/ingeniasjgraphmod
public Font getFont() {
Font font = super.getFont();
// Prefer the parent containers font if our font is a
// FontUIResource
if (font instanceof FontUIResource) {
Container parent = getParent();
if (parent != null && parent.getFont() != null)
font = parent.getFont();
}
return font;
}
}
代码示例来源:origin: tulskiy/musique
public static Font show(Component owner, Font initialFont) {
FontChooserDialog dialog = new FontChooserDialog(owner, initialFont);
dialog.setVisible(true);
return dialog.isAccepted() ? dialog.getPreview().getFont() : null;
}
}
内容来源于网络,如有侵权,请联系作者删除!