下面列出了java.awt.FlowLayout#setHgap ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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);
}
/**
* 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);
}
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 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));
}
public BtnPane()
{
FlowLayout btnPaneLayout = new FlowLayout(FlowLayout.CENTER);
btnPaneLayout.setHgap(0);
btnPaneLayout.setVgap(0);
this.setLayout(btnPaneLayout);
this.setPreferredSize(new Dimension(129,25));
}
/** 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));
}
/**
* Instantiates a new transport control panel.
*
* @param controlListener the control listener
*/
public TransportControlPanel(TransportControlListener controlListener) {
this.controlListener = controlListener;
ButtonGroup buttonGroup = new ButtonGroup();
setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
FlowLayout flowLayout = (FlowLayout) getLayout();
flowLayout.setHgap(10);
playButton = new ToggleButton(Images.getImageIcon(Images.PLAY));
add(playButton);
buttonGroup.add(playButton);
playButton.addActionListener(this);
pauseButton = new ToggleButton(Images.getImageIcon(Images.PAUSE));
add(pauseButton);
buttonGroup.add(pauseButton);
pauseButton.addActionListener(this);
stopButton = new ToggleButton(Images.getImageIcon(Images.STOP));
add(stopButton);
buttonGroup.add(stopButton);
stopButton.addActionListener(this);
invisibleButton = new JToggleButton("");
buttonGroup.add(invisibleButton);
// Until 'Play' is pressed, then pause and stop are disabled:
pauseButton.setEnabled(false);
stopButton.setEnabled(false);
}
private FlowLayout getFlowLayout(int hGap, int vGap)
{
FlowLayout fl = new FlowLayout(FlowLayout.LEFT);
fl.setHgap(hGap);
fl.setVgap(vGap);
return fl;
}
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 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));
}
/** Creates the ui. */
private void createUI() {
setLayout(new BorderLayout());
box = Box.createVerticalBox();
box.setBorder(null);
add(box, BorderLayout.CENTER);
//
// Literal panel
//
setUpLiteralPanel();
box.add(Box.createVerticalStrut(VERTICAL_STRUCT_SIZE));
//
// Property / attribute
//
setUpPropertyPanel();
box.add(Box.createVerticalStrut(VERTICAL_STRUCT_SIZE));
//
// Environment variable
//
setUpEnvVarPanel();
box.add(Box.createVerticalStrut(VERTICAL_STRUCT_SIZE));
//
// Function panel
//
setUpFunctionPanel();
box.add(Box.createVerticalStrut(VERTICAL_STRUCT_SIZE));
//
// Maths panel
//
setUpMathsPanel();
box.add(Box.createVerticalStrut(VERTICAL_STRUCT_SIZE));
JPanel panelRemoveParameter = new JPanel();
FlowLayout flowLayout = (FlowLayout) panelRemoveParameter.getLayout();
flowLayout.setVgap(1);
flowLayout.setHgap(1);
panelRemoveParameter.setMinimumSize(new Dimension(150, 25));
panelRemoveParameter.setPreferredSize(new Dimension(150, 25));
box.add(panelRemoveParameter);
btnRemoveParameter =
new JButton(
Localisation.getString(
ExpressionPanelv2.class, "ExpressionSubPanel.removeParameter"));
btnRemoveParameter.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
removeParameter();
}
});
panelRemoveParameter.add(btnRemoveParameter);
box.add(createApplyRevertPanel());
}
public DeckDetailsPanel() {
GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[] { 0, 140, 0, 0, 0 };
gridBagLayout.rowHeights = new int[] { 28, 30, 35, 0, 132, 31, 0, 0, 0, 0 };
gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 1.0E-4 };
gridBagLayout.rowWeights = new double[] { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0E-4 };
setLayout(gridBagLayout);
add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("DECK_NAME") + " :"), UITools.createGridBagConstraints(null, null, 1, 0));
nameJTextField = new JTextField();
add(nameJTextField, UITools.createGridBagConstraints(null, GridBagConstraints.HORIZONTAL, 2, 0));
add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("CARD_LEGALITIES") + " :"), UITools.createGridBagConstraints(null, null, 1, 1));
panelLegalities = new JPanel();
FlowLayout flowLayout = (FlowLayout) panelLegalities.getLayout();
flowLayout.setHgap(10);
flowLayout.setAlignment(FlowLayout.LEFT);
add(panelLegalities, UITools.createGridBagConstraints(null, GridBagConstraints.BOTH, 2, 1));
add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("CARD_COLOR") + " :"), UITools.createGridBagConstraints(null, null, 1, 2));
manaPanel = new ManaPanel();
add(manaPanel, UITools.createGridBagConstraints(null, GridBagConstraints.BOTH, 2, 2));
lblDate = new JLabel(MTGControler.getInstance().getLangService().getCapitalize("DATE") + " :");
add(lblDate, UITools.createGridBagConstraints(null, null, 1, 3));
lblDateInformation = new JLabel("");
add(lblDateInformation, UITools.createGridBagConstraints(GridBagConstraints.WEST, null, 2, 3));
add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("DESCRIPTION") + " :"), UITools.createGridBagConstraints(null, null, 1, 4));
textArea = new JTextArea();
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("QTY") + " :"), UITools.createGridBagConstraints(null, null, 1, 5));
nbCardsProgress = new JProgressBar();
nbCardsProgress.setStringPainted(true);
add(nbCardsProgress, UITools.createGridBagConstraints(null, GridBagConstraints.HORIZONTAL, 2, 5));
lbstd = new JLabel(" STD ");
lbstd.setOpaque(true);
lbstd.setBackground(Color.GREEN);
lbmnd = new JLabel(" MDN ");
lbmnd.setOpaque(true);
lbmnd.setBackground(Color.GREEN);
lbvin = new JLabel(" VIN ");
lbvin.setOpaque(true);
lbvin.setBackground(Color.GREEN);
lbcmd = new JLabel(" CMD ");
lbcmd.setOpaque(true);
lbcmd.setBackground(Color.GREEN);
lbLeg = new JLabel(" LEG ");
lbLeg.setOpaque(true);
lbLeg.setBackground(Color.GREEN);
panelLegalities.add(lbvin);
panelLegalities.add(lbLeg);
panelLegalities.add(lbstd);
panelLegalities.add(lbmnd);
panelLegalities.add(lbcmd);
add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("SIDEBOARD") + " :"), UITools.createGridBagConstraints(null, null, 1, 6));
nbSideProgress = new JProgressBar();
nbSideProgress.setMaximum(15);
nbSideProgress.setStringPainted(true);
add(nbSideProgress, UITools.createGridBagConstraints(null, GridBagConstraints.HORIZONTAL, 2, 6));
add(new JScrollPane(textArea), UITools.createGridBagConstraints(null, GridBagConstraints.BOTH, 2, 4));
add(new JLabel(MTGControler.getInstance().getLangService().getCapitalize("TAGS") + " :"), UITools.createGridBagConstraints(null, GridBagConstraints.BOTH, 1, 7));
tagsPanel = new JTagsPanel();
add(tagsPanel, UITools.createGridBagConstraints(GridBagConstraints.WEST, GridBagConstraints.VERTICAL, 2, 7));
panel = new JPanel();
add(panel, UITools.createGridBagConstraints(null, GridBagConstraints.BOTH, 2, 8));
if (magicDeck != null) {
mBindingGroup = initDataBindings();
}
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
FlowLayout flowLayout1 = new FlowLayout();
this.setLayout(flowLayout1);
packing = JPlagCreator.createLabel(Messages.getString(
"ProgressPanel.Packing_files"), 200, 20); //$NON-NLS-1$
sending = JPlagCreator.createLabel(Messages.getString(
"ProgressPanel.Sending_files"), 200, 20); //$NON-NLS-1$
waiting = JPlagCreator.createLabel(Messages.getString(
"ProgressPanel.Waiting_in_queue"),200, 20); //$NON-NLS-1$
parsing = JPlagCreator.createLabel(Messages.getString(
"ProgressPanel.Parsing_files"), 200, 20); //$NON-NLS-1$
comparing = JPlagCreator.createLabel(Messages.getString(
"ProgressPanel.Comparing_files"), 200, 20); //$NON-NLS-1$
loading = JPlagCreator.createLabel(Messages.getString(
"ProgressPanel.Loading_results"), 200, 20); //$NON-NLS-1$
loading.setBackground(Color.WHITE);
this.setPreferredSize(new java.awt.Dimension(200, 120));
// TODO: Upload missing file to repository!!
packing.setIcon(new ImageIcon(getClass().getResource(
"/atujplag/data/current.gif"))); //$NON-NLS-1$
sending.setIcon(new ImageIcon(getClass().getResource(
"/atujplag/data/current.gif"))); //$NON-NLS-1$
waiting.setIcon(new ImageIcon(getClass().getResource(
"/atujplag/data/current.gif"))); //$NON-NLS-1$
parsing.setIcon(new ImageIcon(getClass().getResource(
"/atujplag/data/current.gif"))); //$NON-NLS-1$
comparing.setIcon(new ImageIcon(getClass().getResource(
"/atujplag/data/current.gif"))); //$NON-NLS-1$
loading.setIcon(new ImageIcon(getClass().getResource(
"/atujplag/data/current.gif"))); //$NON-NLS-1$
flowLayout1.setHgap(50);
flowLayout1.setVgap(0);
flowLayout1.setAlignment(java.awt.FlowLayout.CENTER);
this.setBackground(JPlagCreator.SYSTEMCOLOR);
this.add(packing);
this.add(sending);
this.add(waiting);
this.add(parsing);
this.add(comparing);
this.add(loading);
}