Example usage for java.awt Label CENTER

List of usage examples for java.awt Label CENTER

Introduction

In this page you can find the example usage for java.awt Label CENTER.

Prototype

int CENTER

To view the source code for java.awt Label CENTER.

Click Source Link

Document

Indicates that the label should be centered.

Usage

From source file:CardFrame.java

private void setCardLayout() {
    cardPanel.setLayout(cardLayout);//from  ww  w. jav a 2 s  .co  m

    Label one = new Label("CARD 1", Label.CENTER);
    Label two = new Label("CARD 2", Label.CENTER);
    Label three = new Label("CARD 3", Label.CENTER);
    Label four = new Label("CARD 4", Label.CENTER);
    Label five = new Label("CARD 5", Label.CENTER);
    cardPanel.add(one, "one");
    cardPanel.add(two, "two");
    cardPanel.add(three, "three");
    cardPanel.add(four, "four");
    cardPanel.add(five, "five");

    cardLayout.show(cardPanel, "one");
}

From source file:ClockDemo.java

/**
 * The init method is called when the browser first starts the applet. It
 * sets up the Label component and obtains a DateFormat object
 *///from   w ww  .  j  a  v a 2 s  .  c  o m
public void init() {
    time = new Label();
    time.setFont(new Font("helvetica", Font.BOLD, 12));
    time.setAlignment(Label.CENTER);
    setLayout(new BorderLayout());
    add(time, BorderLayout.CENTER);
    timeFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM);
}

From source file:FontDemoLabel.java

