@Override public void setMenus(JMenuBar jMenuBar1, JToolBar jToolbar1, StatusBar jStatusBar1) { jToolbar1.add(buttonNouAnunci); jToolbar1.add(buttonConfigure); jToolbar1.revalidate(); }
public void addAction(JXFrame frame, Action action) { JToolBar toolbar = frame.getRootPaneExt().getToolBar(); if (toolbar != null) { AbstractButton button = toolbar.add(action); button.setFocusable(false); } }
private void initView() { AutomatonEditorPanel<T, S> panel = getEditorPanel(); T auto = panel.getAutomaton(); initTable(myAlg.getConvertedGrammar(), new UndoKeeper()); panel.setTool(createArrowTool(panel, auto)); MagnifiableScrollPane scroll = new MagnifiableScrollPane(myTable); scroll.setMinimumSize(myTable.getMinimumSize()); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel, scroll); Dimension size = getPreferredSize(), scrollSize = myTable.getMinimumSize(); double width = size.width + scrollSize.width; split.setPreferredSize(new Dimension((int) width, size.height)); double ratio = size.width / width; split.setDividerLocation(ratio); split.setResizeWeight(ratio); SizeSlider slider = new SizeSlider(scroll); JToolBar toolbar = initToolbar(); add(split, BorderLayout.CENTER); add(slider, BorderLayout.SOUTH); add(toolbar, BorderLayout.NORTH); slider.distributeMagnification(); size = new Dimension( (int) width, size.height + slider.getPreferredSize().height + toolbar.getPreferredSize().height); setPreferredSize(size); }
/** Creates the tool palette. */ protected JToolBar createToolPalette() { JToolBar palette = new JToolBar(); palette.setBackground(Color.lightGray); // use standard FlowLayout for JToolBar // palette.setLayout(new PaletteLayout(2,new Point(2,2))); return palette; }
/** Sets up the components in this frame. */ private void setupComponents() { myDrawPanel.addMouseListener(new DrawPanelMouseListener()); myFrame.add(myDrawPanel, BorderLayout.CENTER); myFrame.setJMenuBar(myMenuBar); myFrame.setIconImage(new ImageIcon("./images//paint.png").getImage()); createFileMenu(); createOptionMenu(); final Action[] actions = { new PencilAction(myDrawPanel, new PencilTool()), new LineAction(myDrawPanel, new LineTool()), new RectangleAction(myDrawPanel, new RectangleTool()), new EllipseAction(myDrawPanel, new EllipseTool()) }; myDrawPanel.addPropertyChangeListener(this); final JMenu toolMenu = new JMenu("Tools"); toolMenu.setMnemonic(KeyEvent.VK_T); final JToolBar toolBar = new JToolBar(); for (final Action current : actions) { toolMenu.add(createToolMenuButton(current)); toolBar.add(createToolBarButton(current)); myDrawPanel.setTool(new PencilTool()); } myMenuBar.add(toolMenu); createHelpMenu(); createColorMenuItem(); myFrame.add(toolBar, BorderLayout.SOUTH); }
private JComponent createPanel() { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JToolBar bar = new JToolBar(); bar.add( new AbstractAction("Force Rerouting") { public void actionPerformed(ActionEvent e) { connection.reroute(); validate(); } }); bar.addSeparator(); bar.add( new AbstractAction("Reset routing policy to always-route") { public void actionPerformed(ActionEvent e) { connection.setRoutingPolicy(ConnectionWidget.RoutingPolicy.ALWAYS_ROUTE); validate(); } }); panel.add(bar, BorderLayout.NORTH); panel.add(createView(), BorderLayout.CENTER); return panel; }
/** Returns the tool bar for the panel. */ protected JComponent getToolBar() { JToolBar tbarDir = new JToolBar(); JButton btnNew = new JButton(); // m_btnSave = new JButton("Save File"); // i118n // btnNew.setText("New Label"); btnNew.setText(Util.getAdmLabel("_adm_New_Label")); btnNew.setActionCommand("new"); // m_btnSave.setActionCommand("save"); ActionListener alTool = new ActionListener() { public void actionPerformed(ActionEvent e) { doAction(e); } }; btnNew.addActionListener(alTool); // m_btnSave.addActionListener(alTool); tbarDir.setFloatable(false); tbarDir.add(btnNew); /*tbarDir.add(new JLabel(" ")); tbarDir.add(m_btnSave);*/ return tbarDir; }
private void initView() { this.setLayout(new BorderLayout()); JToolBar toolBar = new JToolBar(); ActionManager actionManager = Application.getInstance().getActionManager(); toolBar.add(actionManager.getAction(CreateAttributeAction.class).buildButton()); add(toolBar, BorderLayout.NORTH); className = new TextAdapter(new JTextField()) { @Override protected void updateModel(String text) { setClassName(text); } }; FormLayout layout = new FormLayout("right:50dlu, 3dlu, fill:150dlu, 3dlu, fill:100", ""); DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.setDefaultDialogBorder(); builder.append("Class Name:", className.getComponent(), 3); add(builder.getPanel(), BorderLayout.CENTER); }
@Override public void run() { ArrayList<ArrayList<Integer>> paths = new ArrayList<ArrayList<Integer>>(); buttonOpen = new JButton("Open file"); buttonOpen.addActionListener(new openFile()); openFileL = new JLabel("Open file..."); frame = new JFrame("SRPP PROJECT"); frame.setPreferredSize(new Dimension(510, 590)); frame.setResizable(false); JToolBar bar1 = new JToolBar(); bar1.setFloatable(false); bar1.add(buttonOpen); bar1.add(openFileL); bar1.setMargin(new Insets(5, 5, 5, 5)); frame.add(bar1, BorderLayout.NORTH); drawPanel = new DrawPanel(cities, paths, magazine); frame.add(drawPanel, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
private void init() { this.setLayout(new BorderLayout()); JToolBar toolBar = new JToolBar("Java 截图"); // 保存按钮 JButton saveButton = new JButton(new ImageIcon("images/save.gif")); saveButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { parent.saveImage(); } catch (IOException e1) { e1.printStackTrace(); } } }); toolBar.add(saveButton); // 关闭按钮 JButton closeButton = new JButton(new ImageIcon("images/close.gif")); closeButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); toolBar.add(closeButton); this.add(toolBar, BorderLayout.NORTH); }
/** * Creates the Viewpoint Toolbar in the specified orientation. * * @param orientation orientation of the toolbar (JToolBar.VERTICAL or JToolBar.HORIZONTAL) * @return the toolbar component */ public Component doMakeViewPointToolBar(int orientation) { JToolBar toolbar = getViewpointControl().getToolBar(getToolbarsFloatable()); toolbar.setOrientation(orientation); return GuiUtils.top(toolbar); }
protected JToolBar createToolBar() { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); toolBar.setOpaque(false); addActionsTo(toolBar); return toolBar; }
/** * Creates toolbars for the application. This class always returns an empty list. Subclasses may * return other values. */ @Override public List<JToolBar> createToolBars(Application a, @Nullable View pr) { ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); DrawView p = (DrawView) pr; DrawingEditor editor; if (p == null) { editor = getSharedEditor(); } else { editor = p.getEditor(); } LinkedList<JToolBar> list = new LinkedList<JToolBar>(); JToolBar tb; tb = new JToolBar(); addCreationButtonsTo(tb, editor); tb.setName(labels.getString("window.drawToolBar.title")); list.add(tb); tb = new JToolBar(); ButtonFactory.addAttributesButtonsTo(tb, editor); tb.setName(labels.getString("window.attributesToolBar.title")); list.add(tb); tb = new JToolBar(); ButtonFactory.addAlignmentButtonsTo(tb, editor); tb.setName(labels.getString("window.alignmentToolBar.title")); list.add(tb); return list; }
/** * Fill the specified tool bar with the elements that have the given URI as their parent. * * <p>Existing elements on the tool bar will be removed. * * @param toolbar The {@link JToolBar} to update * @param id The {@link URI} of the tool bar */ protected void populateToolBar(JToolBar toolbar, URI id) { toolbar.removeAll(); MenuComponent toolbarDef = uriToMenuElement.get(id); if (toolbarDef == null) throw new IllegalArgumentException("Unknown toolBar " + id); if (!toolbarDef.getType().equals(MenuType.toolBar)) throw new IllegalArgumentException( "Element " + id + " is not a toolBar, but a " + toolbarDef.getType()); if (toolbarDef.getAction() != null) { String name = (String) toolbarDef.getAction().getValue(Action.NAME); toolbar.setName(name); } else toolbar.setName(""); MenuOptions menuOptions = new MenuOptions(); menuOptions.setToolbar(true); for (Component component : makeComponents(id, menuOptions)) { if (component == null) { toolbar.addSeparator(); continue; } if (component instanceof JButton) { JButton toolbarButton = (JButton) component; toolbarButton.putClientProperty("hideActionText", true); } toolbar.add(component); } }
/** * Returns the location where to dock the given {@code JToolBar}, at the given constraint * position. The constraint position must be one of the constants {@code BorderLayout.NORTH * NORTH}, {@code BorderLayout.EAST EAST}, {@code BorderLayout.SOUTH SOUTH}, or {@code * BorderLayout.WEST WEST}. * * <p><b>Note:</b> This method is accessed in the current executing thread. Such thread may or may * not be the event dispatch thread (EDT.) Client code must call this method from the EDT. * * @param toolBar the target {@code JToolBar}. * @param dock the container where to dock the {@code JToolBar} to. * @param constraint the constraint position. * @return the location where to dock the given {@code JToolBar}. * @throws IllegalArgumentException if the constraint has an invalid value. */ @RunsInCurrentThread public @Nonnull Point dockLocation( @Nonnull JToolBar toolBar, @Nonnull Container dock, @Nonnull String constraint) { checkValid(constraint); Insets insets = dock.getInsets(); // BasicToolBarUI prioritizes location N/E/W/S by proximity to the respective border. Close to // top border is N, even // if close to the left or right border. int offset = isHorizontal(toolBar) ? toolBar.getHeight() : toolBar.getWidth(); Dimension dockSize = dock.getSize(); if (NORTH.equals(constraint)) { return new Point(dockSize.width / 2, insets.top); } if (EAST.equals(constraint)) { return new Point( dockSize.width - insets.right - 1, verticalDockingYCoordinate(dockSize.height, insets, offset)); } if (WEST.equals(constraint)) { return new Point(insets.left, verticalDockingYCoordinate(dockSize.height, insets, offset)); } int x = dockSize.width / 2; // Make sure we don't get mistaken for EAST or WEST if (x < insets.left + offset) { x = insets.left + offset; } else if (x > dockSize.width - insets.right - offset - 1) { x = dockSize.width - insets.right - offset - 1; } return new Point(x, dockSize.height - insets.bottom - 1); }
/** Construct a ToDo tab for the property panel. */ public TabToDo() { super("tab.todo-item"); setIcon(new LeftArrowIcon()); String position = Configuration.getString(Configuration.makeKey("layout", "tabtodo")); setOrientation( ((position.equals("West") || position.equals("East")) ? Vertical.getInstance() : Horizontal.getInstance())); setLayout(new BorderLayout()); Object[] actions = {actionNewToDoItem, actionResolve, actionSnooze}; ToolBarFactory factory = new ToolBarFactory(actions); factory.setRollover(true); factory.setFloatable(false); factory.setOrientation(SwingConstants.VERTICAL); JToolBar toolBar = factory.createToolBar(); toolBar.setName(getTitle()); add(toolBar, BorderLayout.WEST); splitPane = new BorderSplitPane(); add(splitPane, BorderLayout.CENTER); setTarget(null); addComponentListener(this); // TODO: Register listener for target ToDo item changes // and for new showStep() requests }
public static void init( JToolBar comp, Thing thing, Container parent, ActionContext actionContext) { JComponentCreator.init(comp, thing, parent, actionContext); Boolean borderPainted = JavaCreator.createBoolean(thing, "borderPainted"); if (borderPainted != null) { comp.setBorderPainted(borderPainted); } Boolean floatable = JavaCreator.createBoolean(thing, "floatable"); if (floatable != null) { comp.setFloatable(floatable); } Insets margin = AwtCreator.createInsets(thing, "margin", actionContext); if (margin != null) { comp.setMargin(margin); } Integer orientation = null; String v = thing.getString("orientation"); if ("HORIZONTAL".equals(v)) { orientation = JToolBar.HORIZONTAL; } else if ("VERTICAL".equals(v)) { orientation = JToolBar.VERTICAL; } if (orientation != null) { comp.setOrientation(orientation); } Boolean rollover = JavaCreator.createBoolean(thing, "rollover"); if (rollover != null) { comp.setRollover(rollover); } }
/** Builds and answers the tool bar. */ private Component buildToolBar() { JToolBar toolBar = new JToolBar(); toolBar.putClientProperty(Options.HEADER_STYLE_KEY, Boolean.TRUE); toolBar.add(createCenteredLabel("Tool Bar")); return toolBar; }
/** * Updates the <code>Toolbar</code> represented by this folder. * * @param cookies array of instance cookies for the folder * @return the updated <code>ToolbarPool</code> representee */ protected Object createInstance(InstanceCookie[] cookies) throws java.io.IOException, ClassNotFoundException { // refresh the toolbar's content getToolbar().removeAll(); for (int i = 0; i < cookies.length; i++) { try { Object obj = cookies[i].instanceCreate(); if (obj instanceof Presenter.Toolbar) { obj = ((Presenter.Toolbar) obj).getToolbarPresenter(); } if (obj instanceof Component) { Component comp = (Component) obj; getToolbar().add(comp); } } catch (java.io.IOException ex) { } catch (ClassNotFoundException ex) { } } // invalidate the toolbar and its parent toolbar.invalidate(); java.awt.Container parent = toolbar.getParent(); if (parent != null) { parent.validate(); parent.repaint(); } return toolbar; }
public TestFrame() { super("Home Plan Component Test"); this.home = new Home(); this.home.getCompass().setVisible(false); UserPreferences preferences = new DefaultUserPreferences(); ViewFactory viewFactory = new SwingViewFactory(); this.homeController = new HomeController(home, preferences, viewFactory); JComponent homeView = (JComponent) this.homeController.getView(); ActionMap actions = homeView.getActionMap(); // Create buttons from HomePane actions map this.selectButton = new JToggleButton(actions.get(HomePane.ActionType.SELECT)); this.createWallsButton = new JToggleButton(actions.get(HomePane.ActionType.CREATE_WALLS)); this.createDimensionsButton = new JToggleButton(actions.get(HomePane.ActionType.CREATE_DIMENSION_LINES)); ButtonGroup group = new ButtonGroup(); group.add(this.selectButton); group.add(this.createWallsButton); group.add(this.createDimensionsButton); this.addButton = new JButton(actions.get(HomePane.ActionType.ADD_HOME_FURNITURE)); this.undoButton = new JButton(actions.get(HomePane.ActionType.UNDO)); this.redoButton = new JButton(actions.get(HomePane.ActionType.REDO)); // Put them it a tool bar JToolBar toolBar = new JToolBar(); toolBar.add(this.selectButton); toolBar.add(this.createWallsButton); toolBar.add(this.addButton); toolBar.add(this.undoButton); toolBar.add(this.redoButton); // Display the tool bar and main view in this pane add(toolBar, BorderLayout.NORTH); add(homeView, BorderLayout.CENTER); pack(); }
protected void addStyleButtons() { borderBtn = new JButton(STLConstants.K0530_SHOW_BORDER.getValue(), UIImages.HIDE_BORDER.getImageIcon()); borderBtn.setOpaque(false); borderBtn.setFocusable(false); borderBtn.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean isSelected = borderBtn.getIcon() != UIImages.SHOW_BORDER.getImageIcon(); setShowBorder(isSelected); if (listener != null) { listener.onShowBorder(isSelected); } } }); toolBar.add(borderBtn); alternationBtn = new JButton(STLConstants.K0533_UNI_ROWS.getValue(), UIImages.UNI_ROWS.getImageIcon()); alternationBtn.setOpaque(false); alternationBtn.setFocusable(false); alternationBtn.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean isSelected = alternationBtn.getIcon() != UIImages.ALT_ROWS.getImageIcon(); setShowAlternation(isSelected); if (listener != null) { listener.onShowAlternation(isSelected); } } }); toolBar.add(alternationBtn); }
private JToolBar createToolBar() { final JToolBar toolBar = new JToolBar(); this.addPhenotypeButton = new JButton( new AbstractAction( null, new ImageIcon( this.getClass().getResource("/org/phenoscape/view/images/list-add.png"))) { @Override public void actionPerformed(ActionEvent e) { addPhenotype(); } }); this.addPhenotypeButton.setToolTipText("Add Phenotype"); toolBar.add(this.addPhenotypeButton); this.deletePhenotypeButton = new JButton( new AbstractAction( null, new ImageIcon( this.getClass().getResource("/org/phenoscape/view/images/list-remove.png"))) { @Override public void actionPerformed(ActionEvent e) { deleteSelectedPhenotype(); } }); this.deletePhenotypeButton.setToolTipText("Delete Phenotype"); toolBar.add(this.deletePhenotypeButton); toolBar.setFloatable(false); return toolBar; }
private JToolBar initToolbar() { JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false); fRun = createRunButton(); toolbar.add(fRun); return toolbar; }
public ScrolledTextPane() { mainPanel = new JPanel(new BorderLayout()); textPane = new JTextPane(); scrollPane = new JScrollPane( textPane, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); setPreferredScrollableSize(new Dimension(350, 550)); mainPanel.add(BorderLayout.CENTER, scrollPane); southToolBar = new JToolBar(); mainPanel.add(BorderLayout.SOUTH, southToolBar); JButton clearButton = new JButton("clear"); JButton copyToClipboardButton = new JButton("copy"); southToolBar.add(clearButton); southToolBar.add(copyToClipboardButton); clearButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { clearText(); } }); copyToClipboardButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { copyToClipboard(); } }); }
private void flipSeparators(Component c, int orientn) { if (c != null && c instanceof JToolBar && UIManager.getLookAndFeel().getName().toLowerCase().indexOf("windows") != -1) { JToolBar jtb = (JToolBar) c; Component comps[] = jtb.getComponents(); if (comps != null && comps.length > 0) { for (int i = 0; i < comps.length; i++) { try { Component component = comps[i]; if (component != null) { if (component instanceof JSeparator) { jtb.remove(component); JSeparator separ = new JSeparator(); if (orientn == SwingConstants.VERTICAL) { separ.setOrientation(SwingConstants.VERTICAL); separ.setMinimumSize(new Dimension(2, 6)); separ.setPreferredSize(new Dimension(2, 6)); separ.setMaximumSize(new Dimension(2, 100)); } else { separ.setOrientation(SwingConstants.HORIZONTAL); separ.setMinimumSize(new Dimension(6, 2)); separ.setPreferredSize(new Dimension(6, 2)); separ.setMaximumSize(new Dimension(100, 2)); } jtb.add(separ, i); } } } catch (Exception e) { e.printStackTrace(); } } } } }
/** * Habilita un componente de la barra de herramientas. * * @param posicion posición del elemento de la barra de herramientas que se quiere * habilitar.Entero del 0 al número de elementos. */ public static void habilitarComponenteBarraHerramientas(int posicion) { if (posicion < toolBar.getComponentCount()) { toolBar.getComponentAtIndex(posicion).setEnabled(true); toolBar.repaint(); } else { System.out.println("Te has salido del rango de componentes de la barra de herramientas"); } } // habilitarComponeneteBarraHerramientas
private MyWindow() { super(JToolBarFixture_constructor_withRobotAndName_Test.class); toolBar.setName("toolBar"); setLayout(new BorderLayout()); add(toolBar, NORTH); toolBar.add(new JLabel("Hello")); setPreferredSize(new Dimension(100, 50)); }
@Override public void addSeparator() { super.addSeparator(new Dimension(5, 1)); JSeparator separator = new JSeparator(SwingConstants.VERTICAL); separator.setMaximumSize(new Dimension(10, 40)); add(separator); super.addSeparator(new Dimension(5, 1)); }
/** Process all loaded images. */ @Override protected void process(List<ThumbnailAction> chunks) { for (ThumbnailAction thumbAction : chunks) { JButton thumbButton = new JButton(thumbAction); // add the new button BEFORE the last glue // this centers the buttons in the toolbar buttonBar.add(thumbButton, buttonBar.getComponentCount() - 1); } }
private void buildGui() { setLayout(new BorderLayout()); JToolBar jtb = new JToolBar(); jtb.add(start); jtb.add(login); this.add(jtb, BorderLayout.NORTH); this.add(new JPanel(), BorderLayout.CENTER); this.add(status, BorderLayout.SOUTH); }