/** 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; }
protected JToolBar createToolBar() { JToolBar jtoolbar = new JToolBar(); jtoolbar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // --------------------------------------- JButton jbuttonClear = new JButton("Clear SQL Statement"); jbuttonClear.setToolTipText("Clear SQL Statement"); jbuttonClear.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionevent) { clear(); } }); // --------------------------------------- JButton jbuttonExecute = new JButton("Execute SQL Statement"); jbuttonExecute.setToolTipText("Execute SQL Statement"); jbuttonExecute.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionevent) { execute(); } }); jtoolbar.addSeparator(); jtoolbar.add(jbuttonClear); jtoolbar.addSeparator(); jtoolbar.add(jbuttonExecute); jtoolbar.addSeparator(); jbuttonClear.setAlignmentY(0.5F); jbuttonClear.setAlignmentX(0.5F); jbuttonExecute.setAlignmentY(0.5F); jbuttonExecute.setAlignmentX(0.5F); return jtoolbar; }
/** * Creates the menu bar * * @return Description of the Return Value */ public JToolBar createToolBar() { // Create the tool bar toolBar = new JToolBar(); toolBar.putClientProperty("jgoodies.headerStyle", "Both"); toolBar.setRollover(true); toolBar.setFloatable(false); for (int i = 0; i < beans.length; i++) { Icon icon; JButton button; try { final JComponent bean = beans[i]; URL iconURL = bean.getClass().getResource("images/" + bean.getName() + "Color16.gif"); icon = new ImageIcon(iconURL); button = new JButton(icon); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { installBean(bean); } }; button.addActionListener(actionListener); } catch (Exception e) { System.out.println("JCalendarDemo.createToolBar(): " + e); button = new JButton(beans[i].getName()); } button.setFocusPainted(false); toolBar.add(button); } return toolBar; }
/** * Creates a new PluginManagerPane object. * * @param manager the plugin mananager * @param context context */ public PluginManagerPane( PluginManager manager, PluginHostContext context, boolean showBuiltInPlugins) { super(new BorderLayout()); // Initialise this.context = context; this.showBuiltInPlugins = showBuiltInPlugins; this.manager = manager; // Connection state JPanel sp = new JPanel(new BorderLayout()); sp.setOpaque(false); sp.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Plugin updates"), BorderFactory.createEmptyBorder(4, 4, 4, 4))); status = new JLabel("Click on Refresh to check for new plugins and updates", JLabel.LEFT); status.setIcon(IDLE_ICON); sp.add(status, BorderLayout.CENTER); refresh = new JButton("Refresh"); refresh.setMnemonic('r'); refresh.addActionListener(this); sp.add(refresh, BorderLayout.EAST); // Create the toolbar JToolBar toolBar = new JToolBar("Plugin manager tools"); toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); toolBar.setBorder(null); toolBar.setFloatable(false); toolBar.add(new ToolButton(installAction = new InstallAction(), false)); toolBar.add(new ToolButton(updateAction = new UpdateAction(), false)); toolBar.add(new ToolButton(removeAction = new RemoveAction(), false)); toolBar.add(new ToolButton(configureAction = new ConfigureAction(), false)); // Create the text area table = new PluginManagerTable(model = new PluginManagerTableModel()) { public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, 180); } }; table.setBorder(null); table.getSelectionModel().addListSelectionListener(this); // Information panel JPanel ip = new JPanel(new BorderLayout()); ip.setOpaque(false); // ip.setBorder(BorderFactory.createTitledBorder("Information")); ip.add(new JLabel(INFORMATION_ICON), BorderLayout.WEST); JPanel tp = new JPanel(new BorderLayout()) { public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, 72); } }; tp.setOpaque(false); tp.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); url = new JLabel(" ", JLabel.CENTER); url.setFont(url.getFont().deriveFont(Font.BOLD).deriveFont(12f)); url.setForeground(Color.blue); url.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); url.setBorder(BorderFactory.createEmptyBorder(4, 0, 4, 0)); url.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent evt) { try { PluginManagerPane.this.context.openURL(new URL(url.getText())); } catch (Exception e) { } } }); tp.add(url, BorderLayout.SOUTH); info = new JTextArea(" ") { public Dimension getPreferredSize() { return new Dimension(400, 130); } }; info.setOpaque(false); info.setWrapStyleWord(true); info.setLineWrap(true); info.setEditable(false); info.setFont(UIManager.getFont("Label.font")); tp.add(info, BorderLayout.CENTER); ip.add(tp, BorderLayout.CENTER); // Build this add(sp, BorderLayout.NORTH); add( new ToolBarTablePane(toolBar, table) { public Dimension getPreferredSize() { return new Dimension(480, 260); } }, BorderLayout.CENTER); add(ip, BorderLayout.SOUTH); // Create the progress dialog JPanel progressPanel = new JPanel(new BorderLayout()); progressPanel.setOpaque(false); Window parentWindow = (Window) SwingUtilities.getAncestorOfClass(Window.class, this); if (parentWindow instanceof JFrame) progressDialog = new JDialog((JFrame) parentWindow, "Downloading", true); else if (parentWindow instanceof JDialog) progressDialog = new JDialog((JDialog) parentWindow, "Downloading", true); else progressDialog = new JDialog((JFrame) null, "Downloading", true); JPanel progressDetailPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; jGridBagAdd(progressDetailPanel, status1Text = new JLabel(), gbc, GridBagConstraints.REMAINDER); jGridBagAdd(progressDetailPanel, status2Text = new JLabel(), gbc, GridBagConstraints.REMAINDER); jGridBagAdd( progressDetailPanel, progress = new JProgressBar(), gbc, GridBagConstraints.REMAINDER); gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.NONE; gbc.weighty = 1.0; jGridBagAdd( progressDetailPanel, cancelDownload = new JButton("Cancel"), gbc, GridBagConstraints.REMAINDER); cancelDownload.addActionListener(this); cancelDownload.setMnemonic('c'); progressPanel.add(statusIcon = new JLabel(), BorderLayout.WEST); progressPanel.add(progressDetailPanel, BorderLayout.CENTER); progressDialog.getContentPane().setLayout(new GridLayout(1, 1)); progressDialog.getContentPane().add(progressPanel); progressDialog.setSize(220, 160); progressDialog.setResizable(false); centerComponent(progressDialog); // Set the intially available actions setAvailableActions(); }
/** Construct the TV object - that is, the main GUI for the program */ public TV(JFrame f, TD mod) { super(); frm = f; theTD = mod; JButton b; // Build the GUI toolBar = new JToolBar(); toolBar.setFloatable(false); toolBar.getAccessibleContext().setAccessibleName("File Toolbar"); toolBar.addSeparator(); b = addTool(toolBar, "Cut"); b = addTool(toolBar, "Copy"); b = addTool(toolBar, "Paste"); toolBar.addSeparator(); toolBar.putClientProperty("JToolBar.isRollover", Boolean.FALSE); // The Slider numSlider = new JSlider(JSlider.HORIZONTAL, 1, 40, 1); numSlider.setPaintTicks(true); numSlider.setPaintLabels(false); numSlider.setMajorTickSpacing(10); numSlider.setMinorTickSpacing(2); numSlider.setExtent(1); numSlider.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent ce) { // System.out.println("CHANGE: " + ce); setQNumber(((JSlider) (ce.getSource())).getValue()); } }); numSlider.setToolTipText("Slide to select question by number"); toolBar.add(numSlider); // The Question# textfield toolBar.add(numTF = new JTextField("01")); numTF.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String num = ((JTextField) e.getSource()).getText(); int n = Integer.parseInt(num.trim()); setQNumber(n); } }); numTF.setToolTipText("Type number to select question by number"); // The First Button b = addTool(toolBar, "First"); b.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setQNumber(1); } }); // The Previous Button b = addTool(toolBar, "Previous"); b.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (getQNumber() <= 1) return; setQNumber(getQNumber() - 1); } }); // The Next Button b = addTool(toolBar, "Next"); b.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (getQNumber() >= getNumQuestions()) return; setQNumber(getQNumber() + 1); } }); // The "Last" Button b = addTool(toolBar, "Last"); b.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setQNumber(getNumQuestions()); } }); add(BorderLayout.NORTH, toolBar); // Rest is a panel to hold the questions, one at a time. questionsPanel = new JPanel(); questionsPanel.setLayout(myCardLayout = new CardLayout()); add(BorderLayout.SOUTH, questionsPanel); fc = new FileDialog(frm); fc.setFilenameFilter( new FilenameFilter() { public boolean accept(File ff, String fname) { // System.out.println("accept("+fname+")"); // XXX TODO list of extentions, from properties. return fname.endsWith(".xam"); } }); TV.centre(fc); }
private void initUI() { setLayout(new BorderLayout()); JToolBar toolBar = new JToolBar(); toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); toolBar.setBorderPainted(false); toolBar.add( new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("add"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("parameter.add"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { add(); } }); toolBar.add( new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("add_par"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("parameter.add.from.report"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { addFromReport(); } }); toolBar.add( new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("parameter_clone"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("parameter.add.clone"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { cloneParameter(); } }); toolBar.add( new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("edit"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("parameter.edit"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { modify(); } }); toolBar.add( new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("delete"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("parameter.delete"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { delete(); } }); toolBar.add( new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("parameter_up"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("parameter.up"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { up(); } }); toolBar.add( new AbstractAction() { public Object getValue(String key) { if (AbstractAction.SMALL_ICON.equals(key)) { return ImageUtil.getImageIcon("parameter_down"); } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) { return I18NSupport.getString("parameter.down"); } return super.getValue(key); } public void actionPerformed(ActionEvent e) { down(); } }); // SwingUtil.registerButtonsForFocus(buttonsPanel); add(toolBar, BorderLayout.NORTH); createTable(); table .getColumnModel() .getColumn(1) .setCellRenderer( new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column); String tmp = (String) value; tmp = tmp.substring(tmp.lastIndexOf('.') + 1); /* if ("Object".equals(tmp)) { tmp = "Any"; } */ setText(tmp); return this; } }); table.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { if (event.getClickCount() == 2) { modify(); } } }); table.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent event) { int keyCode = event.getKeyCode(); if (keyCode == KeyEvent.VK_ENTER) { modify(); // don't let anyone else handle the event event.consume(); } else if (keyCode == KeyEvent.VK_INSERT) { add(); // don't let anyone else handle the event event.consume(); } else if (keyCode == KeyEvent.VK_DELETE) { delete(); // don't let anyone else handle the event event.consume(); } } }); add(new JScrollPane(table), BorderLayout.CENTER); table.setPreferredScrollableViewportSize(new Dimension(250, 200)); }