public FontDemoLabel() {
    super("Font Demo - Label");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container cp = getContentPane();

    // get font name list
    fl = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();

    // IGNORE the setLayout and North/South stuff...
    // we will discuss it in a few pages!

    cp.setLayout(new BorderLayout());
    cp.add(BorderLayout.NORTH, new Label("Number of Fonts = " + fl.length, Label.CENTER));
    cp.add(BorderLayout.CENTER, p = new JPanel());
    p.setLayout(new GridLayout(5, 0, 5, 5));

    for (int i = 0; i < fl.length; i++) {
        JLabel lab;//  w w  w  . j  ava  2s  .  c  o  m

        // The crux of the matter: for each font name,
        // create a label using the name as the text,
        // AND set the font to be the named font!
        p.add(lab = new JLabel(fl[i]));
        lab.setFont(new Font(fl[i], Font.ITALIC | Font.BOLD, 14));
    }
    pack();
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.ImageUploaderThumbnailerTester_2.java

private Component createImagePanel(CropData cropData) {
    RenderedOp image = createCroppedImage(cropData);

    Set<String> blackSides = checkBlackEdges(image);
    if (!blackSides.isEmpty()) {
        log.warn("edges  at " + cropData + ", " + blackSides);
    }//from   www  . j a va 2  s.com

    String legend = "left=" + cropData.left + ", top=" + cropData.top + ", size=" + cropData.size;
    Label l = new Label();
    l.setAlignment(Label.CENTER);
    if (!blackSides.isEmpty()) {
        l.setBackground(new Color(0xFFDDDD));
        legend += " " + blackSides;
    }
    l.setText(legend);

    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add("South", l);
    p.add("Center", new ImageCanvas(image));
    p.setBackground(new Color(0xFFFFFF));
    p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    return p;
}

From source file:edu.cornell.mannlib.vitro.webapp.imageprocessor.jai.JaiImageProcessorTester2.java

private Component createImagePanel(CropData cropData) {
    RenderedOp image = createCroppedImage(cropData);

    Set<String> blackSides = checkBlackEdges(image);
    if (!blackSides.isEmpty()) {
        log.warn("edges  at " + cropData + ", " + blackSides);
    }/*from  w  w  w .  ja v a2s  .  c  o  m*/

    String legend = "left=" + cropData.left + ", top=" + cropData.top + ", size=" + cropData.size;
    Label l = new Label();
    l.setAlignment(Label.CENTER);
    if (!blackSides.isEmpty()) {
        l.setBackground(new Color(0xFFDDDD));
        legend += " " + blackSides;
    }
    l.setText(legend);

    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add("South", l);
    p.add("Center", new javax.media.jai.widget.ImageCanvas(image));
    p.setBackground(new Color(0xFFFFFF));
    p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    return p;
}

From source file:ExposedInt.java

public void init() {

    Panel buttonPanel = new PanelWithInsets(0, 0, 0, 0);
    buttonPanel.setLayout(new GridLayout(3, 2, 5, 5));
    buttonPanel.add(new GrayButton(ExposedIntStringTable.increment));
    buttonPanel.add(new GrayButton(ExposedIntStringTable.decrement));
    buttonPanel.add(minimumButton);//from   w ww.jav  a2s.co m
    buttonPanel.add(maximumButton);
    buttonPanel.add(zeroButton);
    buttonPanel.add(new GrayButton(ExposedIntStringTable.negate));
    zeroButton.disable();

    binaryField = new Label("00000000000000000000000000000000");
    hexField = new Label("00000000");
    decimalField = new Label("0");

    Font fieldFont = new Font("TimesRoman", Font.PLAIN, 12);
    binaryField.setFont(fieldFont);
    hexField.setFont(fieldFont);
    decimalField.setFont(fieldFont);

    Panel numberPanel = new Panel();
    numberPanel.setBackground(Color.white);
    numberPanel.setLayout(new GridLayout(3, 1));
    Panel binaryPanel = new Panel();
    binaryPanel.setLayout(new BorderLayout());
    binaryPanel.add("Center", binaryField);
    numberPanel.add(binaryPanel);

    Panel hexPanel = new Panel();
    hexPanel.setLayout(new BorderLayout());
    hexPanel.add("Center", hexField);
    numberPanel.add(hexPanel);
    numberPanel.add(decimalField);

    Panel labelPanel = new Panel();
    labelPanel.setBackground(Color.white);
    labelPanel.setLayout(new GridLayout(3, 1));
    Label label = new Label(ExposedIntStringTable.binary, Label.CENTER);
    Font labelFont = new Font("Helvetica", Font.ITALIC, 11);
    label.setFont(labelFont);
    labelPanel.add(label);
    label = new Label(ExposedIntStringTable.hex, Label.CENTER);
    label.setFont(labelFont);
    labelPanel.add(label);
    label = new Label(ExposedIntStringTable.decimal, Label.CENTER);
    label.setFont(labelFont);
    labelPanel.add(label);

    Panel dataPanel = new Panel();
    dataPanel.setLayout(new BorderLayout());
    dataPanel.add("West", labelPanel);
    dataPanel.add("Center", numberPanel);

    ColoredLabel title = new ColoredLabel(ExposedIntStringTable.title, Label.CENTER, Color.yellow);
    title.setFont(new Font("Helvetica", Font.BOLD, 12));

    setBackground(Color.red);
    setLayout(new BorderLayout(5, 5));
    add("North", title);
    add("West", buttonPanel);
    add("Center", dataPanel);
}

From source file:interpolation.InteractiveRegression.java

public void Card() {

    CardLayout cl = new CardLayout();

    panelCont.setLayout(cl);/*ww w.j a v a 2  s  . c  om*/

    panelCont.add(panelFirst, "1");
    panelCont.add(panelSecond, "2");

    panelFirst.setName("Regression Polynomial Fits");

    /* Instantiation */
    final GridBagLayout layout = new GridBagLayout();
    final GridBagConstraints c = new GridBagConstraints();

    final Scrollbar degreeSB = new Scrollbar(Scrollbar.HORIZONTAL, this.degreeInt, 1, MIN_SLIDER,
            MAX_SLIDER + 1);

    final Label degreeLabel = new Label("Degree of polynomial = " + this.degree, Label.CENTER);

    // Location
    panelFirst.setLayout(layout);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;

    ++c.gridy;
    c.insets = new Insets(30, 150, 0, 150);
    panelFirst.add(degreeSB, c);

    ++c.gridy;
    c.insets = new Insets(30, 150, 0, 150);
    panelFirst.add(degreeLabel, c);

    degreeSB.addAdjustmentListener(new DegreeListener(this, degreeLabel, degreeSB));

    panelFirst.setVisible(true);
    cl.show(panelCont, "1");
    Cardframe.add(panelCont, BorderLayout.CENTER);

    Cardframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Cardframe.pack();
    Cardframe.setVisible(true);
    updateRegression();
}

From source file:SocketApplet.java

/** Initialize the GUI nicely. */
public void init() {
    Label aLabel;/* w  ww .  ja  v  a2 s . c  o  m*/

    setLayout(new GridBagLayout());
    int LOGO_COL = 1;
    int LABEL_COL = 2;
    int TEXT_COL = 3;
    int BUTTON_COL = 1;
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 100.0;
    gbc.weighty = 100.0;

    gbc.gridx = LABEL_COL;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.EAST;
    add(aLabel = new Label("Name:", Label.CENTER), gbc);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.gridx = TEXT_COL;
    gbc.gridy = 0;
    add(nameTF = new TextField(10), gbc);

    gbc.gridx = LABEL_COL;
    gbc.gridy = 1;
    gbc.anchor = GridBagConstraints.EAST;
    add(aLabel = new Label("Password:", Label.CENTER), gbc);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.gridx = TEXT_COL;
    gbc.gridy = 1;
    add(passTF = new TextField(10), gbc);
    passTF.setEchoChar('*');

    gbc.gridx = LABEL_COL;
    gbc.gridy = 2;
    gbc.anchor = GridBagConstraints.EAST;
    add(aLabel = new Label("Domain:", Label.CENTER), gbc);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.gridx = TEXT_COL;
    gbc.gridy = 2;
    add(domainTF = new TextField(10), gbc);
    sendButton = new Button("Send data");
    gbc.gridx = BUTTON_COL;
    gbc.gridy = 3;
    gbc.gridwidth = 3;
    add(sendButton, gbc);

    whence = getCodeBase();

    // Now the action begins...
    sendButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String name = nameTF.getText();
            if (name.length() == 0) {
                showStatus("Name required");
                return;
            }
            String domain = domainTF.getText();
            if (domain.length() == 0) {
                showStatus("Domain required");
                return;
            }
            showStatus("Connecting to host " + whence.getHost() + " as " + nameTF.getText());

            try {
                Socket s = new Socket(getCodeBase().getHost(), 3333);
                PrintWriter pf = new PrintWriter(s.getOutputStream(), true);
                // send login name
                pf.println(nameTF.getText());
                // passwd
                pf.println(passTF.getText());
                // and domain
                pf.println(domainTF.getText());

                BufferedReader is = new BufferedReader(new InputStreamReader(s.getInputStream()));
                String response = is.readLine();
                showStatus(response);
            } catch (IOException e) {
                showStatus("ERROR: " + e.getMessage());
            }
        }
    });
}

