下面列出了java.awt.FlowLayout#setVgap ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Creates the ui.
*/
private void createUI()
{
dataSourceFieldPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) dataSourceFieldPanel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
JButton btnNewData = new JButton(Localisation.getString(DataSourceConnectorRasterFile.class, "DataSourceConnectorRasterFile.data"));
dataSourceFieldPanel.add(btnNewData);
dataSourceTextField = new JTextField();
dataSourceFieldPanel.add(dataSourceTextField);
dataSourceTextField.setColumns(50);
btnNewData.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
chooseDataSourceToOpen();
}
});
}
/**
* Creates the ui.
*/
private void createUI()
{
dataSourceFieldPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) dataSourceFieldPanel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
JButton btnNewData = new JButton(Localisation.getString(DataSourceConnectorShapeFile.class, "DataSourceConnectorShapeFile.data"));
dataSourceFieldPanel.add(btnNewData);
dataSourceTextField = new JTextField();
dataSourceFieldPanel.add(dataSourceTextField);
dataSourceTextField.setColumns(50);
btnNewData.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
});
}
/** Creates the ui. */
private void createUI() {
groupPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) groupPanel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
TitledBorder titledBorder =
BorderFactory.createTitledBorder(
Localisation.getString(MapBoxTool.class, "MapBoxTool.groupTitle"));
groupPanel.setBorder(titledBorder);
// Export to SLD
exportToSLDButton =
new ToolButton(
Localisation.getString(MapBoxTool.class, "MapBoxTool.exportToSLD"),
"tool/exporttosld.png");
exportToSLDButton.setEnabled(false);
exportToSLDButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
exportToSLD();
}
});
groupPanel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
groupPanel.add(exportToSLDButton);
}
/**
* Constructor.
*
* @param label fixed label text
*/
public JLabelledValue(String label)
{
FlowLayout flowLayout = (FlowLayout) getLayout();
flowLayout.setAlignment(FlowLayout.LEFT);
flowLayout.setVgap(0);
flowLayout.setHgap(0);
JLabel textLabel = new JLabel(label);
textLabel.setFont(new Font("Tahoma", Font.BOLD, 11));
textLabel.setPreferredSize(new Dimension(70, 14));
add(textLabel);
m_valueLabel = new JLabel("");
m_valueLabel.setPreferredSize(new Dimension(80, 14));
add(m_valueLabel);
}
private static RowHeaderTable createRowHeaderTable(final Composite composite, final int width, final int height, final int rowHeaderWidth, final int rowHeight, final boolean iconEnable, final boolean editable) {
final Frame frame = SWT_AWT.new_Frame(composite);
final FlowLayout frameLayout = new FlowLayout();
frameLayout.setVgap(0);
frame.setLayout(frameLayout);
final Panel panel = new Panel();
final FlowLayout panelLayout = new FlowLayout();
panelLayout.setVgap(0);
panel.setLayout(panelLayout);
frame.add(panel);
final RowHeaderTable table = new RowHeaderTable(width, height, rowHeaderWidth, rowHeight, iconEnable, editable);
panel.add(table);
return table;
}
public TurnsPanel() {
FlowLayout flowLayout = (FlowLayout) getLayout();
flowLayout.setVgap(1);
flowLayout.setHgap(1);
flowLayout.setAlignment(FlowLayout.LEFT);
lblTurnNumber = new JLabel("Turn " + GameManager.getInstance().getTurns().size());
add(lblTurnNumber);
add(new JButton(new UntapPhase()));
add(new JButton(new UpkeepPhase()));
add(new JButton(new DrawPhase()));
add(new JButton(new MainPhase(1)));
add(new JButton(new CombatPhase()));
add(new JButton(new AttackPhase()));
add(new JButton(new BlockPhase()));
add(new JButton(new DamagePhase()));
add(new JButton(new EndCombatPhase()));
add(new JButton(new MainPhase(2)));
add(new JButton(new EndPhase()));
add(new JButton(new CleanUpPhase()));
add(new JButton(new EndTurnPhase()));
}
public static JPanel createPanel(String title, int width, int height, int vGap, int hGap, int alignment, int type) {
FlowLayout flowLayout1 = new FlowLayout();
JPanel controlPanel = new JPanel();
controlPanel.setLayout(flowLayout1);
flowLayout1.setAlignment(alignment);
controlPanel.setPreferredSize(new java.awt.Dimension(width, height));
controlPanel.setBackground(JPlagCreator.SYSTEMCOLOR);
if (type == WITH_LINEBORDER)
controlPanel.setBorder(JPlagCreator.LINE);
if (type == WITH_TITLEBORDER)
controlPanel.setBorder(JPlagCreator.titleBorder(title, Color.BLACK, Color.BLACK));
flowLayout1.setVgap(vGap);
flowLayout1.setHgap(hGap);
return controlPanel;
}
/**
* If width or height is not greater than 0, preferred size will not be set
*/
public static JPanel createPanel(int width, int height, int vGap, int hGap, int alignment) {
FlowLayout flowLayout1 = new FlowLayout();
JPanel controlPanel = new JPanel();
controlPanel.setLayout(flowLayout1);
flowLayout1.setAlignment(alignment);
if (width > 0 && height > 0)
controlPanel.setPreferredSize(new java.awt.Dimension(width, height));
controlPanel.setBackground(JPlagCreator.SYSTEMCOLOR);
controlPanel.setBorder(JPlagCreator.LINE);
flowLayout1.setVgap(vGap);
flowLayout1.setHgap(hGap);
return controlPanel;
}
public BtnPane()
{
FlowLayout btnPaneLayout = new FlowLayout(FlowLayout.CENTER);
btnPaneLayout.setHgap(0);
btnPaneLayout.setVgap(0);
this.setLayout(btnPaneLayout);
this.setPreferredSize(new Dimension(129,25));
}
public StatusLineComponent() {
handleComponentMap = new HashMap<InternalHandle, ListComponent>();
FlowLayout flay = new FlowLayout();
flay.setVgap(1);
flay.setHgap(5);
setLayout(flay);
mouseListener = new MListener();
addMouseListener(mouseListener);
hideListener = new HideAWTListener();
createLabel();
createBar();
// tricks to figure out correct height.
bar.setStringPainted(true);
bar.setString("@@@"); // NOI18N
label.setText("@@@"); // NOI18N
preferredHeight = Math.max(label.getPreferredSize().height, bar.getPreferredSize().height) + 3;
setOpaque(false);
discardLabel();
discardBar();
pane = new PopupPane();
pane.getActionMap().put("HidePopup", new AbstractAction() {
public @Override void actionPerformed(ActionEvent actionEvent) {
// System.out.println("escape pressed - hiding");
hidePopup();
}
});
pane.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "HidePopup");
pane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "HidePopup");
}
/**
* 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();
}
/** Creates the ui. */
private void createUI() {
panel = new JPanel();
FlowLayout flowLayout = (FlowLayout) panel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
panel.setBorder(
BorderFactory.createTitledBorder(
Localisation.getString(
BatchUpdateFontTool.class, "BatchUpdateFontTool.title")));
toolButton =
new ToolButton(
Localisation.getString(
BatchUpdateFontTool.class, "BatchUpdateFontTool.title"),
"tool/batchupdatefont.png");
panel.add(toolButton);
toolButton.setEnabled(false);
toolButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
BatchUpdateFontPanel scalePanel = new BatchUpdateFontPanel(application);
scalePanel.populate(sldDataList);
scalePanel.setVisible(true);
}
});
panel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
/**
* Instantiates a new tool panel.
*
* @param parentObj the parent obj
* @param toolMap the tool map
*/
public ToolPanel(ToolSelectionInterface parentObj, Map<Class<?>, List<ToolInterface>> toolMap) {
this.toolSelection = parentObj;
theToolPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) theToolPanel.getLayout();
flowLayout.setAlignOnBaseline(true);
flowLayout.setVgap(1);
flowLayout.setHgap(1);
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.add(theToolPanel);
this.toolMap = toolMap;
JPanel optionsPanel = new JPanel();
add(optionsPanel);
JCheckBox chckbxRecursive =
new JCheckBox(Localisation.getString(ToolPanel.class, "ToolPanel.recursive"));
chckbxRecursive.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
toolSelection.setRecursiveFlag(chckbxRecursive.isSelected());
}
});
optionsPanel.add(chckbxRecursive);
this.setPreferredSize(new Dimension(50, EMPTY_TOOL_PANEL_HEIGHT));
}
/**
* 核心GUI初始化方法.
*
* @param cards
*/
protected void initGUI(Object[][] cards)
{
// 实例化子各主要面板
mainPane = new JPanel(new BorderLayout());
cardPane = new JPanel(new CardLayout());
FlowLayout btnPaneLayout = new FlowLayout(FlowLayout.CENTER);
btnPaneLayout.setVgap(0);
btnPane = new JPanel(btnPaneLayout);
// 加入向前按钮
addToBtnPane(initPreviousButton());
// 加入页号按钮
for(int i=0;i<cards.length;i++ )
{
Object[] cardInfo = cards[i];
// String num = (String)cardInfo[0];
JComponent c = (JComponent)cardInfo[0];
String toolTipText = (String)cardInfo[1];
// 此key即进分页组件的顺序号(从1开始),又将做为它
// 位于CardLayout中的name(constraints),一举多得
final String key = (i+1)+"";
// 先在把要显示的内容组件加入到内容子面板中
this.addCard(key, c, toolTipText);
// 再把该分页内容组件对应的页号按钮加入到按钮面板中
addToBtnPane(createPageButton(key, toolTipText));
}
// 加入向后按钮
addToBtnPane(initNextButton());
// 总体布局
mainPane.add(cardPane, BorderLayout.CENTER);
mainPane.add(btnPane, BorderLayout.SOUTH);
}
/** Creates the UI. */
private void createUI() {
groupPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) groupPanel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
groupPanel.setBorder(
BorderFactory.createTitledBorder(
Localisation.getString(
StickyDataSourceTool.class, "StickyDataSourceTool.groupTitle")));
// Export to YSLD
stickyButton =
new ToggleToolButton(
Localisation.getString(
StickyDataSourceTool.class, "StickyDataSourceTool.dataSource"),
"tool/stickydatasource.png");
stickyButton.setEnabled(true);
final StickyDataSourceTool callingObj = this;
stickyButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
SLDEditorFile.getInstance()
.setStickyDataSource(callingObj, stickyButton.isSelected());
}
});
groupPanel.add(stickyButton);
groupPanel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
private void initGUI()
{
// 实例化按钮
ButtonGroup bg = new ButtonGroup();
btnLeft = new JToggleButton("");
btnRight = new JToggleButton("");
btnLeft.setContentAreaFilled(false);
btnLeft.setFocusable(false);
btnLeft.setBorder(null);
btnLeft.setPreferredSize(new Dimension(64,25));
btnRight.setContentAreaFilled(false);
btnRight.setFocusable(false);
btnRight.setBorder(null);
btnRight.setPreferredSize(new Dimension(64,25));
// 加入到ButtonGroup(实现RadioButton的形为)
bg.add(btnLeft);
bg.add(btnRight);
// 主面板布局
FlowLayout mainLayout = new FlowLayout(FlowLayout.CENTER);
mainLayout.setHgap(0);
mainLayout.setVgap(2);
this.setLayout(mainLayout);
// 此处的border的设置是为了背景上部的装饰而做哦
this.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
// 实例化按钮面板
btnPane = new BtnPane();
btnPane.add(btnLeft);
btnPane.add(btnRight);
// 添加到总体布局中
this.add(btnPane);
}
/**
* Creates a new label/component pair. If given multiple compnents, will add
* them to a JPanel and then set that as the component. Note that this is better
* than putting them into a JPanel yourself: the label will be centered on the
* first component passed-in.
*
* @param label the JLabel of the option
* @param components
*/
public Option(JLabel label, JComponent... components) {
setLabel(label);
if (components.length > 1) {
JPanel panel = new JPanel();
FlowLayout flow = (FlowLayout) panel.getLayout();
flow.setAlignment(FlowLayout.LEFT);
flow.setVgap(0);
flow.setHgap(0);
for (JComponent jc : components) {
panel.add(jc);
}
JUtils.fixHeight(panel);
setComponent(panel);
} else {
setComponent((components.length > 0) ? components[0] : null);
}
// We try to align the label with the first component (descending into
// JPanels), by creating a border that aligns the middle of the border
// with the middle of the first component.
if (components.length > 0) {
int labelOffset = -label.getPreferredSize().height;
Component comp = components[0];
while (comp instanceof JPanel) {
labelOffset += 2 * (((JPanel) comp).getInsets().top);
comp = ((JPanel) comp).getComponent(0);
}
if (comp != null) {
labelOffset += comp.getPreferredSize().height;
if (labelOffset > 0) { // Only do it if the first non-JPanel
// component is bigger
label.setBorder(new EmptyBorder(labelOffset / 2, 0, 0, 0));
}
}
}
}
/** Creates the ui. */
private void createUI() {
groupPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) groupPanel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
groupPanel.setBorder(
BorderFactory.createTitledBorder(
Localisation.getString(SaveSLDTool.class, "SaveSLDTool.save")));
saveAllSLD =
new ToolButton(
Localisation.getString(SaveSLDTool.class, "SaveSLDTool.sld"),
"tool/savesld.png");
saveAllSLD.setEnabled(false);
saveAllSLD.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("."));
chooser.setDialogTitle(
Localisation.getString(
SaveSLDTool.class, "SaveSLDTool.destinationFolder"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
//
// Disable the "All files" option.
//
chooser.setAcceptAllFileFilterUsed(false);
// Save external images option
JPanel accessory = new JPanel();
JCheckBox isOpenBox =
new JCheckBox(
Localisation.getString(
SaveSLDTool.class,
"SaveSLDTool.saveExternalImages"));
accessory.setLayout(new BorderLayout());
accessory.add(isOpenBox, BorderLayout.CENTER);
chooser.setAccessory(accessory);
if (chooser.showSaveDialog(saveAllSLD) == JFileChooser.APPROVE_OPTION) {
worker.saveAllSLDToFolder(
sldDataList, chooser.getSelectedFile(), isOpenBox.isSelected());
}
}
});
groupPanel.add(saveAllSLD);
saveAllSLD.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
public MagicEditionJLabelRenderer() {
FlowLayout flowLayout = new FlowLayout();
flowLayout.setVgap(0);
flowLayout.setAlignment(FlowLayout.LEFT);
pane.setLayout(flowLayout);
}
public MultiSpectraVisualizerWindow(PeakListRow row, RawDataFile raw) {
setBackground(Color.WHITE);
setExtendedState(JFrame.MAXIMIZED_BOTH);
setMinimumSize(new Dimension(800, 600));
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
getContentPane().setLayout(new BorderLayout());
pnGrid = new JPanel();
// any number of rows
pnGrid.setLayout(new GridLayout(0, 1, 0, 25));
pnGrid.setAutoscrolls(true);
JScrollPane scrollPane = new JScrollPane(pnGrid);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
getContentPane().add(scrollPane, BorderLayout.CENTER);
JPanel pnMenu = new JPanel();
FlowLayout fl_pnMenu = (FlowLayout) pnMenu.getLayout();
fl_pnMenu.setVgap(0);
fl_pnMenu.setAlignment(FlowLayout.LEFT);
getContentPane().add(pnMenu, BorderLayout.NORTH);
JButton nextRaw = new JButton("next");
nextRaw.addActionListener(e -> nextRaw());
JButton prevRaw = new JButton("prev");
prevRaw.addActionListener(e -> prevRaw());
pnMenu.add(prevRaw);
pnMenu.add(nextRaw);
lbRaw = new JLabel();
pnMenu.add(lbRaw);
JLabel lbRawTotalWithFragmentation = new JLabel();
pnMenu.add(lbRaw);
int n = 0;
for (Feature f : row.getPeaks()) {
if (f.getMostIntenseFragmentScanNumber() > 0)
n++;
}
lbRawTotalWithFragmentation.setText("(total raw:" + n + ")");
// add charts
setData(row, raw);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setVisible(true);
validate();
repaint();
pack();
}