项目:incubator-netbeans
文件:UI.java
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,LARGE_SIZE,0);
panel.add(createLabel(message),c);
c.weightx = 1.0;
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(LARGE_SIZE,0);
panel.add(new JSeparator(),c);
return panel;
}
项目:Random-Music-Generator
文件:FileMenu.java
/**
* 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 );
}
项目:freecol
文件:ReportNavalPanel.java
/**
* {@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");
}
}
}
}
项目:JITRAX
文件:MenuBar.java
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());
}
项目:FreeCol
文件:ReportNavalPanel.java
/**
* {@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");
}
}
项目:incubator-netbeans
文件:RefactoringSubMenuAction.java
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;
}
}
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;
}
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());
}
}
}
项目:freecol
文件:ReportNavalPanel.java
/**
* {@inheritDoc}
*/
@Override
protected void addOwnUnits() {
final Player player = getMyPlayer();
reportPanel.add(Utility.localizedLabel(player.getForcesLabel()),"sg");
}
}
项目:incubator-netbeans
文件:MenuBar.java
/**
* 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;
}
项目:incubator-netbeans
文件:DynaMenuModel.java
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;
}
}
}
}
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,1,3));
add(separator,new Rectangle(1,1));
}
项目:incubator-netbeans
文件:GenericToolbar.java
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);
}
}
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);
}
项目:FreeCol
文件:ReportCargoPanel.java
@Override
protected void addOwnUnits() {
final Player player = getMyPlayer();
reportPanel.add(Utility.localizedLabel(player.getForcesLabel()),"growx");
for (UnitType unitType : getSpecification().getUnitTypeList()) {
if (unitType.isAvailableto(player)
&& (unitType.canCarryUnits() || unitType.canCarryGoods())) {
AbstractUnit unit = new AbstractUnit(unitType,getCount("carriers",unitType));
reportPanel.add(createUnitTypeLabel(unit),"sg");
}
}
}
项目:freecol
文件:ReportIndianPanel.java
/**
* 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();
}
public static void addSeperator(JPanel panel,GridBagConstraints c) {
Insets orig_insets = c.insets;
c.insets = new Insets(0,0);
c.gridwidth = 2;
c.gridheight = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.CENTER;
c.gridx = 0;
panel.add(Box.createVerticalStrut(5),c);
c.gridx = 0;
c.gridy++;
panel.add(new JSeparator(),c);
c.gridx = 0;
c.gridy++;
panel.add(Box.createVerticalStrut(5),c);
c.insets = orig_insets;
return;
}
项目:JavaGridControl
文件:GridControl.java
private void addTrayIcon(Image image) {
systemTray = SystemTray.get();
if (systemTray == null) {
throw new RuntimeException("Unable to load SystemTray!");
}
systemTray.setimage(image);
systemTray.getMenu().add(new MenuItem("Show",a -> {
frame.setVisible(true);
}));
systemTray.getMenu().add(new JSeparator());
systemTray.getMenu().add(new MenuItem("Quit",a -> {
exit();
})).setShortcut('q'); // case does not matter
}
@Override
public void paint(Graphics g,JComponent c)
{
JSeparator sep = (JSeparator) c;
Dimension dim = sep.getSize();
g.setColor(sep.getForeground());
if( sep.getorientation() == SwingConstants.VERTICAL )
{
int x = dim.width / 2;
g.drawLine(x,x,dim.height);
}
else
{
int y = dim.height / 2;
g.drawLine(0,dim.width,y);
}
}
项目:gate-core
文件:Xjpopupmenu.java
/**
* Force separators to be the same width as the jpopupmenu.
* This is because the MenuLayout make separators invisible contrary
* to the default jpopupmenu layout manager.
* @param aFlag true if the popupmenu is visible
*/
@Override
public void setVisible(boolean aFlag) {
super.setVisible(aFlag);
if (!aFlag) { return; }
MenuLayout layout = (MenuLayout) getLayout();
for (int i = 0; i < getComponents().length; i++) {
Component component = getComponents()[i];
if (component instanceof JSeparator) {
JSeparator separator = (JSeparator) component;
int column = layout.getColumnForComponentIndex(i);
int preferredWidth = layout.getPreferredWidthForColumn(column);
// use the popupmenu width to set the separators width
separator.setPreferredSize(new Dimension(
preferredWidth,separator.getHeight()));
}
}
revalidate();
}
项目:KeysPerSecond
文件:Main.java
/**
* Shows the size configuration dialog
*/
protected static final void configureSize(){
JPanel pconfig = new JPanel(new BorderLayout());
JSpinner s = new JSpinner(new SpinnerNumberModel(config.size * 100,50,Integer.MAX_VALUE,1));
JLabel info = new JLabel("<html>Change how big the displayed window is.<br>"
+ "The precentage specifies how big the window is in<br>"
+ "comparison to the default size of the window.<html>");
pconfig.add(info,BorderLayout.PAGE_START);
pconfig.add(new JSeparator(),BorderLayout.CENTER);
JPanel line = new JPanel();
line.add(new JLabel("Size: "));
line.add(s);
line.add(new JLabel("%"));
pconfig.add(line,BorderLayout.PAGE_END);
if(0 == JOptionPane.showOptionDialog(null,pconfig,"Keys per second",JOptionPane.QUESTION_MESSAGE,null,new String[]{"OK","Cancel"},0)){
config.size = ((double)s.getValue()) / 100.0D;
}
}
项目:s-store
文件:AbstractViewer.java
public static void addSeperator(JPanel panel,c);
c.insets = orig_insets;
return;
}
项目:Equella
文件:StepsTab.java
private JComponent createnorth()
{
final JLabel nameLabel = new JLabel(CurrentLocale.get("com.tle.admin.workflow.stepstab.name")); //$NON-NLS-1$
final JLabel ownerLabel = new JLabel(CurrentLocale.get("com.tle.admin.workflow.stepstab.owner")); //$NON-NLS-1$
nameField = new I18nTextField(BundleCache.getLanguages());
owner = new SingleUserSelector(clientService.getService(RemoteUserService.class));
moveLive = new JCheckBox(CurrentLocale.get("com.tle.admin.workflow.stepstab.live")); //$NON-NLS-1$
final int height1 = owner.getPreferredSize().height;
final int width1 = ownerLabel.getPreferredSize().width;
final int[] rows = {height1,height1,};
final JPanel north = new JPanel(new TableLayout(rows,cols));
north.add(nameLabel,1));
north.add(nameField,1));
north.add(ownerLabel,1));
north.add(owner,1));
north.add(moveLive,2,3,1));
north.add(new JSeparator(),1));
return north;
}
项目:Equella
文件:Editor.java
protected void removeSection(JComponent section)
{
for( int i = 0,count = getComponentCount(); i < count; i++ )
{
Component c = getComponent(i);
if( c.equals(section) )
{
remove(i);
// Remove next component too if it's a JSeparator
if( i < count && getComponent(i) instanceof JSeparator )
{
remove(i);
}
}
}
}
项目:Equella
文件:AccessEditor.java
private void setupGUI()
{
JComponent whoCanPanel = createWhoCanPanel();
JComponent modePanel = createModePanel();
container = new JPanel(new GridLayout(1,1));
JSeparator separator = new JSeparator();
final int height1 = whoCanPanel.getPreferredSize().height;
final int height2 = modePanel.getMinimumSize().height;
final int height3 = separator.getPreferredSize().height;
final int[] rows = {height1,};
final int[] cols = {TableLayout.DOUBLE_FILL,cols));
add(whoCanPanel,1));
add(modePanel,1));
add(separator,1));
add(container,1));
}
项目:FreeCol
文件:ReportNavalPanel.java
/**
* {@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)),"sg");
}
}
}
}
项目:VISNode
文件:NodeView.java
/**
* Builds a separator for the node parâmetros
*
* @return JComponent
*/
private JComponent buildSeparator() {
JSeparator separator = new JSeparator(JSeparator.HORIZONTAL);
separator.setBorder(new EmptyBorder(0,25));
separator.setForeground(new Color(0xAAAAAA));
separator.setBackground(new Color(0xAAAAAA));
JPanel container = new JPanel(new BorderLayout());
container.setBorder(new EmptyBorder(0,10,10));
container.add(separator);
container.setAlignmentX(JLabel.LEFT_ALIGNMENT);
container.setopaque(false);
return container;
}
项目:incubator-netbeans
文件:MenuEditLayer.java
public static boolean isNonMenuJSeparator(RADComponent comp) {
if(comp == null) return false;
if(JSeparator.class.isAssignableFrom(comp.getBeanClass())) {
RADComponent parent = comp.getParentComponent();
if(parent != null && JMenu.class.isAssignableFrom(parent.getBeanClass())) {
return false;
}
return true;
}
return false;
}
项目:incubator-netbeans
文件:MenuEditLayer.java
public static boolean isMenuRelatedComponentClass(Class clas) {
if(clas == null) return false;
if(JMenuItem.class.isAssignableFrom(clas)) return true;
if(JMenu.class.isAssignableFrom(clas)) return true;
if(JSeparator.class.isAssignableFrom(clas)) return true;
if(JMenuBar.class.isAssignableFrom(clas)) return true;
return false;
}
项目:incubator-netbeans
文件:MenuEditLayer.java
项目:FreeCol
文件:ReportUnitPanel.java
/**
* The constructor that will add the items to this panel.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param key the report name key
* @param showColonies Whether to show colonies with no selected units.
*/
protected ReportUnitPanel(FreeColClient freeColClient,String key,boolean showColonies) {
super(freeColClient,key);
this.showColonies = showColonies;
reportPanel.setLayout(new MigLayout("fillx,wrap 12","",""));
gatherData();
addREFUnits();
addOwnUnits();
reportPanel.add(new JSeparator(JSeparator.HORIZONTAL),"newline,wrap 40");
// Colonies first,sorted according to user preferences
for (Colony colony : freeColClient.getMySortedColonies()) {
handleLocation(colony,colony.getName(),inColonies.get(colony));
}
// Europe next
Europe europe = getMyPlayer().getEurope();
if (europe != null) {
handleLocation(europe,Messages.getName(europe),inEurope);
}
// Finally all other locations,sorted alphabetically.
forEach(mapEntriesByKey(inLocations),e -> handleLocation(null,e.getKey(),e.getValue()));
revalidate();
repaint();
}
private static void resolveInstance(Object instance,List<JComponent> result) throws IOException {
if (instance instanceof Presenter.Popup) {
JMenuItem temp = ((Presenter.Popup) instance).getPopupPresenter();
result.add(temp);
} else if (instance instanceof JSeparator) {
result.add(null);
} else if (instance instanceof JComponent) {
result.add((JComponent) instance);
} else if (instance instanceof Action) {
Actions.MenuItem mi = new Actions.MenuItem((Action) instance,true);
result.add(mi);
} else {
throw new IOException(String.format("Unsupported instance: %s,class: %s",instance,instance.getClass())); // NOI18N
}
}
项目:freecol
文件:ReportCompactColonyPanel.java
/**
* display the header area for the concise panel.
*
* @param market A {@code Market} to check goods arrears
* status with.
*/
private void conciseHeaders(Market market) {
reportPanel.add(new JSeparator(JSeparator.HORIZONTAL),growx");
reportPanel.add(newLabel("report.colony.name.header",stpld("report.colony.name")),"newline");
reportPanel.add(newLabel("report.colony.grow.header",stpld("report.colony.grow")));
reportPanel.add(newLabel("report.colony.explore.header",stpld("report.colony.explore")));
for (TileImprovementType ti : this.spec.getTileImprovementTypeList()) {
if (ti.isNatural()) continue;
String key = "report.colony.tile." + ti.getSuffix() + ".header";
reportPanel.add(newLabel(key,stpld(key)));
}
for (GoodsType gt : this.goodsTypes) {
ImageIcon icon = new ImageIcon(this.lib.getSmallIconImage(gt));
JLabel l = newLabel(null,icon,stpl("report.colony.production.header")
.addNamed("%goods%",gt));
l.setEnabled(market == null || market.getArrears(gt) <= 0);
reportPanel.add(l);
}
final UnitType type = spec.getDefaultUnitType(getMyPlayer());
ImageIcon colonistIcon
= new ImageIcon(this.lib.getTinyUnitimage(type,false));
reportPanel.add(newLabel(null,colonistIcon,stpld("report.colony.birth")));
reportPanel.add(newLabel("report.colony.making.header",stpld("report.colony.making")));
reportPanel.add(newLabel("report.colony.improve.header",stpld("report.colony.improve")));
reportPanel.add(new JSeparator(JSeparator.HORIZONTAL),growx");
}
项目:jaer
文件:MenuScroller.java
private void refreshMenu() {
if (menuItems != null && menuItems.length > 0) {
firstIndex = Math.max(topFixedCount,firstIndex);
firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount,firstIndex);
upItem.setEnabled(firstIndex > topFixedCount);
downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount);
menu.removeAll();
for (int i = 0; i < topFixedCount; i++) {
menu.add(menuItems[i]);
}
if (topFixedCount > 0) {
menu.add(new JSeparator());
}
menu.add(upItem);
for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
menu.add(menuItems[i]);
}
menu.add(downItem);
if (bottomFixedCount > 0) {
menu.add(new JSeparator());
}
for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
menu.add(menuItems[i]);
}
JComponent parent = (JComponent) upItem.getParent();
parent.revalidate();
parent.repaint();
}
}
项目:incubator-netbeans
文件:LanguageRegistrationProcessor.java
private static void registerCommentUncommentToolbarButtons(LayerBuilder b,String mimeType) {
File f = instanceFile(b,"Editors/" + mimeType + "/Toolbars/Default","Separator-before-comment",JSeparator.class,null); //NOI18N
f.position(30000);
f.write();
f = b.file("Editors/" + mimeType + "/Toolbars/Default/comment"); //NOI18N
f.position(30100);
f.write();
f = b.file("Editors/" + mimeType + "/Toolbars/Default/uncomment"); //NOI18N
f.position(30200);
f.write();
//
// // Toolbar
// if (linePrefix != null && linePrefix.length() > 0) {
// // Yes,found line comment prefix - register comment/uncomment toolbar buttons!
// Element toolbarFolder = mkdirs(mimeFolder,"Toolbars/Default"); // NOI18N
//
// item = createFile(doc,toolbarFolder,"Separator-before-comment.instance"); // NOI18N
// setFileAttribute(doc,item,"instanceClass",STRINGVALUE,"javax.swing.JSeparator"); // NOI18N
// setFileAttribute(doc,"position",INTVALUE,"30000"); // NOI18N
//
// item = createFile(doc,"comment"); // NOI18N
// setFileAttribute(doc,"30100"); // NOI18N
//
// item = createFile(doc,"uncomment"); // NOI18N
// setFileAttribute(doc,"30200"); // NOI18N
// }
}
private void addToBar(JComponent comp,int pos,boolean priority,boolean separator)
{
JPanel panel = getPanel(pos);
JSeparator sep = new JSeparator(SwingConstants.VERTICAL);
sep.setPreferredSize(new Dimension(3,image.getIconHeight()));
comp.setBorder(new EmptyBorder(0,5,5));
boolean sepFirst = false;
int loc = -1;
// This Could all be done nicer,but who cares if it works?
if( pos == SwingConstants.RIGHT )
{
if( priority )
{
sepFirst = true;
}
else
{
loc = 0;
}
}
else
{
if( priority )
{
loc = 0;
sepFirst = true;
}
}
if( sepFirst && separator )
{
panel.add(sep,loc);
}
panel.add(comp,loc);
if( !sepFirst && separator )
{
panel.add(sep,loc);
}
}
项目:incubator-netbeans
文件:Toolbar.java
/** Overridden to set focusable to false for any AbstractButton
* subclasses which are added */
@Override
protected void addImpl(Component c,Object constraints,int idx) {
//issue 39896,after opening dialog from toolbar button,focus
//remains on toolbar button. Does not create an accessibility issue -
//all standard toolbar buttons are also available via the keyboard
if (c instanceof AbstractButton) {
c.setFocusable(false);
((JComponent) c).setopaque(false);
if (isMetalLaF) {
//Metal/ocean resets borders,so fix it this way
((AbstractButton) c).setBorderPainted(false);
((AbstractButton) c).setopaque(false);
}
//This is active for GTK L&F. It should be fixed in JDK
//but it is not fixed in JDK 6.0.
if (!isMetalLaF) {
((AbstractButton) c).setMargin( emptyInsets );
}
if( null != label && c != label ) {
remove( label );
label = null;
}
} else if( c instanceof JToolBar.Separator ) {
JToolBar.Separator separator = (JToolBar.Separator)c;
if (getorientation() == VERTICAL) {
separator.setorientation(JSeparator.HORIZONTAL);
} else {
separator.setorientation(JSeparator.VERTICAL);
}
}
super.addImpl (c,constraints,idx);
}
项目:incubator-netbeans
文件:DataLoaderGetActionsTest.java
/**
* This test checks whether the JSeparator added from the configuration
* file is reflected in the resulting popup.
* The tests performs following steps:
* <OL><LI> Create an instance of ExtensibleNode with folder set to "test"
* <LI> No actions should be returned by getActions since the "test" folder
* is not there
* <LI> Create two actions in the testing folder separated by JSeparator
* <LI> getActions should return 3 elements - null element for the separator
* <LI> Popup is created from the actions array - the null element
* should be replaced by a JSeparator again
* </OL>
*/
public void testAddingSeparators() throws Exception {
Node en1 = node;
assertEquals("No actions at the start",en1.getActions(false).length);
FileObject test = root;
FileObject a1 = test.createData("1[org-openide-actions-PropertiesAction].instance");
FileObject sep = test.createData("2[javax-swing-JSeparator].instance");
FileObject a2 = test.createData("3[org-openide-actions-CutAction].instance");
Action[] actions = en1.getActions(false);
assertEquals("Actions array should contain 3 elements: "+Arrays.asList(actions),actions.length);
assertNull("separator should create null element in the array",actions[1]);
javax.swing.jpopupmenu jp = Utilities.actionsToPopup(actions,Lookups.singleton(en1));
assertEquals("Popup should contain 3 components",jp.getComponentCount());
assertTrue("Separator should be second",jp.getComponent(1) instanceof JSeparator);
}
项目:incubator-netbeans
文件:ToolbarContainer.java
public Toolbaraqua() {
super( new BorderLayout() );
JSeparator sep = new JToolBar.Separator();
sep.setorientation(JSeparator.VERTICAL);
sep.setForeground(UIManager.getColor("NbSplitPane.background")); //NOI18N
add( sep,BorderLayout.CENTER );
dim = new Dimension (grip_WIDTH,grip_WIDTH);
max = new Dimension (grip_WIDTH,Integer.MAX_VALUE);
setBorder(BorderFactory.createEmptyBorder(4,0));
}
项目:incubator-netbeans
文件:Terminal.java
private void addMenuItem(jpopupmenu menu,Object o) {
if (o instanceof JSeparator) {
menu.add((JSeparator) o);
} else if (o instanceof Action) {
Action a = (Action) o;
if (isBooleanStateAction(a)) {
JCheckBoxMenuItem item = new JCheckBoxMenuItem(a);
item.setSelected((Boolean) a.getValue(BOOLEAN_STATE_ENABLED_KEY));
menu.add(item);
} else {
menu.add((Action) o);
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。