类java.awt.Label源码实例Demo

下面列出了怎么用java.awt.Label的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: JavaGame   文件: Block.java
/**
	 * ������
	 * 
	 * @param g
	 */
	public void drawContent(Graphics g) {
		this.value = (int) Math.pow(2, level) + "";
		g.setColor(Constant.COLOR_BLOCKS_ACTIVE[level - 1]);
		Font f = new Font("΢���ź�", Font.BOLD, 60 - 5 * value.length());
		g.setFont(f);
		FontMetrics fm = new Label().getFontMetrics(f);
		int xValueStart = x + (Constant.BLOCK_WIDTH - fm.stringWidth(value)) / 2;
		int yValueStart = y+Constant.BLOCK_HEIGHT- (Constant.BLOCK_HEIGHT - fm.getHeight()) / 2-fm.getDescent();

		// ������
		g.fillRoundRect(x, y, Constant.BLOCK_WIDTH, Constant.BLOCK_WIDTH, 10, 10);
		g.setColor(Color.BLACK);
		// ������
		g.drawString(value, xValueStart, yValueStart);

//		 //���Լ�¼
//		 f = new Font("΢���ź�", Font.BOLD, 20);
//		 g.setFont(f);
//		 String s = "(" + x + "," + y + ")" + moveCount;
//		 g.drawString(s, x, y + 20);
	}
 
源代码2 项目: openjdk-8   文件: WPrinterJob.java
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
 
源代码3 项目: TencentKona-8   文件: WPrinterJob.java
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
 
源代码4 项目: TencentKona-8   文件: MultiResolutionCursorTest.java
public void start() {
    //Get things going.  Request focus, set size, et cetera
    setSize(200, 200);
    setVisible(true);
    validate();

    final Image image = new MultiResolutionCursor();

    int center = sizes[0] / 2;
    Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
            image, new Point(center, center), "multi-resolution cursor");

    Frame frame = new Frame("Test Frame");
    frame.setSize(300, 300);
    frame.setLocation(300, 50);
    frame.add(new Label("Move cursor here"));
    frame.setCursor(cursor);
    frame.setVisible(true);
}
 
源代码5 项目: jdk8u60   文件: WPrinterJob.java
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
 
源代码6 项目: openjdk-jdk8u   文件: WPrinterJob.java
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
 
源代码7 项目: jdk8u_jdk   文件: MultiResolutionCursorTest.java
public void start() {
    //Get things going.  Request focus, set size, et cetera
    setSize(200, 200);
    setVisible(true);
    validate();

    final Image image = new MultiResolutionCursor();

    int center = sizes[0] / 2;
    Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
            image, new Point(center, center), "multi-resolution cursor");

    Frame frame = new Frame("Test Frame");
    frame.setSize(300, 300);
    frame.setLocation(300, 50);
    frame.add(new Label("Move cursor here"));
    frame.setCursor(cursor);
    frame.setVisible(true);
}
 
源代码8 项目: openjdk-jdk8u   文件: MultiResolutionCursorTest.java
public void start() {
    //Get things going.  Request focus, set size, et cetera
    setSize(200, 200);
    setVisible(true);
    validate();

    final Image image = new MultiResolutionCursor();

    int center = sizes[0] / 2;
    Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
            image, new Point(center, center), "multi-resolution cursor");

    Frame frame = new Frame("Test Frame");
    frame.setSize(300, 300);
    frame.setLocation(300, 50);
    frame.add(new Label("Move cursor here"));
    frame.setCursor(cursor);
    frame.setVisible(true);
}
 
源代码9 项目: TrakEM2   文件: DBLoader.java
private void makeWindow() {
	dialog = new java.awt.Dialog(IJ.getInstance(), "Loading...", false);
	dialog.setUndecorated(true);
	bytes = new Label("Loaded: 0 bytes                ");
	speed = new Label("Speed: 0 bytes/s               ");
	time = new Label ("Elapsed time: 0 s              ");
	dialog.setLayout(new GridLayout(3,1));
	dialog.addWindowListener(new java.awt.event.WindowAdapter() {
		public void windowDeactivated(java.awt.event.WindowEvent we) {
			dialog.toFront();
		}
	});
	dialog.add(time);
	dialog.add(bytes);
	dialog.add(speed);
	java.awt.Dimension screen = dialog.getToolkit().getScreenSize();
	dialog.pack();
	dialog.setLocation(screen.width/2 - dialog.getWidth()/2, screen.height/2 - dialog.getHeight()/2);
	//dialog.setVisible(true);
}
 
