本文整理汇总了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);
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}