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

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

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

JLabel.setHorizontalAlignment介绍

暂无

代码示例

代码示例来源: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: gocd/gocd

private JLabel label(String content, Font font) {
  JLabel jLabel = new JLabel(content);
  jLabel.setHorizontalAlignment(JLabel.CENTER);
  if (font != null) {
    jLabel.setFont(font);
  }
  return jLabel;
}

代码示例来源: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: stackoverflow.com

window = new JFrame();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setLayout(new BorderLayout());
display = new JLabel();
display.setHorizontalAlignment(JLabel.RIGHT);
display.setText("0");
window.add(display, BorderLayout.NORTH);
JPanel digitsPanel = new JPanel();
digitsPanel.setLayout(new GridLayout(4, 3));
int[] digitOrder = new int[] { 7,8,9,4,5,6,1,2,3,0 };
  JButton button = new JButton(Integer.toString(digit));
  button.addActionListener(this);
  digitsPanel.add(button);
window.add(digitsPanel, BorderLayout.CENTER);
JPanel operatorsPanel = new JPanel();
operatorsPanel.setLayout(new GridLayout(5,1));
String[] operators = new String[] { "+","-","x","/","=" };
window.add(operatorsPanel, BorderLayout.EAST);
window.pack();
window.setVisible(true);

代码示例来源:origin: 4thline/cling

protected ShutdownWindow() {
    JLabel shutdownLabel = new JLabel("Shutting down, please wait...");
    shutdownLabel.setHorizontalAlignment(JLabel.CENTER);
    getContentPane().add(shutdownLabel);
    setPreferredSize(new Dimension(300, 30));
    pack();
    Application.center(this);
  }
}

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

public IconTextField()
  setLayout(new BorderLayout());
  iconWrapperLabel = new JLabel();
  iconWrapperLabel.setPreferredSize(new Dimension(30, 0));
  iconWrapperLabel.setVerticalAlignment(JLabel.CENTER);
  iconWrapperLabel.setHorizontalAlignment(JLabel.CENTER);

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

EventQueue.invokeLater(new Runnable(){
 public void run(){
  JLabel label = new JLabel();

  label.setHorizontalAlignment(SwingConstants.CENTER);

  try{
   // URL imageURL = new URL("http://static.ak.fbcdn.net/rsrc.php/v2/yb/r/GsNJNwuI-UM.gif");
   URL imageURL = new URL("http://i34.photobucket.com/albums/d129/nirendaran/Speed/verify_anim.gif");

   label.setIcon(new ImageIcon(imageURL));
  }
  catch (MalformedURLException ex){
   ex.printStackTrace();
  }

  JFrame frame = new JFrame();
  frame.add(label, BorderLayout.CENTER);
  frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  frame.setMinimumSize(new Dimension(160, 120));
  frame.setVisible(true);
 }
});

代码示例来源:origin: 4thline/cling

@PostConstruct
public void init() {
  addWindowListener(
      new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent windowEvent) {
          dispose();
          presenter.onViewDisposed();
        }
      }
  );
  iconLabel.setHorizontalAlignment(JLabel.CENTER);
  getContentPane().add(iconLabel);
  setStatus(false);
  setMinimumSize(new Dimension(100, 100));
  setPreferredSize(new Dimension(300, 300));
  setResizable(true);
  pack();
  setVisible(true);
}

代码示例来源:origin: palantir/Cinch