public void start() {
    //Get things going.  Request focus, set size, et cetera
    setSize(200, 200);
    setVisible(true);
    validate();

    final Image image = new MultiResolutionCursor();

    int center = sizes[0] / 2;
    Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
            image, new Point(center, center), "multi-resolution cursor");

    Frame frame = new Frame("Test Frame");
    frame.setSize(300, 300);
    frame.setLocation(300, 50);
    frame.add(new Label("Move cursor here"));
    frame.setCursor(cursor);
    frame.setVisible(true);
}
 
源代码11 项目: jdk8u-dev-jdk   文件: WPrinterJob.java
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
 
源代码12 项目: mzmine2   文件: FeatureOverviewWindow.java
private JPanel addFeatureDataSummary(PeakListRow row) {
  JPanel featureDataSummary = new JPanel(new GridLayout(0, 1));
  featureDataSummary.setBackground(Color.WHITE);
  featureDataSummary.add(new Label("Feature: " + row.getID()));
  if (row.getPreferredPeakIdentity() != null)
    featureDataSummary.add(new Label("Identity: " + row.getPreferredPeakIdentity().getName()));
  if (row.getComment() != null)
    featureDataSummary.add(new Label("Comment: " + row.getComment()));
  featureDataSummary.add(new Label("Raw File: " + rawFiles[0].getName()));
  featureDataSummary.add(new Label("Intensity: "
      + MZmineCore.getConfiguration().getIntensityFormat().format(feature.getHeight())));
  featureDataSummary.add(new Label(
      "Area: " + MZmineCore.getConfiguration().getIntensityFormat().format(feature.getArea())));
  featureDataSummary.add(new Label("Charge: " + feature.getCharge()));
  featureDataSummary.add(
      new Label("m/z: " + MZmineCore.getConfiguration().getMZFormat().format(feature.getMZ())));
  featureDataSummary.add(new Label(
      "Retention time: " + MZmineCore.getConfiguration().getRTFormat().format(feature.getRT())));
  featureDataSummary.add(new Label("Asymmetry factor "
      + MZmineCore.getConfiguration().getRTFormat().format(feature.getAsymmetryFactor())));
  featureDataSummary.add(new Label("Tailing Factor factor "
      + MZmineCore.getConfiguration().getRTFormat().format(feature.getTailingFactor())));
  featureDataSummary.add(new Label("Status: " + feature.getFeatureStatus()));
  return featureDataSummary;
}
 
源代码13 项目: openjdk-jdk9   文件: MultiResolutionCursorTest.java
public void start() {
    //Get things going.  Request focus, set size, et cetera
    setSize(200, 200);
    setVisible(true);
    validate();

    final Image image = new BaseMultiResolutionImage(
            createResolutionVariant(0),
            createResolutionVariant(1),
            createResolutionVariant(2),
            createResolutionVariant(3)
    );

    int center = sizes[0] / 2;
    Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
            image, new Point(center, center), "multi-resolution cursor");

    Frame frame = new Frame("Test Frame");
    frame.setSize(300, 300);
    frame.setLocation(300, 50);
    frame.add(new Label("Move cursor here"));
    frame.setCursor(cursor);
    frame.setVisible(true);
}
 
源代码14 项目: jdk8u-jdk   文件: WPrinterJob.java
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
 
源代码15 项目: openjdk-8-source   文件: LWLabelPeer.java
/**
 * Converts {@code Label} alignment constant to the {@code JLabel} constant.
 * If wrong Label alignment provided returns default alignment.
 *
 * @param alignment {@code Label} constant.
 *
 * @return {@code JLabel} constant.
 */
private static int convertAlignment(final int alignment) {
    switch (alignment) {
        case Label.CENTER:
            return SwingConstants.CENTER;
        case Label.RIGHT:
            return SwingConstants.RIGHT;
        default:
            return SwingConstants.LEFT;
    }
}
 
源代码16 项目: jdk8u-jdk   文件: LWLabelPeer.java
/**
 * Converts {@code Label} alignment constant to the {@code JLabel} constant.
 * If wrong Label alignment provided returns default alignment.
 *
 * @param alignment {@code Label} constant.
 *
 * @return {@code JLabel} constant.
 */
private static int convertAlignment(final int alignment) {
    switch (alignment) {
        case Label.CENTER:
            return SwingConstants.CENTER;
        case Label.RIGHT:
            return SwingConstants.RIGHT;
        default:
            return SwingConstants.LEFT;
    }
}
 