From source file:width.java

 public void init() {
     GridBagLayout gridBag = new GridBagLayout();
     GridBagConstraints c = new GridBagConstraints();

     setLayout(gridBag);/*from   ww w  .ja v  a  2 s . c o  m*/

     Label receiverLabel = new Label("Receiver name:", 
                                     Label.RIGHT);
     gridBag.setConstraints(receiverLabel, c);
     add(receiverLabel);

     nameField = new TextField(getParameter("RECEIVERNAME"),
                                            10);
     c.fill = GridBagConstraints.HORIZONTAL;
     gridBag.setConstraints(nameField, c);
     add(nameField);
     nameField.addActionListener(this);

     Button button = new Button("Send message");
     c.gridwidth = GridBagConstraints.REMAINDER; //end row
     c.anchor = GridBagConstraints.WEST; //stick to the 
                                         //text field
     c.fill = GridBagConstraints.NONE; //keep the button 
                                       //small
     gridBag.setConstraints(button, c);
     add(button);
     button.addActionListener(this);

     status = new TextArea(5, 60);
     status.setEditable(false);
     c.anchor = GridBagConstraints.CENTER; //reset to the default
     c.fill = GridBagConstraints.BOTH; //make this big
     c.weightx = 1.0;
     c.weighty = 1.0;
     gridBag.setConstraints(status, c);
     add(status);

     myName = getParameter("NAME");
     Label senderLabel = new Label("(My name is " + myName + ".)",
                                   Label.CENTER);
     c.weightx = 0.0;
     c.weighty = 0.0;
     gridBag.setConstraints(senderLabel, c);
     add(senderLabel);

newline = System.getProperty("line.separator");
 }

From source file:CircleOfSquares.java

public void init() {

    setBackground(ColorTable.appletBackgroundColor);
    setLayout(new BorderLayout(5, 5));

    threeParts = new ThreeParts(SimData.methodAreaMemorySectionSize);
    simulationController = new ControlPanel();
    resetButton = simulationController.getResetButton();

    ColoredLabel title = new ColoredLabel(StringTable.appletTitle, Label.CENTER, ColorTable.titleColor);
    title.setFont(new Font("Helvetica", Font.BOLD, 12));
    add("North", title);
    add("South", simulationController);
    add("Center", threeParts);

    // Get a reference to the UI objects that are actually manipulated by
    // the handlers of the Step and Reset buttons. These aren't available
    // without this explicit get() because these objects are buried several
    // levels down in embedded panels.
    stackMemoryView = threeParts.getStackMemoryViewReference();
    methodAreaMemoryView = threeParts.getMethodAreaMemoryViewReference();
    registers = threeParts.getRegisterPanel();

    // Place the bytecodes into the method area
    for (int i = 0; i < SimData.methodAreaMemorySectionSize; ++i) {

        methodAreaMemorySection.setAtAddress(methodAreaBase + i, SimData.theProgram[i]);

        methodAreaMemorySection.setLogicalValueAtAddress(methodAreaBase + i, SimData.byteCodeMnemonics[i]);
    }// w w w.ja  v a2 s  . com

    ResetState();
    UpdateStateDisplay();
}