javax.swing.JLabel.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中javax.swing.JLabel.<init>()方法的一些代码示例,展示了JLabel.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.<init>()方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:<init>

JLabel.<init>介绍

暂无

代码示例

代码示例来源:origin: log4j/log4j

protected JPanel createStatusArea() {
 JPanel statusArea = new JPanel();
 JLabel status =
   new JLabel("No log records to display.");
 _statusLabel = status;
 status.setHorizontalAlignment(JLabel.LEFT);
 statusArea.setBorder(BorderFactory.createEtchedBorder());
 statusArea.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
 statusArea.add(status);
 return (statusArea);
}

代码示例来源:origin: stanfordnlp/CoreNLP

private void initAboutBox() {
 aboutBox = new JDialog(this, "About Tregex");
 aboutBox.getContentPane().setLayout(new BorderLayout());
 aboutBox.getContentPane().add(new JLabel("<html><b>Tregex and Tsurgeon</b></html>", SwingConstants.CENTER), BorderLayout.NORTH);
 aboutBox.getContentPane().add(new JLabel("<html>Tregex by Galen Andrew and Roger Levy<br>Tsurgeon by Roger Levy<br>Graphical interface by Anna Rafferty<br>Additional features and development by Chris Manning<br></html>", SwingConstants.CENTER), BorderLayout.CENTER);
 aboutBox.getContentPane().add(new JLabel("<html><font size=2>\u00A92007 The Board of Trustees of The Leland Stanford Junior University.<br>Distributed under the GNU General Public License</font></html>", SwingConstants.CENTER), BorderLayout.SOUTH);
}

代码示例来源:origin: stackoverflow.com

import javax.swing.JFrame;
import javax.swing.JLabel;

public class AnotherJFrame extends JFrame
{
  public AnotherJFrame()
  {
    super("Another GUI");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    add(new JLabel("Empty JFrame"));
    pack();
    setVisible(true);
  }
}

代码示例来源:origin: stackoverflow.com

import javax.swing.*;

public class JOptionPaneMultiInput {
  public static void main(String[] args) {
   JTextField xField = new JTextField(5);
   JTextField yField = new JTextField(5);

   JPanel myPanel = new JPanel();
   myPanel.add(new JLabel("x:"));
   myPanel.add(xField);
   myPanel.add(Box.createHorizontalStrut(15)); // a spacer
   myPanel.add(new JLabel("y:"));
   myPanel.add(yField);

   int result = JOptionPane.showConfirmDialog(null, myPanel, 
        "Please Enter X and Y Values", JOptionPane.OK_CANCEL_OPTION);
   if (result == JOptionPane.OK_OPTION) {
     System.out.println("x value: " + xField.getText());
     System.out.println("y value: " + yField.getText());
   }
  }
}

代码示例来源:origin: apache/shiro

public void afterPropertiesSet() throws Exception {
  ClassPathResource resource = new ClassPathResource("logo.png");
  ImageIcon icon = new ImageIcon(resource.getURL());
  JLabel logo = new JLabel(icon);
  refreshButton.addActionListener(this);
  JPanel valuePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
  valuePanel.add(valueField);
  valuePanel.add(saveButton);
  secureMethod3Button.addActionListener(this);
  JPanel methodPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
  methodPanel.add(secureMethod1Button);
  methodPanel.add(secureMethod2Button);
  methodPanel.add(secureMethod3Button);
  frame = new JFrame("Apache Shiro Sample Application");
  frame.setSize(500, 200);
  panel.add(logo, BorderLayout.NORTH);
  panel.add(valuePanel, BorderLayout.CENTER);
  panel.add(methodPanel, BorderLayout.SOUTH);

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) {
  JFrame frame = new JFrame();
  frame.setLayout(new GridBagLayout());
  JPanel panel = new JPanel();
  panel.add(new JLabel("This is a label"));
  panel.setBorder(new LineBorder(Color.BLACK)); // make it easy to see
  frame.add(panel, new GridBagConstraints());
  frame.setSize(400, 400);
  frame.setLocationRelativeTo(null);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setVisible(true);
}

代码示例来源:origin: stackoverflow.com

JPanel content = new JPanel();
content.setLayout(new FlowLayout());
content.add(new JLabel("Input"));
content.add(m_userInputTf);
content.add(m_multiplyBtn);
content.add(new JLabel("Total"));
content.add(m_totalTf);
content.add(m_clearBtn);
this.pack();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

代码示例来源:origin: loklak/loklak_server

/**
 * show the image as JFrame on desktop
 */
public void show() {
  JLabel label = new JLabel(new ImageIcon(this.image));
  JFrame f = new JFrame();
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.getContentPane().add(label);
  f.pack();
  f.setVisible(true);
}

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame(){{
    add( new JPanel(){{
       add( new JLabel("Hey there"){{ 
         setBackground(Color.black);
         setForeground( Color.white);
       }});
       add( new JButton("Ok"){{
         addActionListener( new ActionListener(){
           public void actionPerformed( ActionEvent ae ){
             System.out.println("Button pushed");
           }
          });
        }});
   }});
 }};

代码示例来源:origin: stackoverflow.com