源代码17 项目: SPIM_Registration   文件: InteractiveIntegral.java
public Radius1Listener( final Label label, final float min, final float max, final int scrollbarSize, final Scrollbar radiusScrollbar1,  final Scrollbar radiusScrollbar2, final Label radiusText2  )
{
	this.label = label;
	this.min = min;
	this.max = max;
	this.scrollbarSize = scrollbarSize;
	
	this.radiusScrollbar1 = radiusScrollbar1;
	this.radiusScrollbar2 = radiusScrollbar2;
	this.radiusText2 = radiusText2;
}
 
源代码18 项目: TencentKona-8   文件: DitherTest.java
public DitherControls(DitherTest app, int s, int e, DitherMethod type,
        boolean vertical) {
    applet = app;
    setLayout(dcLayout);
    add(new Label(vertical ? "Vertical" : "Horizontal"));
    add(choice = new Choice());
    for (DitherMethod m : DitherMethod.values()) {
        choice.addItem(m.toString().substring(0, 1)
                + m.toString().substring(1).toLowerCase());
    }
    choice.select(type.ordinal());
    add(start = new CardinalTextField(Integer.toString(s), 4));
    add(end = new CardinalTextField(Integer.toString(e), 4));
}
 
源代码19 项目: jdk8u60   文件: DitherTest.java
public DitherControls(DitherTest app, int s, int e, DitherMethod type,
        boolean vertical) {
    applet = app;
    setLayout(dcLayout);
    add(new Label(vertical ? "Vertical" : "Horizontal"));
    add(choice = new Choice());
    for (DitherMethod m : DitherMethod.values()) {
        choice.addItem(m.toString().substring(0, 1)
                + m.toString().substring(1).toLowerCase());
    }
    choice.select(type.ordinal());
    add(start = new CardinalTextField(Integer.toString(s), 4));
    add(end = new CardinalTextField(Integer.toString(e), 4));
}
 
源代码20 项目: openjdk-8   文件: LWLabelPeer.java
/**
 * Converts {@code Label} alignment constant to the {@code JLabel} constant.
 * If wrong Label alignment provided returns default alignment.
 *
 * @param alignment {@code Label} constant.
 *
 * @return {@code JLabel} constant.
 */
private static int convertAlignment(final int alignment) {
    switch (alignment) {
        case Label.CENTER:
            return SwingConstants.CENTER;
        case Label.RIGHT:
            return SwingConstants.RIGHT;
        default:
            return SwingConstants.LEFT;
    }
}
 
源代码21 项目: openjdk-jdk8u   文件: DitherTest.java
public DitherControls(DitherTest app, int s, int e, DitherMethod type,
        boolean vertical) {
    applet = app;
    setLayout(dcLayout);
    add(new Label(vertical ? "Vertical" : "Horizontal"));
    add(choice = new Choice());
    for (DitherMethod m : DitherMethod.values()) {
        choice.addItem(m.toString().substring(0, 1)
                + m.toString().substring(1).toLowerCase());
    }
    choice.select(type.ordinal());
    add(start = new CardinalTextField(Integer.toString(s), 4));
    add(end = new CardinalTextField(Integer.toString(e), 4));
}
 
源代码22 项目: openjdk-jdk8u   文件: LWLabelPeer.java
/**
 * Converts {@code Label} alignment constant to the {@code JLabel} constant.
 * If wrong Label alignment provided returns default alignment.
 *
 * @param alignment {@code Label} constant.
 *
 * @return {@code JLabel} constant.
 */
private static int convertAlignment(final int alignment) {
    switch (alignment) {
        case Label.CENTER:
            return SwingConstants.CENTER;
        case Label.RIGHT:
            return SwingConstants.RIGHT;
        default:
            return SwingConstants.LEFT;
    }
}
 
源代码23 项目: xyTalk-pc   文件: GraphicUtils.java
/**
    * Loading an image via a MediaTracker
    * 
    * @param image
    * @throws InterruptedException
    * @throws IOException
    */
   public static void load(Image image) throws InterruptedException,
    IOException {
MediaTracker tracker = new MediaTracker(new Label()); // any component
						      // will do
tracker.addImage(image, 0);
tracker.waitForID(0);
if (tracker.isErrorID(0))
    throw new IOException("error loading image");
   }
 
