本文整理汇总了Java中javax.swing.JSeparator类的典型用法代码示例。如果您正苦于以下问题:Java JSeparator类的具体用法?Java JSeparator怎么用?Java JSeparator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSeparator类属于javax.swing包,在下文中一共展示了JSeparator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSeparator
import javax.swing.JSeparator; //导入依赖的package包/类
public static JPanel createSeparator(String message) {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.anchor = GridBagConstraints.WEST;
c.insets = new Insets(LARGE_SIZE, 0, LARGE_SIZE, 0);
panel.add(createLabel(message), c);
c.weightx = 1.0;
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(LARGE_SIZE, LARGE_SIZE, LARGE_SIZE, 0);
panel.add(new JSeparator(), c);
return panel;
}
示例2: initialize
import javax.swing.JSeparator; //导入依赖的package包/类
/**
* in jedem Konstruktor verwendete Initialisationsmethode
* @param song
* @param midiPlayer
* @param songChanger
*/
void initialize(Song song, MidiPlayer midiPlayer, ISongChanger songChanger){
player = midiPlayer;
songChanger.addSongChangeObserver(this);
openMenu = new JMenuItem("Öffnen");
saveMenu = new JMenuItem("Speichern");
separator = new JSeparator();
exitMenu = new JMenuItem("Beenden");
ActionHandler aH = new ActionHandler();
openMenu.addActionListener(aH);
saveMenu.addActionListener(aH);
exitMenu.addActionListener(aH);
add(openMenu);
add(saveMenu);
add(separator);
add(exitMenu);
songChange( song );
}
示例3: addREFUnits
import javax.swing.JSeparator; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void addREFUnits() {
final Specification spec = getSpecification();
final Player player = getMyPlayer();
final Nation refNation = player.getNation().getREFNation();
reportPanel.add(new JLabel(Messages.getName(refNation)), SPAN_SPLIT_2);
reportPanel.add(new JSeparator(JSeparator.HORIZONTAL), "growx");
List<AbstractUnit> refUnits = player.getREFUnits();
if (refUnits != null) {
for (AbstractUnit au : refUnits) {
if (au.getType(spec).isNaval()) {
reportPanel.add(createUnitTypeLabel(au), "sg");
}
}
}
}
示例4: buildHelpMenu
import javax.swing.JSeparator; //导入依赖的package包/类
private void buildHelpMenu() {
setOnlineDocumentationOption(new JMenuItem("Documentation"));
setSourceCodeOption(new JMenuItem("Source Code"));
setAboutOption(new JMenuItem("About"));
getOnlineDocumentationOption().addActionListener(new HelpOptionListener());
getSourceCodeOption().addActionListener(new HelpOptionListener());
getAboutOption().addActionListener(new HelpOptionListener());
setHelpMenu(new JMenu());
getHelpMenu().setMnemonic(KeyEvent.VK_H);
//getHelpMenu().add(getOnlineDocumentationOption());
getHelpMenu().add(getSourceCodeOption());
getHelpMenu().add(new JSeparator());
getHelpMenu().add(getAboutOption());
}
示例5: addOwnUnits
import javax.swing.JSeparator; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void addOwnUnits() {
final Player player = getMyPlayer();
reportPanel.add(Utility.localizedLabel(player.getForcesLabel()), NL_SPAN_SPLIT_2);
reportPanel.add(new JSeparator(JSeparator.HORIZONTAL), "growx");
for (UnitType unitType : getSpecification().getUnitTypeList()) {
if (!isReportable(unitType)) continue;
AbstractUnit au = new AbstractUnit(unitType,
Specification.DEFAULT_ROLE_ID,
getCount("naval", unitType));
reportPanel.add(createUnitTypeLabel(au), "sg");
}
}
示例6: addPresenter
import javax.swing.JSeparator; //导入依赖的package包/类
private void addPresenter(JComponent presenter) {
if (!showIcons && presenter instanceof AbstractButton) {
((AbstractButton) presenter).setIcon(null);
}
boolean isSeparator = presenter == null || presenter instanceof JSeparator;
if (isSeparator) {
if (!wasSeparator) {
shouldAddSeparator = true;
wasSeparator = true;
}
} else {
if (shouldAddSeparator) {
addSeparator();
shouldAddSeparator = false;
}
add(presenter);
wasSeparator = false;
}
}
示例7: createMenuItems
import javax.swing.JSeparator; //导入依赖的package包/类
private List<JComponent> createMenuItems(Lookup context) {
if (fileObjectList.isEmpty()) {
return Collections.emptyList();
}
List <JComponent> result = new ArrayList<JComponent>(fileObjectList.size() + 1);
result.addAll(retrieveMenuItems(fileObjectList, context));
if (!result.isEmpty()) {
// add separator at beginning of the context menu
if (result.get(0) instanceof JSeparator) {
result.set(0, null);
} else {
result.add(0, null);
}
}
return result;
}
示例8: loadActions
import javax.swing.JSeparator; //导入依赖的package包/类
private void loadActions(List<Action> actions, DataFolder df) throws IOException, ClassNotFoundException {
DataObject[] dob = df.getChildren();
int i;
int k = dob.length;
for (i = 0; i < k; i++) {
InstanceCookie ic = dob[i].getCookie(InstanceCookie.class);
if (ic == null) {
LOG.log(Level.WARNING, "Not an action instance, or broken action: {0}", dob[i].getPrimaryFile());
continue;
}
Class clazz = ic.instanceClass();
if (JSeparator.class.isAssignableFrom(clazz)) {
actions.add(null);
} else {
actions.add((Action)ic.instanceCreate());
}
}
}
示例9: acceptCookie
import javax.swing.JSeparator; //导入依赖的package包/类
/**
* Accepts only cookies that can provide <code>Menu</code>.
* @param cookie an <code>InstanceCookie</code> to test
* @return true if the cookie can provide accepted instances
*/
protected @Override InstanceCookie acceptCookie(InstanceCookie cookie)
throws IOException, ClassNotFoundException {
// [pnejedly] Don't try to optimize this by InstanceCookie.Of
// It will load the classes few ms later from instanceCreate
// anyway and more instanceOf calls take longer
Class c = cookie.instanceClass();
boolean action = Action.class.isAssignableFrom (c);
if (action) {
cookie.instanceCreate();
}
boolean is =
Presenter.Menu.class.isAssignableFrom (c) ||
JMenuItem.class.isAssignableFrom (c) ||
JSeparator.class.isAssignableFrom (c) ||
action;
return is ? cookie : null;
}
示例10: checkSeparators
import javax.swing.JSeparator; //导入依赖的package包/类
static void checkSeparators(Component[] menuones, JPopupMenu parent) {
boolean wasSeparator = false;
for (int i = 0; i < menuones.length; i++) {
Component curItem = menuones[i];
if (curItem != null) {
boolean isSeparator = curItem instanceof JSeparator;
if (isSeparator) {
boolean isVisible = curItem.isVisible();
if (isVisible != !wasSeparator) {
//MACOSX whenever a property like enablement or visible is changed, need to remove and add.
// could be possibly split to work differetly on other platform..
parent.remove(i);
JSeparator newOne = createSeparator();
newOne.setVisible(!wasSeparator);
parent.add(newOne, i);
}
}
if (!(curItem instanceof InvisibleMenuItem)) {
wasSeparator = isSeparator;
}
}
}
}
示例11: LabelSeparator
import javax.swing.JSeparator; //导入依赖的package包/类
public LabelSeparator(JLabel label)
{
JSeparator separator = new JSeparator();
final int height1 = label.getPreferredSize().height;
final int height2 = separator.getPreferredSize().height;
final int height3 = (height1 - height2) / 2;
final int width1 = label.getPreferredSize().width;
final int[] rows = {height3, height2, height3,};
final int[] cols = {width1, TableLayout.FILL,};
setLayout(new TableLayout(rows, cols));
add(label, new Rectangle(0, 0, 1, 3));
add(separator, new Rectangle(1, 1, 1, 1));
}
示例12: addSeparator
import javax.swing.JSeparator; //导入依赖的package包/类
public void addSeparator() {
if (!UIUtils.isMetalLookAndFeel()) {
super.addSeparator();
} else {
final JSeparator separator = new JSeparator(JSeparator.VERTICAL);
final int WDTH = separator.getPreferredSize().width;
final Dimension SIZE = new Dimension(new JToolBar.Separator().getSeparatorSize().width, 12);
JPanel panel = new JPanel(null) {
public Dimension getPreferredSize() { return SIZE; }
public Dimension getMaximumSize() { return SIZE; }
public Dimension getMinimumSize() { return SIZE; }
public void doLayout() {
int x = (getWidth() - WDTH) / 2;
int y = (getHeight()- SIZE.height) / 2;
separator.setBounds(x, y, WDTH, SIZE.height);
}
};
panel.setOpaque(false);
panel.add(separator);
super.add(panel);
}
}
示例13: fireItemStateChanged
import javax.swing.JSeparator; //导入依赖的package包/类
protected void fireItemStateChanged(ItemEvent e) {
switch (e.getStateChange()) {
case ItemEvent.SELECTED:
if (e.getItem() instanceof JSeparator) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
selectNextItem();
}
});
}
break;
case ItemEvent.DESELECTED:
if (!(e.getItem() instanceof JSeparator)) {
lastSelectedIndex = model.getIndexOf(e.getItem());
}
break;
}
super.fireItemStateChanged(e);
}
示例14: addOwnUnits
import javax.swing.JSeparator; //导入依赖的package包/类
@Override
protected void addOwnUnits() {
final Player player = getMyPlayer();
reportPanel.add(Utility.localizedLabel(player.getForcesLabel()), NL_SPAN_SPLIT_2);
reportPanel.add(new JSeparator(JSeparator.HORIZONTAL), "growx");
for (UnitType unitType : getSpecification().getUnitTypeList()) {
if (unitType.isAvailableTo(player)
&& (unitType.canCarryUnits() || unitType.canCarryGoods())) {
AbstractUnit unit = new AbstractUnit(unitType,
Specification.DEFAULT_ROLE_ID,
getCount("carriers", unitType));
reportPanel.add(createUnitTypeLabel(unit), "sg");
}
}
}
示例15: ReportIndianPanel
import javax.swing.JSeparator; //导入依赖的package包/类
/**
* The constructor that will add the items to this panel.
*
* @param freeColClient The {@code FreeColClient} for the game.
*/
public ReportIndianPanel(FreeColClient freeColClient) {
super(freeColClient, "reportIndianAction");
Player player = getMyPlayer();
reportPanel.setLayout(new MigLayout("wrap 6, fillx, insets 0",
"[]20px[center]", "[top]"));
boolean needsSeperator = false;
for (Player opponent : CollectionUtils.transform(getGame().getLiveNativePlayers(),
p -> player.hasContacted(p))) {
if (needsSeperator) {
reportPanel.add(new JSeparator(JSeparator.HORIZONTAL),
"newline 20, span, growx, wrap 20");
}
buildIndianAdvisorPanel(player, opponent);
needsSeperator = true;
}
scrollPane.getViewport().setOpaque(false);
reportPanel.setOpaque(true);
reportPanel.doLayout();
}