當前位置: 首頁>>代碼示例>>Java>>正文


Java FlowLayout.setAlignment方法代碼示例

本文整理匯總了Java中java.awt.FlowLayout.setAlignment方法的典型用法代碼示例。如果您正苦於以下問題:Java FlowLayout.setAlignment方法的具體用法?Java FlowLayout.setAlignment怎麽用?Java FlowLayout.setAlignment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.FlowLayout的用法示例。


在下文中一共展示了FlowLayout.setAlignment方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addRadioButtons

import java.awt.FlowLayout; //導入方法依賴的package包/類
/** Create a bank of radio buttons.  A radio button provides a list of
 *  choices, only one of which may be chosen at a time.
 *  @param name The name used to identify the entry (when calling get).
 *  @param label The label to attach to the entry.
 *  @param values The list of possible choices.
 *  @param defaultValue Default value.
 */
public void addRadioButtons(
    String name,
    String label,
    String[] values,
    String defaultValue) {
    JLabel lbl = new JLabel(label + ": ");
    lbl.setBackground(_background);
    FlowLayout flow = new FlowLayout();
    flow.setAlignment(FlowLayout.LEFT);

    // This must be a JPanel, not a Panel, or the scroll bars won't work.
    JPanel buttonPanel = new JPanel(flow);

    ButtonGroup group = new ButtonGroup();
    QueryActionListener listener = new QueryActionListener(name);

    // Regrettably, ButtonGroup provides no method to find out
    // which button is selected, so we have to go through a
    // song and dance here...
    JRadioButton[] buttons = new JRadioButton[values.length];
    for (int i = 0; i < values.length; i++) {
        JRadioButton checkbox = new JRadioButton(values[i]);
        buttons[i] = checkbox;
        checkbox.setBackground(_background);
        // The following (essentially) undocumented method does nothing...
        // checkbox.setContentAreaFilled(true);
        checkbox.setOpaque(false);
        if (values[i].equals(defaultValue)) {
            checkbox.setSelected(true);
        }
        group.add(checkbox);
        buttonPanel.add(checkbox);
        // Add the listener last so that there is no notification
        // of the first value.
        checkbox.addActionListener(listener);
    }
    _addPair(name, lbl, buttonPanel, buttons);
}
 
開發者ID:OpenDA-Association,項目名稱:OpenDA,代碼行數:46,代碼來源:Query.java

示例2: JChoice

import java.awt.FlowLayout; //導入方法依賴的package包/類
/**
 * Creates a FastChoice with the given data model.
 */
public JChoice(ComboBoxModel<E> model) {
  layout = new FlowLayout();
  layout.setHgap(0);
  layout.setVgap(0);
  layout.setAlignment(FlowLayout.LEFT);
  setLayout(layout);
  this.model = model;
  //by default nothing is selected
  setSelectedItem(null);
  initLocalData();
  buildGui();
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:16,代碼來源:JChoice.java

示例3: ProgressDialog

import java.awt.FlowLayout; //導入方法依賴的package包/類
public ProgressDialog(JFrame parent) {
	
	// init frame
	m_frame = new JFrame(Constants.Name + " - Operation in progress");
	final Container pane = m_frame.getContentPane();
	FlowLayout layout = new FlowLayout();
	layout.setAlignment(FlowLayout.LEFT);
	pane.setLayout(layout);
	
	m_title = new JLabel();
	pane.add(m_title);
	
	// set up the progress bar
	JPanel panel = new JPanel();
	pane.add(panel);
	panel.setLayout(new BorderLayout());
	m_text = GuiTricks.unboldLabel(new JLabel());
	m_progress = new JProgressBar();
	m_text.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
	panel.add(m_text, BorderLayout.NORTH);
	panel.add(m_progress, BorderLayout.CENTER);
	panel.setPreferredSize(new Dimension(360, 50));
	
	// show the frame
	pane.doLayout();
	m_frame.setSize(400, 120);
	m_frame.setResizable(false);
	m_frame.setLocationRelativeTo(parent);
	m_frame.setVisible(true);
	m_frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
}
 
開發者ID:cccssw,項目名稱:enigma-vk,代碼行數:32,代碼來源:ProgressDialog.java

示例4: erzeugeMenuPanel

import java.awt.FlowLayout; //導入方法依賴的package包/類
/**
 * Erzeugt das Menü mit Ausleih- und Rückgabe-Button und Titel.
 */
private void erzeugeMenuPanel()
{
    _menuPanel = new JPanel();
    FlowLayout auswahlPanelLayout = new FlowLayout();
    auswahlPanelLayout.setAlignment(FlowLayout.LEFT);
    _menuPanel.setLayout(auswahlPanelLayout);
    _frame.getContentPane()
        .add(_menuPanel, BorderLayout.NORTH);
    _menuPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    erzeugeAusleiheButton();
    erzeugeRueckgabeButton();
    erzeugeVormerkAnsichtButton();
    erzeugeTitel();
}
 
開發者ID:polemonium,項目名稱:SE2Project,代碼行數:18,代碼來源:MediathekUI.java

示例5: createRelationContent

import java.awt.FlowLayout; //導入方法依賴的package包/類
@SuppressWarnings({"unchecked", "rawtypes"})
private void createRelationContent() {
  this.setTitle("Relations");
  this.relationContentPane = new JPanel();
  this.relationContentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  this.relationContentPane.setLayout(new BorderLayout(0, 0));

  this.list = new JList();
  this.list.setBorder(new LineBorder(new Color(0, 0, 0)));
  final JScrollPane scrollPane = new JScrollPane(this.list,
      JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  scrollPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  this.relationContentPane.add(scrollPane, BorderLayout.CENTER);

  final ArrayList<String> relations = Utility.getSuitableRelations(this.type);
  final DefaultListModel<String> model = new DefaultListModel<>();
  this.list.setModel(model);
  this.list.setCellRenderer(new ListCellRender());

  for (final String rel : relations) {
    model.addElement(rel);
  }

  final JPanel panel = new JPanel();
  final FlowLayout flowLayout = (FlowLayout) panel.getLayout();
  flowLayout.setAlignment(FlowLayout.RIGHT);
  this.relationContentPane.add(panel, BorderLayout.SOUTH);

  final JButton btnNewButton = new JButton("Next");
  btnNewButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(final ActionEvent e) {
      if (!MappingWizard.this.list.isSelectionEmpty()) {
        MappingWizard.this.createAtomContent();
        MappingWizard.this.setContentPane(MappingWizard.this.atomContentPane);
        MappingWizard.this.revalidate();
      }
    }
  });
  panel.add(btnNewButton);

  final JButton btnNewButton_1 = new JButton("Cancel");
  btnNewButton_1.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(final ActionEvent arg0) {
      MappingWizard.this.disposeThis();
    }
  });
  panel.add(btnNewButton_1);
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:51,代碼來源:MappingWizard.java


注:本文中的java.awt.FlowLayout.setAlignment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。