源代码24 项目: SPIM_Registration   文件: InteractiveDoG.java
public Sigma2Listener( final float min, final float max, final int scrollbarSize, final Scrollbar sigmaScrollbar2, final Label sigma2Label )
{
	this.min = min;
	this.max = max;
	this.scrollbarSize = scrollbarSize;
	
	this.sigmaScrollbar2 = sigmaScrollbar2;
	this.sigma2Label = sigma2Label;
}
 
源代码25 项目: sagetv   文件: Sage.java
static void setSplashText(String x)
{
  Label tempL = splashText;
  if (tempL != null)
    tempL.setText(x);
  if (Sage.DBG) System.out.println("Splash: " + x);
  SageTV.writeOutWatchdogFile();
}
 
源代码26 项目: pdfxtk   文件: LoginRequester.java
public LoginRequester(Frame parent, String title, String user_label, String password_label, 
	String posText_, String negText) {
  
  super(parent, title, true);
  setLayout(new GridBagLayout());
  posText = posText_;
  
  add(new Label(user_label), Awt.constraints(false, GridBagConstraints.HORIZONTAL));
  u_text = new TextField(30);
  try{u_text.setText(System.getProperty("user.name",""));}
  catch(Exception e) {}
  add(u_text, Awt.constraints(true, GridBagConstraints.HORIZONTAL));
  
  add(new Label(password_label), Awt.constraints(false, GridBagConstraints.HORIZONTAL));
  p_text = new TextField(30);
  p_text.setEchoChar('*');
  add(p_text, Awt.constraints(true, GridBagConstraints.HORIZONTAL));
  
  Button pos = new Button(posText);
  add(pos, Awt.constraints(false, 10, 4, GridBagConstraints.HORIZONTAL));
  pos.addActionListener(this);
  
  Button neg = new Button(negText);
  add(neg, Awt.constraints(true, 10, 4, GridBagConstraints.HORIZONTAL));
  neg.addActionListener(this);
  
  pack();
}
 
源代码27 项目: swift-k   文件: GIPApplet.java
public EmailConfirmationDialog(Frame parent, String[] messages, String textArea) {

        super(parent, true);
        setTitle("Confirmation Dialog");

        Font font = new Font("Courier", Font.PLAIN, 12);
        setFont(font);
        
        int rows = messages.length;
        Panel textPanel = new Panel();
        textPanel.setLayout(new GridLayout(rows,1));
        for(int i = 0; i < rows; i++){
            textPanel.add(new Label(messages[i]));
        }
        add("North", textPanel);

        Panel textAreaPanel = new Panel();
        TextArea ta = new TextArea(12,60);
        ta.setText(textArea);
        textAreaPanel.add(ta);
        add("Center", textAreaPanel);
        
        Panel p = new Panel();
        p.setLayout(new FlowLayout());
        Button yes = new Button("Yes");
        yes.addActionListener(this);
        p.add(yes);
        Button no = new Button("No");
        no.addActionListener(this);
        p.add(no);
        add("South", p);
        
        setLocation(100, 200);
        pack();

    }
 
源代码28 项目: Scripts   文件: InteractivePlotter.java
private void updatePromptLabel(final int index, final String newLabel, final Color color) {
	try {
		synchronized (prompt.getTreeLock()) {
			final Label label = ((Label) prompt.getComponent(index));
			label.setAlignment(Label.RIGHT);
			label.setText(newLabel);
			label.setForeground(color);
		}
	} catch (final ArrayIndexOutOfBoundsException | ClassCastException ignored) {
		// Do nothing: index is not valid
	}
}
 
源代码29 项目: swift-k   文件: UITools.java
public static void main(String args[]) {
   // Create a frame and center it relative to the 
   // screen
   Frame f = new Frame("This should be centered");
   f.add(new Label("Press Ctrl-C from command line to exit"));
   f.setSize(f.getPreferredSize());
   f.pack();
   center(null, f);
   f.show();
}
 
源代码30 项目: openjdk-jdk9   文件: DitherTest.java
public DitherControls(DitherTest app, int s, int e, DitherMethod type,
        boolean vertical) {
    applet = app;
    setLayout(dcLayout);
    add(new Label(vertical ? "Vertical" : "Horizontal"));
    add(choice = new Choice());
    for (DitherMethod m : DitherMethod.values()) {
        choice.addItem(m.toString().substring(0, 1)
                + m.toString().substring(1).toLowerCase());
    }
    choice.select(type.ordinal());
    add(start = new CardinalTextField(Integer.toString(s), 4));
    add(end = new CardinalTextField(Integer.toString(e), 4));
}
 
 类所在包
 类方法
 同包方法