本文整理了Java中java.awt.Label.setFont()
方法的一些代码示例,展示了Label.setFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Label.setFont()
方法的具体详情如下:
包路径:java.awt.Label
类名称:Label
方法名:setFont
暂无
代码示例来源:origin: log4j/log4j
protected void wrapStringOnPanel(String message,
Container container) {
GridBagConstraints c = getDefaultConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
// Insets() args are top, left, bottom, right
c.insets = new Insets(0, 0, 0, 0);
GridBagLayout gbLayout = (GridBagLayout) container.getLayout();
while (message.length() > 0) {
int newLineIndex = message.indexOf('\n');
String line;
if (newLineIndex >= 0) {
line = message.substring(0, newLineIndex);
message = message.substring(newLineIndex + 1);
} else {
line = message;
message = "";
}
Label label = new Label(line);
label.setFont(DISPLAY_FONT);
gbLayout.setConstraints(label, c);
container.add(label);
}
}
代码示例来源:origin: wildfly/wildfly
listbox.setBounds(210, 30, 150, 160);
err_msg.setBounds(new Rectangle(10, 200, 350, 30));
err_msg.setFont(new Font("Helvetica", Font.ITALIC, 12));
err_msg.setForeground(Color.red);
err_msg.setVisible(false);
代码示例来源:origin: com.h2database/h2
label.setFont(font);
mainPanel.add(label, constraintsLabel);
代码示例来源:origin: wildfly/wildfly
leave_button.addActionListener(this);
mbr_label=new Label("0 mbr(s)");
mbr_label.setFont(default_font);
sub_panel.add("South", clear_button);
sub_panel.add("South", leave_button);
代码示例来源:origin: wildfly/wildfly
leave_button.addActionListener(this);
mbr_label = new Label("1 mbr(s)");
mbr_label.setFont(default_font);
p.add("South", leave_button);
p.add("South", mbr_label);
代码示例来源:origin: wildfly/wildfly
public UserInfoDialog(Frame parent) {
super(parent, "Input", true);
setLayout(null);
l.setFont(default_font);
l.setSize(50, 30);
l.setLocation(30, 50);
name.setFont(default_font);
name.setSize(150, 30);
name.setLocation(90, 50);
//name.selectAll();
ok.setFont(default_font);
ok.setSize(50, 30);
ok.setLocation(30, 90);
add(l); add(name); add(ok);
ok.addActionListener(this);
setSize(300, 150);
Point my_loc=parent.getLocation();
my_loc.x+=50;
my_loc.y+=150;
setLocation(my_loc);
show();
}
代码示例来源:origin: stackoverflow.com
@FXML
private Label myLabel;
@Override
public void initialize(URL arg0, ResourceBundle arg1){
Font myFont = null;
try {
myFont = Font.loadFont(new FileInputStream(new File("patch_to_font.ttf")), 10);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
myLabel.setFont(myFont);
}
代码示例来源:origin: sc.fiji/VIB-lib
private Label addLabel(String txt) {
constr.insets = new Insets(10, 5, 0, 5);
Label label = new Label(txt);
label.setFont(font);
add(label, constr);
constr.insets = new Insets(0, 5, 0, 5);
return label;
}
代码示例来源:origin: sc.fiji/3D_Viewer
/**
* Helper method to add the header of the PointList as a Label to the panel.
*/
private void addHeader() {
final Label l = new Label(header);
l.setFont(new Font("Verdana", Font.BOLD, 12));
c.gridy = 0;
c.gridwidth = 2;
c.gridx = 0;
add(l, c);
c.gridwidth = 1;
}
代码示例来源:origin: stackoverflow.com
{
Label label = new Label(IRAPfx.getData().getOptionString("Localised text 6"));
label.setFont(Font.font("Arial",FontPosture.ITALIC,FONT_SIZE_INSTRUCTIONS));
label.setWrapText(true);
label.setTextFill(Color.WHITE);
vBox.getChildren().add(label);
}
代码示例来源:origin: stackoverflow.com
{
Label label = new Label(IRAPfx.getData().getOptionString("Localised text 6"));
label.setFont(Font.font("Arial",FontPosture.ITALIC,FONT
label.setTextOverrun(OverrunStyle.CLIP);
label.setTextFill(Color.WHITE);
vBox.getChildren().add(label);
}
代码示例来源:origin: sc.fiji/VIB-lib
private Label addLabel(String s, GridBagConstraints c) {
Label label = new Label(s);
label.setFont(font);
this.add(label, c);
return label;
}
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
@Override
public void itemStateChanged( final ItemEvent arg0 )
{
if ( arg0.getStateChange() == ItemEvent.DESELECTED )
{
sigmaText2.setFont( sigmaText2.getFont().deriveFont( Font.PLAIN ) );
sigma2.setBackground( inactiveColor );
enableSigma2 = false;
}
else if ( arg0.getStateChange() == ItemEvent.SELECTED )
{
sigmaText2.setFont( sigmaText2.getFont().deriveFont( Font.BOLD ) );
sigma2.setBackground( originalColor );
enableSigma2 = true;
}
}
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
@Override
public void itemStateChanged( final ItemEvent arg0 )
{
if ( arg0.getStateChange() == ItemEvent.DESELECTED )
{
radiusText2.setFont( radiusText2.getFont().deriveFont( Font.PLAIN ) );
radius2.setBackground( inactiveColor );
enableRadius2 = false;
}
else if ( arg0.getStateChange() == ItemEvent.SELECTED )
{
radiusText2.setFont( radiusText2.getFont().deriveFont( Font.BOLD ) );
radius2.setBackground( originalColor );
enableRadius2 = true;
}
}
}
代码示例来源:origin: sc.fiji/MTrackJ_
private Label makeLabel(String label) {
if (IJ.isMacintosh()) label += " ";
final Label lab = new Label(" "+label);
lab.setFont(font);
return lab;
}
代码示例来源:origin: sc.fiji/VIB-lib
private void addHints() {
// larger font to distinguish keys more easily
Font keyFont = new Font("Monospaced", Font.PLAIN, 12);
addLabel("Hints:");
Label label = new Label("Jump to prev/next selection:");
label.setFont(font);
add(label, constr);
label = new Label("\",\"\t/\t\".\"");
label.setFont(keyFont);
add(label, constr);
}
代码示例来源:origin: net.imagej/ij
void addLabel(String text, Label label2) {
if (label2==null&&IJ.isMacOSX()) text += " ";
panel = new Panel();
c.gridy = y++;
int bottomInset = IJ.isMacOSX()?4:0;
c.insets = new Insets(0, 10, bottomInset, 0);
gridbag.setConstraints(panel, c);
panel.setLayout(new FlowLayout(label2==null?FlowLayout.CENTER:FlowLayout.LEFT, 0, 0));
Label label= new TrimmedLabel(text);
label.setFont(sanFont);
panel.add(label);
if (label2!=null) {
label2.setFont(monoFont);
label2.setAlignment(Label.LEFT);
panel.add(label2);
}
add(panel);
}
代码示例来源:origin: sc.fiji/MTrackJ_
public void addMessage(final String text) {
final Label label = new Label(" "+text);
label.setFont(font);
Panel panel = new Panel();
panel.setLayout(new FlowLayout(FlowLayout.CENTER,10,10));
panel.add(label);
add("North",panel);
}
代码示例来源:origin: imagej/ImageJA
void addLabel(String text, Label label2) {
if (label2==null&&IJ.isMacOSX()) text += " ";
panel = new Panel();
c.gridy = y++;
int bottomInset = IJ.isMacOSX()?4:0;
c.insets = new Insets(0, 10, bottomInset, 0);
gridbag.setConstraints(panel, c);
panel.setLayout(new FlowLayout(label2==null?FlowLayout.CENTER:FlowLayout.LEFT, 0, 0));
Label label= new TrimmedLabel(text);
label.setFont(sanFont);
panel.add(label);
if (label2!=null) {
label2.setFont(monoFont);
label2.setAlignment(Label.LEFT);
panel.add(label2);
}
add(panel);
}
代码示例来源:origin: stackoverflow.com
public void start(Stage stage) {
VBox root = new VBox(10);
Scene scene = new Scene(root, 300, 250);
// font.css: .labelStyleClass { -fx-font-size: 20 }
scene.getStylesheets().add(getClass().getResource("font.css").toExternalForm());
root.getChildren().add(LabelBuilder.create().text("default").build());
root.getChildren().add(LabelBuilder.create().text("font-css").styleClass("labelStyleClass").build());
Label lblApi = LabelBuilder.create().text("font-css-api (doesn't work)").styleClass("labelStyleClass").build();
lblApi.setFont(Font.font(lblApi.getFont().getFamily(), 40));
root.getChildren().add(lblApi);
Label lblStyle = LabelBuilder.create().text("font-css-setstyle (work)").styleClass("labelStyleClass").build();
lblStyle.setStyle("-fx-font-size:40;");
root.getChildren().add(lblStyle);
stage.setTitle("Hello World!");
stage.setScene(scene);
stage.show();
}
内容来源于网络,如有侵权,请联系作者删除!