下面列出了javax.swing.JLabel#setAlignmentY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private JTextField createEntry(String labelText, int cols, String text,
String toolTipText, JComponent labels,
JComponent values)
{
Box boxLabel = Box.createHorizontalBox();
boxLabel.add(Box.createHorizontalGlue());
JLabel label = new JLabel(i18n(labelText));
label.setAlignmentY(Component.CENTER_ALIGNMENT);
boxLabel.add(label);
labels.add(boxLabel);
JPanel fieldPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
JTextField field = new JTextField(cols);
field.setHorizontalAlignment(JTextField.CENTER);
field.setToolTipText(i18n(toolTipText));
field.setText(text);
fieldPanel.add(field);
values.add(fieldPanel);
return field;
}
private void buildFactoryPidInstanceSelectionBox()
{
final JLabel factoryInstanceLabel = new JLabel("Factory PID instance: ");
factoryInstanceLabel.setToolTipText(FACTORY_PID_INSTANCE_SELECTOR_TOOLTIP);
factoryInstanceLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
factoryInstanceLabel.setAlignmentY(Component.LEFT_ALIGNMENT);
fbox.setAlignmentX(Component.CENTER_ALIGNMENT);
fbox.setAlignmentY(Component.LEFT_ALIGNMENT);
fbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ev)
{
final String slectedPid = (String) fbox.getSelectedItem();
updateSelectionFactoryPID(slectedPid);
TargetPanel.this.owner.targetSelectionChanged();
}
});
factoryPidInstanceSelectionBox.add(factoryInstanceLabel);
factoryPidInstanceSelectionBox.add(Box.createHorizontalStrut(30));
factoryPidInstanceSelectionBox.add(fbox);
}
public SeparatorTitled(String title, boolean bold) {
super(BoxLayout.LINE_AXIS);
JLabel titleLabel = new JLabel(title);
if (bold)
FormUtils.setBold(titleLabel);
titleLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
this.add(titleLabel);
this.add(Box.createHorizontalStrut(5));
JSeparator separator = new JSeparator();
separator.setAlignmentY(Container.TOP_ALIGNMENT);
this.add(separator);
this.setMaximumSize(new Dimension(Short.MAX_VALUE, 20));
}
private void build(String title) {
JLabel titleLabel = new JLabel(title);
if (color != null)
titleLabel.setForeground(color);
titleLabel.setFont(font);
titleLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
this.add(titleLabel);
this.add(Box.createHorizontalStrut(5));
JSeparator separator = new JSeparator();
separator.setAlignmentY(Container.TOP_ALIGNMENT);
this.add(separator);
this.setMaximumSize(new Dimension(Short.MAX_VALUE, 20));
}
private void createTime(TimeSettings timeSettings, JComponent labels,
JComponent values)
{
Box boxLabel = Box.createHorizontalBox();
boxLabel.add(Box.createHorizontalGlue());
JLabel label = new JLabel(i18n("LB_GAMEINFO_TIME"));
label.setAlignmentY(Component.CENTER_ALIGNMENT);
boxLabel.add(label);
labels.add(boxLabel);
Box boxValue = Box.createVerticalBox();
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
boxValue.add(Box.createVerticalGlue());
boxValue.add(panel);
boxValue.add(Box.createVerticalGlue());
m_preByoyomi = new TimeField(3, "TT_GAMEINFO_TIME_MAIN");
if (timeSettings != null)
m_preByoyomi.setTime(timeSettings.getPreByoyomi());
panel.add(m_preByoyomi);
panel.add(new JLabel(" + "));
m_byoyomi = new TimeField(2, "TT_GAMEINFO_TIME_BYOYOMI");
if (timeSettings != null && timeSettings.getUseByoyomi())
m_byoyomi.setTime(timeSettings.getByoyomi());
panel.add(m_byoyomi);
panel.add(new JLabel(" / "));
m_byoyomiMoves = new JTextField(2);
m_byoyomiMoves.setToolTipText(i18n("TT_GAMEINFO_TIME_BYOYOMI_MOVES"));
m_byoyomiMoves.setHorizontalAlignment(JTextField.RIGHT);
if (timeSettings != null && timeSettings.getUseByoyomi())
{
int byoyomiMoves = timeSettings.getByoyomiMoves();
m_byoyomiMoves.setText(Integer.toString(byoyomiMoves));
}
panel.add(m_byoyomiMoves);
panel.add(new JLabel(" " + i18n("LB_GAMEINFO_TIME_MOVES")));
values.add(boxValue);
}
private JComponent createEntryLabel(String text)
{
Box box = Box.createHorizontalBox();
box.add(Box.createHorizontalGlue());
JLabel label = new JLabel(i18n(text));
label.setAlignmentY(Component.CENTER_ALIGNMENT);
box.add(label);
return box;
}
private JComponent createEntryLabel(String text)
{
Box box = Box.createHorizontalBox();
box.add(Box.createHorizontalGlue());
JLabel label = new JLabel(i18n(text));
label.setAlignmentY(Component.CENTER_ALIGNMENT);
box.add(label);
return box;
}
private JTextField createEntry(String labelText, int cols, String text)
{
Box boxLabel = Box.createHorizontalBox();
boxLabel.add(Box.createHorizontalGlue());
JLabel label = new JLabel(i18n(labelText));
label.setAlignmentY(Component.CENTER_ALIGNMENT);
boxLabel.add(label);
m_panelLeft.add(boxLabel);
JPanel fieldPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
JTextField field = new JTextField(cols);
field.setText(text);
fieldPanel.add(field);
m_panelRight.add(fieldPanel);
return field;
}
/**
* Creates a new {@link Technique} editor.
*
* @param technique The {@link Technique} to edit.
*/
public TechniqueEditor(Technique technique) {
super(technique);
JPanel content = new JPanel(new ColumnLayout(2));
JPanel fields = new JPanel(new ColumnLayout(2));
JLabel icon = new JLabel(technique.getIcon(true));
Container wrapper;
mNameField = createCorrectableField(fields, fields, I18n.Text("Name"), technique.getName(), I18n.Text("The base name of the technique, without any notes or specialty information"));
mNotesField = createField(fields, fields, I18n.Text("Notes"), technique.getNotes(), I18n.Text("Any notes that you would like to show up in the list along with this technique"), 0);
mCategoriesField = createField(fields, fields, I18n.Text("Categories"), technique.getCategoriesAsString(), I18n.Text("The category or categories the technique belongs to (separate multiple categories with a comma)"), 0);
createDefaults(fields);
createLimits(fields);
wrapper = createDifficultyPopups(fields);
mReferenceField = createField(wrapper, wrapper, I18n.Text("Page Reference"), mRow.getReference(), I18n.Text("A reference to the book and page this technique appears on (e.g. B22 would refer to \"Basic Set\", page 22)"), 6);
icon.setVerticalAlignment(SwingConstants.TOP);
icon.setAlignmentY(-1.0f);
content.add(icon);
content.add(fields);
add(content);
mTabPanel = new JTabbedPane();
mPrereqs = new PrereqsPanel(mRow, mRow.getPrereqs());
mFeatures = new FeaturesPanel(mRow, mRow.getFeatures());
mMeleeWeapons = MeleeWeaponEditor.createEditor(mRow);
mRangedWeapons = RangedWeaponEditor.createEditor(mRow);
Component panel = embedEditor(mPrereqs);
mTabPanel.addTab(panel.getName(), panel);
panel = embedEditor(mFeatures);
mTabPanel.addTab(panel.getName(), panel);
mTabPanel.addTab(mMeleeWeapons.getName(), mMeleeWeapons);
mTabPanel.addTab(mRangedWeapons.getName(), mRangedWeapons);
UIUtilities.selectTab(mTabPanel, getLastTabName());
add(mTabPanel);
}
/**
* Creates a new {@link Note} editor.
*
* @param note The {@link Note} to edit.
*/
public NoteEditor(Note note) {
super(note);
JPanel content = new JPanel(new ColumnLayout(2, RowDistribution.GIVE_EXCESS_TO_LAST));
JLabel iconLabel = new JLabel(note.getIcon(true));
JPanel right = new JPanel(new ColumnLayout(1, RowDistribution.GIVE_EXCESS_TO_LAST));
content.add(iconLabel);
content.add(right);
mReferenceField = new JTextField(Text.makeFiller(6, 'M'));
UIUtilities.setToPreferredSizeOnly(mReferenceField);
mReferenceField.setText(note.getReference());
mReferenceField.setToolTipText(Text.wrapPlainTextForToolTip(I18n.Text("A reference to the book and page this note applies to (e.g. B22 would refer to \"Basic Set\", page 22)")));
mReferenceField.setEnabled(mIsEditable);
JPanel wrapper = new JPanel(new ColumnLayout(4));
wrapper.add(new LinkedLabel(I18n.Text("Note Content:")));
wrapper.add(new JPanel());
wrapper.add(new LinkedLabel(I18n.Text("Page Reference"), mReferenceField));
wrapper.add(mReferenceField);
right.add(wrapper);
mEditor = new JTextArea(note.getDescription());
mEditor.setLineWrap(true);
mEditor.setWrapStyleWord(true);
mEditor.setEnabled(mIsEditable);
JScrollPane scroller = new JScrollPane(mEditor, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
scroller.setMinimumSize(new Dimension(400, 300));
iconLabel.setVerticalAlignment(SwingConstants.TOP);
iconLabel.setAlignmentY(-1.0f);
right.add(scroller);
add(content);
}
public void updateTextWithIcons() {
textPane.setText(textPane.getText().replaceAll("(?m)^[ \t]*\r?\n", ""));
Pattern p = Pattern.compile(CardsPatterns.MANA_PATTERN.getPattern());
Matcher m = p.matcher(textPane.getText());
String text = textPane.getText();
StyleContext context = new StyleContext();
StyledDocument document = new DefaultStyledDocument(context);
Style labelStyle = context.getStyle(StyleContext.DEFAULT_STYLE);
Style italic = context.addStyle("italicStyle", labelStyle);
StyleConstants.setItalic(italic, true);
int cumule = 0;
try {
document.insertString(0, text, null);
while (m.find()) {
Image ic = manaPanel.getManaSymbol(m.group());
int width = 15;
if (m.group().equals("{100}"))
width = 30;
JLabel label = new JLabel(new ImageIcon(ic.getScaledInstance(width, 15, Image.SCALE_DEFAULT)));
label.setAlignmentY(SwingConstants.TOP);
StyleConstants.setComponent(labelStyle, label);
document.remove(m.start() + cumule, (m.end() - m.start()));
document.insertString(m.start() + cumule, m.group(), labelStyle);
}
textPane.setDocument(document);
} catch (BadLocationException e) {
textPane.setText(text);
}
}
public ParametersPanel() {
messageLabel.setLabelFor(messageTextArea);
Mnemonics.setLocalizedText(messageLabel, getMessage("CTL_CommitForm_Message")); // NOI18N
JLabel templateLink = getMessagesTemplateLink(messageTextArea, "org.netbeans.modules.versioning.util.common.TemplatePanel"); //NOI18N
JLabel recentLink = getRecentMessagesLink(messageTextArea);
messageTextArea.setColumns(60); //this determines the preferred width of the whole dialog
messageTextArea.setLineWrap(true);
messageTextArea.setRows(4);
messageTextArea.setTabSize(4);
messageTextArea.setWrapStyleWord(true);
messageTextArea.setMinimumSize(new Dimension(100, 18));
scrollpane.setViewportView(messageTextArea);
messageTextArea.getAccessibleContext().setAccessibleName(getMessage("ACSN_CommitForm_Message")); // NOI18N
messageTextArea.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_CommitForm_Message")); // NOI18N
if(commitMessage != null) {
messageTextArea.setText(commitMessage);
}
JPanel topPanel = new VerticallyNonResizingPanel();
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS));
topPanel.add(messageLabel);
topPanel.add(Box.createHorizontalGlue());
topPanel.add(recentLink);
topPanel.add(makeHorizontalStrut(recentLink, templateLink, RELATED, this));
topPanel.add(templateLink);
messageLabel.setAlignmentX(LEFT_ALIGNMENT);
messageLabel.setAlignmentY(BOTTOM_ALIGNMENT);
recentLink.setAlignmentY(BOTTOM_ALIGNMENT);
templateLink.setAlignmentY(BOTTOM_ALIGNMENT);
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
topPanel.setAlignmentY(BOTTOM_ALIGNMENT);
add(topPanel);
add(makeVerticalStrut(messageLabel, scrollpane, RELATED, this));
add(scrollpane);
Spellchecker.register (messageTextArea);
}
/**
* Creates a new {@link Equipment} editor.
*
* @param equipment The {@link Equipment} to edit.
* @param carried {@code true} for the carried equipment, {@code false} for the other
* equipment.
*/
public EquipmentEditor(Equipment equipment, boolean carried) {
super(equipment);
mCarried = carried;
JPanel content = new JPanel(new ColumnLayout(2));
JPanel fields = new JPanel(new ColumnLayout(2));
JLabel icon = new JLabel(equipment.getIcon(true));
mDescriptionField = createCorrectableField(fields, I18n.Text("Name"), equipment.getDescription(), I18n.Text("The name/description of the equipment, without any notes"));
createSecondLineFields(fields);
createValueAndWeightFields(fields);
mNotesField = createField(fields, fields, I18n.Text("Notes"), equipment.getNotes(), I18n.Text("Any notes that you would like to show up in the list along with this equipment"), 0);
mCategoriesField = createField(fields, fields, I18n.Text("Categories"), equipment.getCategoriesAsString(), I18n.Text("The category or categories the equipment belongs to (separate multiple categories with a comma)"), 0);
boolean forCharacterOrTemplate = equipment.getCharacter() != null || equipment.getTemplate() != null;
JPanel wrapper = new JPanel(new ColumnLayout(forCharacterOrTemplate ? 5 : 3));
if (forCharacterOrTemplate) {
mUsesField = createIntegerNumberField(fields, wrapper, I18n.Text("Uses"), mRow.getUses(), I18n.Text("The number of uses remaining for this equipment"), 5);
mMaxUsesField = createIntegerNumberField(wrapper, wrapper, I18n.Text("Max Uses"), mRow.getMaxUses(), I18n.Text("The maximum number of uses for this equipment"), 5);
} else {
mMaxUsesField = createIntegerNumberField(fields, wrapper, I18n.Text("Max Uses"), mRow.getMaxUses(), I18n.Text("The maximum number of uses for this equipment"), 5);
}
mReferenceField = createField(wrapper, wrapper, I18n.Text("Page Reference"), mRow.getReference(), I18n.Text("A reference to the book and page this equipment appears on (e.g. B22 would refer to \"Basic Set\", page 22)"), 6);
fields.add(wrapper);
icon.setVerticalAlignment(SwingConstants.TOP);
icon.setAlignmentY(-1.0f);
content.add(icon);
content.add(fields);
add(content);
mTabPanel = new JTabbedPane();
mModifiers = EquipmentModifierListEditor.createEditor(mRow);
mModifiers.addActionListener(this);
mPrereqs = new PrereqsPanel(mRow, mRow.getPrereqs());
mFeatures = new FeaturesPanel(mRow, mRow.getFeatures());
mMeleeWeapons = MeleeWeaponEditor.createEditor(mRow);
mRangedWeapons = RangedWeaponEditor.createEditor(mRow);
mTabPanel.addTab(mMeleeWeapons.getName(), mMeleeWeapons);
mTabPanel.addTab(mRangedWeapons.getName(), mRangedWeapons);
Component panel = embedEditor(mPrereqs);
mTabPanel.addTab(panel.getName(), panel);
panel = embedEditor(mFeatures);
mTabPanel.addTab(panel.getName(), panel);
mTabPanel.addTab(mModifiers.getName(), mModifiers);
if (!mIsEditable) {
UIUtilities.disableControls(mMeleeWeapons);
UIUtilities.disableControls(mRangedWeapons);
UIUtilities.disableControls(mModifiers);
}
UIUtilities.selectTab(mTabPanel, getLastTabName());
add(mTabPanel);
}
/**
* Creates a new {@link Spell} {@link RowEditor}.
*
* @param spell The row being edited.
*/
protected RitualMagicSpellEditor(RitualMagicSpell spell) {
super(spell);
Container content = new JPanel(new ColumnLayout(2));
Container fields = new JPanel(new ColumnLayout());
Container wrapper1 = new JPanel(new ColumnLayout(3));
Container wrapper2 = new JPanel(new ColumnLayout(4));
Container wrapper3 = new JPanel(new ColumnLayout(2));
Container noGapWrapper = new JPanel(new ColumnLayout(2, 0, 0));
JLabel icon = new JLabel(spell.getIcon(true));
Dimension size = new Dimension();
Container ptsPanel;
mNameField = createCorrectableField(wrapper1, wrapper1, I18n.Text("Name"), spell.getName(), I18n.Text("The name of the spell, without any notes"));
fields.add(wrapper1);
createTechLevelFields(wrapper1);
mBaseSkillNameField = createCorrectableField(wrapper2, wrapper2, I18n.Text("Base Skill"), spell.getBaseSkillName(), I18n.Text("The name of the base skill, such as \"Ritual Magic\" or \"Thaumatology\""));
mPrerequisiteSpellsCountField = createNumberField(wrapper2, wrapper2, I18n.Text("Prerequisite Count"), I18n.Text("The penalty to skill level based on the number of prerequisite spells"), mRow.getPrerequisiteSpellsCount(), 2);
mCollegeField = createField(wrapper2, wrapper2, I18n.Text("College"), spell.getCollege(), I18n.Text("The college the spell belongs to"), 0);
mPowerSourceField = createField(wrapper2, wrapper2, I18n.Text("Power Source"), spell.getPowerSource(), I18n.Text("The source of power for the spell"), 0);
mClassField = createCorrectableField(wrapper2, wrapper2, I18n.Text("Class"), spell.getSpellClass(), I18n.Text("The class of spell (Area, Missile, etc.)"));
mCastingCostField = createCorrectableField(wrapper2, wrapper2, I18n.Text("Casting Cost"), spell.getCastingCost(), I18n.Text("The casting cost of the spell"));
mMaintenanceField = createField(wrapper2, wrapper2, I18n.Text("Maintenance Cost"), spell.getMaintenance(), I18n.Text("The cost to maintain a spell after its initial duration"), 0);
mCastingTimeField = createCorrectableField(wrapper2, wrapper2, I18n.Text("Casting Time"), spell.getCastingTime(), I18n.Text("The casting time of the spell"));
mResistField = createCorrectableField(wrapper2, wrapper2, I18n.Text("Resist"), spell.getResist(), I18n.Text("The resistance roll, if any"));
mDurationField = createCorrectableField(wrapper2, wrapper2, I18n.Text("Duration"), spell.getDuration(), I18n.Text("The duration of the spell once its cast"));
fields.add(wrapper2);
ptsPanel = createPointsFields();
fields.add(ptsPanel);
mNotesField = createField(wrapper3, wrapper3, I18n.Text("Notes"), spell.getNotes(), I18n.Text("Any notes that you would like to show up in the list along with this spell"), 0);
mCategoriesField = createField(wrapper3, wrapper3, I18n.Text("Categories"), spell.getCategoriesAsString(), I18n.Text("The category or categories the spell belongs to (separate multiple categories with a comma)"), 0);
mReferenceField = createField(ptsPanel, noGapWrapper, I18n.Text("Page Reference"), mRow.getReference(), I18n.Text("A reference to the book and page this spell appears on (e.g. B22 would refer to \"Basic Set\", page 22)"), 6);
noGapWrapper.add(new JPanel());
ptsPanel.add(noGapWrapper);
fields.add(wrapper3);
determineLargest(wrapper1, 3, size);
determineLargest(wrapper2, 4, size);
determineLargest(ptsPanel, 100, size);
determineLargest(wrapper3, 2, size);
applySize(wrapper1, 3, size);
applySize(wrapper2, 4, size);
applySize(ptsPanel, 100, size);
applySize(wrapper3, 2, size);
icon.setVerticalAlignment(SwingConstants.TOP);
icon.setAlignmentY(-1.0f);
content.add(icon);
content.add(fields);
add(content);
mTabPanel = new JTabbedPane();
mPrereqs = new PrereqsPanel(mRow, mRow.getPrereqs());
mMeleeWeapons = MeleeWeaponEditor.createEditor(mRow);
mRangedWeapons = RangedWeaponEditor.createEditor(mRow);
Component panel = embedEditor(mPrereqs);
mTabPanel.addTab(panel.getName(), panel);
mTabPanel.addTab(mMeleeWeapons.getName(), mMeleeWeapons);
mTabPanel.addTab(mRangedWeapons.getName(), mRangedWeapons);
if (!mIsEditable) {
UIUtilities.disableControls(mMeleeWeapons);
UIUtilities.disableControls(mRangedWeapons);
}
UIUtilities.selectTab(mTabPanel, getLastTabName());
add(mTabPanel);
}
/**
* Creates a new {@link Spell} editor.
*
* @param spell The {@link Spell} to edit.
*/
public SpellEditor(Spell spell) {
super(spell);
boolean notContainer = !spell.canHaveChildren();
Container content = new JPanel(new ColumnLayout(2));
Container fields = new JPanel(new ColumnLayout());
Container wrapper1 = new JPanel(new ColumnLayout(notContainer ? 3 : 2));
Container wrapper2 = new JPanel(new ColumnLayout(4));
Container wrapper3 = new JPanel(new ColumnLayout(2));
Container noGapWrapper = new JPanel(new ColumnLayout(2, 0, 0));
Container ptsPanel = null;
JLabel icon = new JLabel(spell.getIcon(true));
Dimension size = new Dimension();
Container refParent = wrapper3;
mNameField = createCorrectableField(wrapper1, wrapper1, I18n.Text("Name"), spell.getName(), I18n.Text("The name of the spell, without any notes"));
fields.add(wrapper1);
if (notContainer) {
createTechLevelFields(wrapper1);
mCollegeField = createField(wrapper2, wrapper2, I18n.Text("College"), spell.getCollege(), I18n.Text("The college the spell belongs to"), 0);
mPowerSourceField = createField(wrapper2, wrapper2, I18n.Text("Power Source"), spell.getPowerSource(), I18n.Text("The source of power for the spell"), 0);
mClassField = createCorrectableField(wrapper2, wrapper2, I18n.Text("Class"), spell.getSpellClass(), I18n.Text("The class of spell (Area, Missile, etc.)"));
mCastingCostField = createCorrectableField(wrapper2, wrapper2, I18n.Text("Casting Cost"), spell.getCastingCost(), I18n.Text("The casting cost of the spell"));
mMaintenanceField = createField(wrapper2, wrapper2, I18n.Text("Maintenance Cost"), spell.getMaintenance(), I18n.Text("The cost to maintain a spell after its initial duration"), 0);
mCastingTimeField = createCorrectableField(wrapper2, wrapper2, I18n.Text("Casting Time"), spell.getCastingTime(), I18n.Text("The casting time of the spell"));
mResistField = createCorrectableField(wrapper2, wrapper2, I18n.Text("Resist"), spell.getResist(), I18n.Text("The resistance roll, if any"));
mDurationField = createCorrectableField(wrapper2, wrapper2, I18n.Text("Duration"), spell.getDuration(), I18n.Text("The duration of the spell once its cast"));
fields.add(wrapper2);
ptsPanel = createPointsFields();
fields.add(ptsPanel);
refParent = ptsPanel;
}
mNotesField = createField(wrapper3, wrapper3, I18n.Text("Notes"), spell.getNotes(), I18n.Text("Any notes that you would like to show up in the list along with this spell"), 0);
mCategoriesField = createField(wrapper3, wrapper3, I18n.Text("Categories"), spell.getCategoriesAsString(), I18n.Text("The category or categories the spell belongs to (separate multiple categories with a comma)"), 0);
mReferenceField = createField(refParent, noGapWrapper, I18n.Text("Page Reference"), mRow.getReference(), I18n.Text("A reference to the book and page this spell appears on (e.g. B22 would refer to \"Basic Set\", page 22)"), 6);
noGapWrapper.add(new JPanel());
refParent.add(noGapWrapper);
fields.add(wrapper3);
determineLargest(wrapper1, 3, size);
determineLargest(wrapper2, 4, size);
if (ptsPanel != null) {
determineLargest(ptsPanel, 100, size);
}
determineLargest(wrapper3, 2, size);
applySize(wrapper1, 3, size);
applySize(wrapper2, 4, size);
if (ptsPanel != null) {
applySize(ptsPanel, 100, size);
}
applySize(wrapper3, 2, size);
icon.setVerticalAlignment(SwingConstants.TOP);
icon.setAlignmentY(-1.0f);
content.add(icon);
content.add(fields);
add(content);
if (notContainer) {
mTabPanel = new JTabbedPane();
mPrereqs = new PrereqsPanel(mRow, mRow.getPrereqs());
mMeleeWeapons = MeleeWeaponEditor.createEditor(mRow);
mRangedWeapons = RangedWeaponEditor.createEditor(mRow);
Component panel = embedEditor(mPrereqs);
mTabPanel.addTab(panel.getName(), panel);
mTabPanel.addTab(mMeleeWeapons.getName(), mMeleeWeapons);
mTabPanel.addTab(mRangedWeapons.getName(), mRangedWeapons);
if (!mIsEditable) {
UIUtilities.disableControls(mMeleeWeapons);
UIUtilities.disableControls(mRangedWeapons);
}
UIUtilities.selectTab(mTabPanel, getLastTabName());
add(mTabPanel);
}
}
private void buildTargetSelectionBox()
{
final JLabel targetedLabel = new JLabel("Configuration target level: ");
targetedLabel.setToolTipText(CONFIGURATION_TARGET_LEVEL_TOOLTIP);
targetedLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
targetedLabel.setAlignmentY(Component.LEFT_ALIGNMENT);
targetSelectionBox.add(targetedLabel);
targetSelectionBox.add(Box.createHorizontalStrut(30));
for (int i = 0; i < MAX_SIZE; i++) {
rbs[i] = new JRadioButton(TARGET_LEVEL_NAMES[i]);
bg.add(rbs[i]);
rbs[i].setActionCommand(String.valueOf(i));
rbs[i].setAlignmentX(Component.CENTER_ALIGNMENT);
rbs[i].setAlignmentY(Component.LEFT_ALIGNMENT);
rbs[i].addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event)
{
// If this is a factory PID then changing target level must be handled
// as a request for a new instance with the selected binding.
// Thus we change the selected PID in fbox to the default entry. We
// must do this without triggering an action event, thus replace the
// model with a new empty model, change selection in the real model
// and set it back as the model of the combo-box.
final ComboBoxModel cbm = fbox.getModel();
fbox.setModel(new DefaultComboBoxModel());
cbm.setSelectedItem(FACTORY_PID_DEFAULTS);
fbox.setModel(cbm);
selectedTargetLevel = Integer.parseInt(event.getActionCommand());
TargetPanel.this.owner.targetSelectionChanged();
}
});
targetSelectionBox.add(rbs[i]);
icons[i] = new JLabel(newDocumentIcon);
icons[i].setAlignmentX(Component.BOTTOM_ALIGNMENT);
icons[i].setAlignmentY(Component.LEFT_ALIGNMENT);
targetSelectionBox.add(icons[i]);
targetSelectionBox.add(Box.createHorizontalGlue());
}
}
/**
* ctor.
*
* @param app Application API
*
* @throws IllegalArgumentException
* <TT>null</TT> <TT>IApplication</TT> or <TT>MainFrame</TT>
* passed.
*/
MainFrameToolBar(IApplication app)
{
super();
if (app == null)
{
throw new IllegalArgumentException("IApplication == null");
}
_app = app;
setUseRolloverButtons(true);
setFloatable(true);
ActionCollection actions = _app.getActionCollection();
JLabel lbl = new JLabel(s_stringMgr.getString("MainFrameToolBar.connectTo"));
lbl.setAlignmentY(0.5f);
add(lbl);
AliasesDropDown drop = new AliasesDropDown(app);
drop.setAlignmentY(0.5f);
add(drop);
addSeparator();
add(actions.get(GlobalPreferencesAction.class));
add(actions.get(NewSessionPropertiesAction.class));
if (_app.getDesktopStyle().isInternalFrameStyle())
{
addSeparator();
add(actions.get(TileAction.class));
add(actions.get(TileHorizontalAction.class));
add(actions.get(TileVerticalAction.class));
add(actions.get(CascadeAction.class));
add(actions.get(MaximizeAction.class));
addSeparator();
}
JLabel lbl2 = new JLabel(" " + s_stringMgr.getString("MainFrameToolBar.activeSession") + " ");
lbl.setAlignmentY(0.5f);
add(lbl2);
SessionDropDown sessionDropDown = new SessionDropDown(app);
sessionDropDown.setAlignmentY(0.5f);
add(sessionDropDown);
addToggleAction((IToggleAction) actions.get(ToggleAutoCommitAction.class));
add(actions.get(CommitAction.class));
add(actions.get(RollbackAction.class));
addSeparator();
add(actions.get(NewSQLWorksheetAction.class));
add(actions.get(NewObjectTreeAction.class));
}
private void init(int numberOfSteps, int messageX, int messageY, Color messageColor) {
JPanel content = new JPanel() {
public boolean isOptimizedDrawingEnabled() {
return false;
}
};
content.setLayout(new OverlayLayout(content));
content.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
JPanel dynamicContent = new JPanel();
dynamicContent.setOpaque(false);
dynamicContent.setLayout(new GridBagLayout());
message = new JLabel();
message.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
message.setForeground(messageColor);
progressBar = new JProgressBar();
progressBar.setPreferredSize(new Dimension(icon.getIconWidth(), 18));
progressBar.setIndeterminate(false);
progressBar.setMaximum(numberOfSteps);
progressBar.setVisible(false);
GridBagConstraints c = GuiUtil.setConstraints(0, 0, 1, 1, GridBagConstraints.HORIZONTAL, 5 + messageY, 5 + messageX, 0, 5);
c.anchor = GridBagConstraints.NORTH;
dynamicContent.add(message, c);
c = GuiUtil.setConstraints(0, 1, 1, 1, GridBagConstraints.HORIZONTAL, 5, 5, 5, 5);
c.anchor = GridBagConstraints.SOUTH;
dynamicContent.add(progressBar, c);
dynamicContent.setAlignmentX(0f);
dynamicContent.setAlignmentY(0f);
content.add(dynamicContent);
JLabel image = new JLabel(icon);
image.setAlignmentX(0f);
image.setAlignmentY(0f);
content.add(image);
add(content, BorderLayout.CENTER);
// center on screen
Toolkit t = Toolkit.getDefaultToolkit();
Insets frame_insets = t.getScreenInsets(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration());
int frame_insets_x = frame_insets.left + frame_insets.right;
int frame_insets_y = frame_insets.bottom + frame_insets.top;
Dimension dim = t.getScreenSize();
int x = (dim.width - icon.getIconWidth() - frame_insets_x) / 2;
int y = (dim.height - icon.getIconHeight() - frame_insets_y) / 2;
setMinimumSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
setLocation(x, y);
setAlwaysOnTop(true);
}