void buildGUI() {
  JFrame frame = new JFrame(OnChangeExample.class.getSimpleName());
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setSize(400, 100);
  frame.setLayout(new GridBagLayout());
  frame.add(label,getLeftGBC(0));
  frame.add(button,getRightGBC(0));
  count.setHorizontalAlignment(SwingConstants.CENTER);
  frame.add(countLabel,getLeftGBC(1));
  frame.add(count,getRightGBC(1));
  frame.setVisible(true);
}

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

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout());
setSize(100, 200);
inputDisplay = new JLabel();
inputDisplay.setHorizontalAlignment(JLabel.RIGHT);
inputDisplay.setText(Integer.toString(leftHandSide));
operatorIndicator = new JLabel();
operatorIndicator.setBorder(new EmptyBorder(0, 4, 0, 4));
final JPanel display = new JPanel();
display.setLayout(new BorderLayout());
display.add(inputDisplay, BorderLayout.CENTER);
display.add(operatorIndicator, BorderLayout.WEST);
digitPanel.add(new JPanel()); // Blank spacer panel
digitPanel.add(new JButton(new DigitButtonAction(0)));
add(display, BorderLayout.NORTH);
pack();
  @Override
  public void run() {
    new CalculatorDemo().setVisible(true);

代码示例来源: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: opentripplanner/OpenTripPlanner

protected JComponent makeTextPanel(String text) {
  JPanel panel = new JPanel(false);
  JLabel filler = new JLabel(text);
  filler.setHorizontalAlignment(JLabel.CENTER);
  panel.setLayout(new GridLayout(1, 1));
  panel.add(filler);
  return panel;
}

代码示例来源:origin: secdec/attack-surface-detector-burp

private JLabel addPanelDescriptionToGridBagLayout(String descriptionText, Container gridBagContainer, int yPosition) {
  final JLabel panelDescription = new JLabel(descriptionText);
  panelDescription.setHorizontalAlignment(SwingConstants.LEFT);
  callbacks.customizeUiComponent(panelDescription);
  GridBagConstraints gridBagConstraints = new GridBagConstraints();
  gridBagConstraints.gridwidth = 3;
  gridBagConstraints.gridx = 1;
  gridBagConstraints.gridy = yPosition;
  gridBagConstraints.ipadx = 5;
  gridBagConstraints.ipady = 5;
  gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
  gridBagConstraints.anchor = GridBagConstraints.WEST;
  gridBagContainer.add(panelDescription, gridBagConstraints);
  return panelDescription;
}

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

setLayout( new BorderLayout() ):

JLabel center = new JLabel("CENTER");
center.setHorizontalAlignment(JLabel.CENTER); // maybe you are missing this
add(center, BorderLayout.CENTER);

JLabel right = new JLabel("RIGHT");
add(right, BorderLayout.LINE_END);

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

JLabel lblProtocolo = new JLabel("Protocolo:");
JLabel lblDataEntrada = new JLabel("Data Entrada:");
JTextField tfProtocolo = new JTextField(10);
JTextField tfDataEntrada = new JTextField(10);
JTextField soteste = new JTextField(10);
JFrame f = new JFrame();
c.gridwidth = 2;
c.weightx = 1;
lblDataEntrada.setHorizontalAlignment(JLabel.RIGHT);
f.getContentPane().add(lblDataEntrada,c);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);

代码示例来源:origin: skylot/jadx

public void addRow(String label, String tooltip, JComponent comp) {
  c.gridy = row++;
  JLabel jLabel = new JLabel(label);
  jLabel.setLabelFor(comp);
  jLabel.setHorizontalAlignment(SwingConstants.LEFT);
  c.gridx = 0;
  c.gridwidth = 1;
  c.anchor = GridBagConstraints.LINE_START;
  c.weightx = 0.8;
  c.fill = GridBagConstraints.NONE;
  add(jLabel, c);
  c.gridx = 1;
  c.gridwidth = GridBagConstraints.REMAINDER;
  c.anchor = GridBagConstraints.CENTER;
  c.weightx = 0.2;
  c.fill = GridBagConstraints.HORIZONTAL;
  if (tooltip != null) {
    jLabel.setToolTipText(tooltip);
    comp.setToolTipText(tooltip);
  }
  add(comp, c);
  comp.addPropertyChangeListener("enabled", evt -> jLabel.setEnabled((boolean) evt.getNewValue()));
}

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

table.setDefaultRenderer(Double.class, new CurrencyRenderer(nf));
table.setDefaultEditor(Double.class, new CurrencyEditor(nf));
this.add(new JScrollPane(table));
  this.setHorizontalAlignment(JLabel.RIGHT);
JFrame f = new JFrame("RenderEditNumber");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(this);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);

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

private LaunchProgress() {
    super(new BorderLayout());
    progressBar = new JProgressBar();
    progressBar.setIndeterminate(false);
    progressBar.setStringPainted(true);
    JPanel panel = new JPanel();
    label = new JLabel("Starting up");
    label.setHorizontalAlignment(JLabel.CENTER);
    panel.add(label);
    panel.add(progressBar);
    add(panel, BorderLayout.PAGE_START);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
  }
}

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

private void uiLayout () {
  topPanel = new JPanel(new GridBagLayout());
  topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  warningNotice = new JLabel("List of third party extensions for LibGDX");
  warningNotice2 = new JLabel("These are not maintained by the LibGDX team, please see the support links for info and help");
  warningNotice.setHorizontalAlignment(JLabel.CENTER);
  warningNotice2.setHorizontalAlignment(JLabel.CENTER);
  bottomPanel = new JPanel(new GridBagLayout());
  buttonPanel = new JPanel(new GridBagLayout());
  buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  buttonOK = new SetupButton("Save");

代码示例来源:origin: secdec/attack-surface-detector-burp

private JLabel addErrorMessageToGridBagLayout(Container gridBagContainer, int yPosition) {
  final JLabel errorMessage = new JLabel("");
  errorMessage.setForeground(new Color(255, 0, 0));
  errorMessage.setHorizontalAlignment(SwingConstants.LEFT);
  callbacks.customizeUiComponent(errorMessage);
  GridBagConstraints gridBagConstraints = new GridBagConstraints();
  gridBagConstraints.gridwidth = 3;
  gridBagConstraints.gridx = 1;
  gridBagConstraints.gridy = yPosition;
  gridBagConstraints.ipadx = 5;
  gridBagConstraints.ipady = 10;
  gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
  gridBagConstraints.anchor = GridBagConstraints.WEST;
  gridBagContainer.add(errorMessage, gridBagConstraints);
  return errorMessage;
}

相关文章

JLabel类方法