append("the available space</html>");
JLabel label = new JLabel(sb.toString());
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(label);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void show(){
  frame = new JFrame("HDR View");
  label = new JLabel(new ImageIcon(image));
  frame.getContentPane().add(label);
  frame.setLayout(new FlowLayout());
  frame.pack();
  frame.setVisible(true);
}

代码示例来源:origin: stackoverflow.com

label1 = new JLabel("max 10 chars");
textfield1 = new JTextField(15);
add(label1);
add(textfield1);
textfield1.setDocument(new JTextFieldLimit(10));
setVisible(true);

代码示例来源:origin: stackoverflow.com

$cat HelloWorldSwing.java
 package start;
 import javax.swing.*;
 public class HelloWorldSwing {
   public static void main(String[] args) {
     //Create and set up the window.
     JFrame frame = new JFrame("HelloWorldSwing");
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     JLabel label = new JLabel("Hello World");
     frame.add(label);
     //Display the window.
     frame.pack();
     frame.setVisible(true);
   }
 }
 class Dummy {
   // just to have another thing to pack in the jar
 }

代码示例来源:origin: gocd/gocd

private void createView() {
  JPanel controlsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10));
  serverTextField = new JTextField("");
  serverTextField.setColumns(15);
  serverTextField.selectAll();
  JPanel textPanel = new JPanel(new GridLayout(4, 2, 0, 10));
  textPanel.add(new JLabel("Go Server Hostname or IP"));
  textPanel.add(serverTextField);
  textPanel.add(new JLabel("SSL Mode"));
  sslModeComponent = new SslModeComponent();
  textPanel.add(sslModeComponent);
  textPanel.add(new JLabel("Server root certificate"));
  fileBrowser = new FileBrowser();
  textPanel.add(fileBrowser);
  controlsPanel.add(textPanel);
  getContentPane().add(controlsPanel, BorderLayout.NORTH);
  JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10));
  okButton = new JButton("OK");
  buttonPanel.add(okButton);
  getContentPane().add(buttonPanel, BorderLayout.SOUTH);
}

代码示例来源:origin: pedrovgs/AndroidWiFiADB

private void createNoDevicesPanel() {
 panelNoDevices = new JPanel(new BorderLayout());
 JLabel labelNoDevices = new JLabel(NO_DEVICE_CONNECTED);
 labelNoDevices.setHorizontalAlignment(SwingConstants.CENTER);
 panelNoDevices.add(labelNoDevices);
}

代码示例来源:origin: kiegroup/optaplanner

return;
final JFrame exceptionFrame = new JFrame("Uncaught exception: " + e.getMessage());
Icon errorIcon = UIManager.getIcon("OptionPane.errorIcon");
BufferedImage errorImage = new BufferedImage(
errorIcon.paintIcon(null, errorImage.getGraphics(), 0, 0);
exceptionFrame.setIconImage(errorImage);
exceptionFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
JPanel contentPanel = new JPanel(new BorderLayout(5, 5));
contentPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
contentPanel.add(new JLabel("An uncaught exception has occurred: "), BorderLayout.NORTH);
JTextArea stackTraceTextArea = new JTextArea(30, 80);
stackTraceTextArea.setEditable(false);
contentPanel.add(stackTraceScrollPane, BorderLayout.CENTER);
stackTraceTextArea.setCaretPosition(0); // Scroll to top
JPanel buttonPanel = new JPanel(new GridLayout(1, 0));
JButton closeButton = new JButton(new AbstractAction("Close") {
  @Override

代码示例来源:origin: libgdx/libgdx

public Splash (Frame frame, String imageFile, int minMillis) {
  super(frame);
  this.minMillis = minMillis;
  getContentPane().add(new JLabel(new ImageIcon(Splash.class.getResource(imageFile))), BorderLayout.CENTER);
  pack();
  setLocationRelativeTo(null);
  setVisible(true);
  startTime = System.currentTimeMillis();
}

代码示例来源:origin: loklak/loklak_server

/**
   * show the images as stream of JFrame on desktop
   */
  public void show() {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
    JLabel label = null;
    while (true) {
      for (int i = 0; i < this.frames.size(); i++) {
        Frame frame = this.frames.get(i);
        if (label == null) {
          label = new JLabel(new ImageIcon(frame.image));
          f.getContentPane().add(label);
          f.pack();
        } else {
          label.getGraphics().drawImage(frame.image,0,0, label);
        }
        try {Thread.sleep(frame.delayMillis);} catch (InterruptedException e) {}
      }
    }
  }
}

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.setSize(200, 200);

// create the status bar panel and shove it down the bottom of the frame
JPanel statusPanel = new JPanel();
statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
frame.add(statusPanel, BorderLayout.SOUTH);
statusPanel.setPreferredSize(new Dimension(frame.getWidth(), 16));
statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
JLabel statusLabel = new JLabel("status");
statusLabel.setHorizontalAlignment(SwingConstants.LEFT);
statusPanel.add(statusLabel);

frame.setVisible(true);

代码示例来源:origin: kevin-wayne/algs4

private static void init() {
  if (frame != null) frame.setVisible(false);
  frame = new JFrame();
  offscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  onscreenImage  = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  JLabel draw = new JLabel(icon);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);            // closes all windows

相关文章

JLabel类方法