List of usage examples for javax.swing JFrame setIconImages
public synchronized void setIconImages(java.util.List<? extends Image> icons)
From source file:Main.java
public static void main(String[] args) throws Exception { URL url16 = new URL("http://www.java2s.com/style/download.png"); URL url32 = new URL("http://www.java2s.com/style/download.png"); final List<Image> icons = new ArrayList<Image>(); icons.add(ImageIO.read(url16)); icons.add(ImageIO.read(url32)); JFrame f = new JFrame(); f.setIconImages(icons); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(200, 100);//from w w w .j a v a 2s .co m f.setVisible(true); }
From source file:lcmc.LCMC.java
/** The main function for starting the application. */ public static void main(final String[] args) { Tools.init();// w w w .j a va 2 s .c om final JFrame mainFrame = new JFrame(Tools.getString("DrbdMC.Title") + " " + Tools.getRelease()); final List<Image> il = new ArrayList<Image>(); for (final String iconS : new String[] { "LCMC.AppIcon32", "LCMC.AppIcon48", "LCMC.AppIcon64", "LCMC.AppIcon128", "LCMC.AppIcon256" }) { il.add(Tools.createImageIcon(Tools.getDefault(iconS)).getImage()); } mainFrame.setIconImages(il); final String autoArgs = initApp(args); mainFrame.setGlassPane(getMainGlassPane()); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.addWindowListener(new ExitListener()); mainFrame.setJMenuBar(getMenuBar()); mainFrame.setContentPane(getMainPanel()); javax.swing.SwingUtilities.invokeLater(new Runnable() { @Override public void run() { createAndShowGUI((Container) mainFrame); } }); if (autoArgs != null) { Tools.parseAutoArgs(autoArgs); } //final Thread t = new Thread(new Runnable() { // public void run() { // drbd.utilities.RoboTest.startMover(600000, true); // } //}); //t.start(); }
From source file:at.gv.egiz.bku.local.stal.LocalIdentityLinkSTALFactory.java
@Override public STAL createSTAL() { final LocalBKUWorker stal; //http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html // use undecorated JFrame instead of JWindow, // which creates an invisible owning frame and therefore cannot getFocusInWindow() JFrame dialog = new JFrame("Brgerkarte"); log.debug("AlwaysOnTop supported: {}.", dialog.isAlwaysOnTopSupported()); // [#439] make mocca dialog alwaysOnTop dialog.setAlwaysOnTop(true);// ww w . j a v a 2s. c o m dialog.setIconImages(BKUIcons.icons); // dialog.setUndecorated(true); // dialog.getRootPane().setWindowDecorationStyle(JRootPane.NONE); if (locale != null) { dialog.setLocale(locale); } LocalHelpListener helpListener = null; if (helpURL != null) { helpListener = new LocalHelpListener(helpURL, locale); } else { log.warn("No HELP URL configured, help system disabled."); } IdentityLinkGUIFacade gui = new IdentityLinkGUI(dialog.getContentPane(), dialog.getLocale(), null, new ResourceFontLoader(), helpListener); BKUGUIFacade proxy = (BKUGUIFacade) GUIProxy.newInstance(gui, dialog, new Class[] { IdentityLinkGUIFacade.class }); stal = new LocalBKUWorker(proxy, dialog); dialog.setPreferredSize(PREFERRED_SIZE); dialog.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = dialog.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } dialog.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); return stal; }
From source file:org.keyboardplaying.xtt.ui.UIController.java
private Window makeWindow(String titleKey, String iconKey, Container content) { /* The basics. */ JFrame window = new I14edJFrame(i18n, titleKey); window.setIconImages(images.getImages(iconKey)); /* Make sure thread is ended when window is closed. */ window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); /* Add content and adapt size to fit the content. */ window.setContentPane(content);//from w w w. j a v a 2 s . c o m window.pack(); // Center on screen window.setLocationRelativeTo(null); return window; }
From source file:at.gv.egiz.bku.local.stal.LocalGetCertificateSTALFactory.java
@Override public STAL createSTAL() { final LocalBKUWorker stal; //http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html // use undecorated JFrame instead of JWindow, // which creates an invisible owning frame and therefore cannot getFocusInWindow() JFrame dialog = new JFrame("Brgerkarte"); log.debug("AlwaysOnTop supported: {}.", dialog.isAlwaysOnTopSupported()); // [#439] make mocca dialog alwaysOnTop dialog.setAlwaysOnTop(true);// w w w. jav a 2s . c o m dialog.setIconImages(BKUIcons.icons); // dialog.setUndecorated(true); // dialog.getRootPane().setWindowDecorationStyle(JRootPane.NONE); if (locale != null) { dialog.setLocale(locale); } LocalHelpListener helpListener = null; if (helpURL != null) { helpListener = new LocalHelpListener(helpURL, locale); } else { log.warn("No HELP URL configured, help system disabled."); } GetCertificateGUIFacade gui = new GetCertificateGUI(dialog.getContentPane(), dialog.getLocale(), null, new ResourceFontLoader(), helpListener); BKUGUIFacade proxy = (BKUGUIFacade) GUIProxy.newInstance(gui, dialog, new Class[] { GetCertificateGUIFacade.class, }); stal = new LocalBKUWorker(proxy, dialog); dialog.setPreferredSize(PREFERRED_SIZE); dialog.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = dialog.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } dialog.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); return stal; }
From source file:at.gv.egiz.bku.local.stal.LocalGetHardwareInfoSTALFactory.java
@Override public STAL createSTAL() { final LocalBKUWorker stal; //http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html // use undecorated JFrame instead of JWindow, // which creates an invisible owning frame and therefore cannot getFocusInWindow() JFrame dialog = new JFrame("Brgerkarte"); log.debug("AlwaysOnTop supported: {}.", dialog.isAlwaysOnTopSupported()); // [#439] make mocca dialog alwaysOnTop dialog.setAlwaysOnTop(true);//from w w w. j a v a 2 s. c o m dialog.setIconImages(BKUIcons.icons); // dialog.setUndecorated(true); // dialog.getRootPane().setWindowDecorationStyle(JRootPane.NONE); if (locale != null) { dialog.setLocale(locale); } LocalHelpListener helpListener = null; if (helpURL != null) { helpListener = new LocalHelpListener(helpURL, locale); } else { log.warn("No HELP URL configured, help system disabled."); } GetHardwareInfoGUIFacade gui = new GetHardwareInfoGUI(dialog.getContentPane(), dialog.getLocale(), null, new ResourceFontLoader(), helpListener); BKUGUIFacade proxy = (BKUGUIFacade) GUIProxy.newInstance(gui, dialog, new Class[] { GetHardwareInfoGUIFacade.class, }); stal = new LocalBKUWorker(proxy, dialog); dialog.setPreferredSize(PREFERRED_SIZE); dialog.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = dialog.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } dialog.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); return stal; }
From source file:at.gv.egiz.bku.local.stal.LocalSTALFactory.java
@Override public STAL createSTAL() { final LocalBKUWorker stal; //http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html // use undecorated JFrame instead of JWindow, // which creates an invisible owning frame and therefore cannot getFocusInWindow() JFrame dialog = new JFrame("Brgerkarte"); log.debug("AlwaysOnTop supported: {}.", dialog.isAlwaysOnTopSupported()); // [#439] make mocca dialog alwaysOnTop dialog.setAlwaysOnTop(true);// w w w . ja va2s . com dialog.setIconImages(BKUIcons.icons); // dialog.setUndecorated(true); // dialog.getRootPane().setWindowDecorationStyle(JRootPane.NONE); if (locale != null) { dialog.setLocale(locale); } LocalHelpListener helpListener = null; if (helpURL != null) { helpListener = new LocalHelpListener(helpURL, locale); } else { log.warn("No HELP URL configured, help system disabled."); } PINManagementGUIFacade gui = new PINManagementGUI(dialog.getContentPane(), dialog.getLocale(), null, new ResourceFontLoader(), helpListener); BKUGUIFacade proxy = (BKUGUIFacade) GUIProxy.newInstance(gui, dialog, new Class[] { PINManagementGUIFacade.class }); SMCCHelper.setUseSWCard(configurationFacade.getUseSWCard()); stal = new LocalBKUWorker(proxy, dialog); dialog.setPreferredSize(PREFERRED_SIZE); dialog.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = dialog.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } dialog.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); return stal; }
From source file:au.org.ala.delta.editor.DeltaEditor.java
@Override protected void startup() { _actionMap = getContext().getActionMap(this); JFrame frame = getMainFrame(); frame.setPreferredSize(new Dimension(800, 600)); frame.setIconImages(IconHelper.getBlueIconList()); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); addExitListener(new ExitListener() { @Override/*w ww . ja v a 2s . com*/ public void willExit(EventObject event) { } @Override public boolean canExit(EventObject event) { boolean canClose = closeAll(); return canClose; } }); _helpController = new HelpController("help/delta_editor/DeltaEditor"); _dataSetRepository = new SlotFileRepository(); _statusBar = new StatusBar(); // Hiding the status bar as it doesn't really convey much useful information and takes up screen space. //getMainView().setStatusBar(_statusBar); getMainView().setMenuBar(buildMenus()); _helpController.enableHelpKey(frame); createDesktop(); show(_desktop); }
From source file:au.org.ala.delta.intkey.Intkey.java
/** * Creates and shows the GUI. Called by the swing application framework *///from w w w . jav a2 s. c o m @Override protected void startup() { final JFrame mainFrame = getMainFrame(); _defaultGlassPane = mainFrame.getGlassPane(); mainFrame.setTitle("Intkey"); mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); mainFrame.setIconImages(IconHelper.getRedIconList()); _helpController = new HelpController(HELPSET_PATH); _taxonformatter = new ItemFormatter(false, CommentStrippingMode.STRIP_ALL, AngleBracketHandlingMode.REMOVE, true, false, true); _context = new IntkeyContext(new IntkeyUIInterceptor(this), new DirectivePopulatorInterceptor(this)); _advancedModeOnlyDynamicButtons = new ArrayList<JButton>(); _normalModeOnlyDynamicButtons = new ArrayList<JButton>(); _activeOnlyWhenCharactersUsedButtons = new ArrayList<JButton>(); _dynamicButtonsFullHelp = new HashMap<JButton, String>(); ActionMap actionMap = getContext().getActionMap(); _rootPanel = new JPanel(); _rootPanel.setAlignmentX(Component.LEFT_ALIGNMENT); _rootPanel.setBackground(SystemColor.control); _rootPanel.setLayout(new BorderLayout(0, 0)); _globalOptionBar = new JPanel(); _globalOptionBar.setBorder(new EmptyBorder(0, 5, 0, 5)); _rootPanel.add(_globalOptionBar, BorderLayout.NORTH); _globalOptionBar.setLayout(new BorderLayout(0, 0)); _pnlDynamicButtons = new JPanel(); FlowLayout flowLayout_1 = (FlowLayout) _pnlDynamicButtons.getLayout(); flowLayout_1.setVgap(0); flowLayout_1.setHgap(0); _globalOptionBar.add(_pnlDynamicButtons, BorderLayout.WEST); _btnContextHelp = new JButton(); _btnContextHelp.setMinimumSize(new Dimension(30, 30)); _btnContextHelp.setMaximumSize(new Dimension(30, 30)); _btnContextHelp.setAction(actionMap.get("btnContextHelp")); _btnContextHelp.setPreferredSize(new Dimension(30, 30)); _btnContextHelp.setMargin(new Insets(2, 5, 2, 5)); _btnContextHelp.addActionListener(actionMap.get("btnContextHelp")); _globalOptionBar.add(_btnContextHelp, BorderLayout.EAST); _rootSplitPane = new JSplitPane(); _rootSplitPane.setDividerSize(3); _rootSplitPane.setResizeWeight(0.5); _rootSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT); _rootSplitPane.setContinuousLayout(true); _rootPanel.add(_rootSplitPane); _innerSplitPaneLeft = new JSplitPane(); _innerSplitPaneLeft.setMinimumSize(new Dimension(25, 25)); _innerSplitPaneLeft.setAlignmentX(Component.CENTER_ALIGNMENT); _innerSplitPaneLeft.setDividerSize(3); _innerSplitPaneLeft.setResizeWeight(0.5); _innerSplitPaneLeft.setContinuousLayout(true); _innerSplitPaneLeft.setOrientation(JSplitPane.VERTICAL_SPLIT); _rootSplitPane.setLeftComponent(_innerSplitPaneLeft); _pnlAvailableCharacters = new JPanel(); _innerSplitPaneLeft.setLeftComponent(_pnlAvailableCharacters); _pnlAvailableCharacters.setLayout(new BorderLayout(0, 0)); _sclPaneAvailableCharacters = new JScrollPane(); _pnlAvailableCharacters.add(_sclPaneAvailableCharacters, BorderLayout.CENTER); _listAvailableCharacters = new JList(); // _listAvailableCharacters.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); _listAvailableCharacters.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); _listAvailableCharacters.setCellRenderer(_availableCharactersListCellRenderer); _listAvailableCharacters.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { int selectedIndex = _listAvailableCharacters.getSelectedIndex(); if (selectedIndex >= 0) { try { Character ch = (Character) _availableCharacterListModel.getElementAt(selectedIndex); executeDirective(new UseDirective(), Integer.toString(ch.getCharacterId())); } catch (Exception ex) { ex.printStackTrace(); } } } } }); _sclPaneAvailableCharacters.setViewportView(_listAvailableCharacters); _pnlAvailableCharactersHeader = new JPanel(); _pnlAvailableCharacters.add(_pnlAvailableCharactersHeader, BorderLayout.NORTH); _pnlAvailableCharactersHeader.setLayout(new BorderLayout(0, 0)); _lblNumAvailableCharacters = new JLabel(); _lblNumAvailableCharacters.setBorder(new EmptyBorder(0, 5, 0, 0)); _lblNumAvailableCharacters.setFont(new Font("Tahoma", Font.PLAIN, 15)); _lblNumAvailableCharacters.setText(MessageFormat.format(availableCharactersCaption, 0)); _pnlAvailableCharactersHeader.add(_lblNumAvailableCharacters, BorderLayout.WEST); _pnlAvailableCharactersButtons = new JPanel(); FlowLayout flowLayout = (FlowLayout) _pnlAvailableCharactersButtons.getLayout(); flowLayout.setVgap(2); flowLayout.setHgap(2); _pnlAvailableCharactersHeader.add(_pnlAvailableCharactersButtons, BorderLayout.EAST); // All toolbar buttons should be disabled until a dataset is loaded. _btnRestart = new JButton(); _btnRestart.setAction(actionMap.get("btnRestart")); _btnRestart.setPreferredSize(new Dimension(30, 30)); _btnRestart.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnRestart); _btnBestOrder = new JButton(); _btnBestOrder.setAction(actionMap.get("btnBestOrder")); _btnBestOrder.setPreferredSize(new Dimension(30, 30)); _btnBestOrder.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnBestOrder); _btnSeparate = new JButton(); _btnSeparate.setAction(actionMap.get("btnSeparate")); _btnSeparate.setVisible(_advancedMode); _btnSeparate.setPreferredSize(new Dimension(30, 30)); _btnSeparate.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnSeparate); _btnNaturalOrder = new JButton(); _btnNaturalOrder.setAction(actionMap.get("btnNaturalOrder")); _btnNaturalOrder.setPreferredSize(new Dimension(30, 30)); _btnNaturalOrder.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnNaturalOrder); _btnDiffSpecimenTaxa = new JButton(); _btnDiffSpecimenTaxa.setAction(actionMap.get("btnDiffSpecimenTaxa")); _btnDiffSpecimenTaxa.setEnabled(false); _btnDiffSpecimenTaxa.setPreferredSize(new Dimension(30, 30)); _pnlAvailableCharactersButtons.add(_btnDiffSpecimenTaxa); _btnSetTolerance = new JButton(); _btnSetTolerance.setAction(actionMap.get("btnSetTolerance")); _btnSetTolerance.setPreferredSize(new Dimension(30, 30)); _btnSetTolerance.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnSetTolerance); _btnSetMatch = new JButton(); _btnSetMatch.setAction(actionMap.get("btnSetMatch")); _btnSetMatch.setVisible(_advancedMode); _btnSetMatch.setPreferredSize(new Dimension(30, 30)); _btnSetMatch.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnSetMatch); _btnSubsetCharacters = new JButton(); _btnSubsetCharacters.setAction(actionMap.get("btnSubsetCharacters")); _btnSubsetCharacters.setPreferredSize(new Dimension(30, 30)); _btnSubsetCharacters.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnSubsetCharacters); _btnFindCharacter = new JButton(); _btnFindCharacter.setAction(actionMap.get("btnFindCharacter")); _btnFindCharacter.setPreferredSize(new Dimension(30, 30)); _btnFindCharacter.setEnabled(false); _pnlAvailableCharactersButtons.add(_btnFindCharacter); _pnlAvailableCharactersButtons.setEnabled(false); _pnlUsedCharacters = new JPanel(); _innerSplitPaneLeft.setRightComponent(_pnlUsedCharacters); _pnlUsedCharacters.setLayout(new BorderLayout(0, 0)); _sclPnUsedCharacters = new JScrollPane(); _pnlUsedCharacters.add(_sclPnUsedCharacters, BorderLayout.CENTER); _listUsedCharacters = new JList(); _listUsedCharacters.setCellRenderer(_usedCharactersListCellRenderer); _listUsedCharacters.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); _listUsedCharacters.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { int selectedIndex = _listUsedCharacters.getSelectedIndex(); if (selectedIndex >= 0) { try { Attribute attr = (Attribute) _usedCharacterListModel.getElementAt(selectedIndex); if (_context.charactersFixed() && _context.getFixedCharactersList() .contains(attr.getCharacter().getCharacterId())) { return; } executeDirective(new ChangeDirective(), Integer.toString(attr.getCharacter().getCharacterId())); } catch (Exception ex) { ex.printStackTrace(); } } } } }); _sclPnUsedCharacters.setViewportView(_listUsedCharacters); _pnlUsedCharactersHeader = new JPanel(); _pnlUsedCharacters.add(_pnlUsedCharactersHeader, BorderLayout.NORTH); _pnlUsedCharactersHeader.setLayout(new BorderLayout(0, 0)); _lblNumUsedCharacters = new JLabel(); _lblNumUsedCharacters.setBorder(new EmptyBorder(7, 5, 7, 0)); _lblNumUsedCharacters.setFont(new Font("Tahoma", Font.PLAIN, 15)); _lblNumUsedCharacters.setText(MessageFormat.format(usedCharactersCaption, 0)); _pnlUsedCharactersHeader.add(_lblNumUsedCharacters, BorderLayout.WEST); _innerSplitPaneRight = new JSplitPane(); _innerSplitPaneRight.setMinimumSize(new Dimension(25, 25)); _innerSplitPaneRight.setDividerSize(3); _innerSplitPaneRight.setResizeWeight(0.5); _innerSplitPaneRight.setContinuousLayout(true); _innerSplitPaneRight.setOrientation(JSplitPane.VERTICAL_SPLIT); _rootSplitPane.setRightComponent(_innerSplitPaneRight); _pnlRemainingTaxa = new JPanel(); _innerSplitPaneRight.setLeftComponent(_pnlRemainingTaxa); _pnlRemainingTaxa.setLayout(new BorderLayout(0, 0)); _sclPnRemainingTaxa = new JScrollPane(); _pnlRemainingTaxa.add(_sclPnRemainingTaxa, BorderLayout.CENTER); _listRemainingTaxa = new JList(); _listRemainingTaxa.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { displayInfoForSelectedTaxa(); } } }); _sclPnRemainingTaxa.setViewportView(_listRemainingTaxa); _pnlRemainingTaxaHeader = new JPanel(); _pnlRemainingTaxa.add(_pnlRemainingTaxaHeader, BorderLayout.NORTH); _pnlRemainingTaxaHeader.setLayout(new BorderLayout(0, 0)); _lblNumRemainingTaxa = new JLabel(); _lblNumRemainingTaxa.setBorder(new EmptyBorder(0, 5, 0, 0)); _lblNumRemainingTaxa.setFont(new Font("Tahoma", Font.PLAIN, 15)); _lblNumRemainingTaxa.setText(MessageFormat.format(remainingTaxaCaption, 0)); _pnlRemainingTaxaHeader.add(_lblNumRemainingTaxa, BorderLayout.WEST); _pnlRemainingTaxaButtons = new JPanel(); FlowLayout fl_pnlRemainingTaxaButtons = (FlowLayout) _pnlRemainingTaxaButtons.getLayout(); fl_pnlRemainingTaxaButtons.setVgap(2); fl_pnlRemainingTaxaButtons.setHgap(2); _pnlRemainingTaxaHeader.add(_pnlRemainingTaxaButtons, BorderLayout.EAST); // All toolbar buttons should be disabled until a dataset is loaded. _btnTaxonInfo = new JButton(); _btnTaxonInfo.setAction(actionMap.get("btnTaxonInfo")); _btnTaxonInfo.setPreferredSize(new Dimension(30, 30)); _btnTaxonInfo.setEnabled(false); _pnlRemainingTaxaButtons.add(_btnTaxonInfo); _btnDiffTaxa = new JButton(); _btnDiffTaxa.setAction(actionMap.get("btnDiffTaxa")); _btnDiffTaxa.setPreferredSize(new Dimension(30, 30)); _btnDiffTaxa.setEnabled(false); _pnlRemainingTaxaButtons.add(_btnDiffTaxa); _btnSubsetTaxa = new JButton(); _btnSubsetTaxa.setAction(actionMap.get("btnSubsetTaxa")); _btnSubsetTaxa.setPreferredSize(new Dimension(30, 30)); _btnSubsetTaxa.setEnabled(false); _pnlRemainingTaxaButtons.add(_btnSubsetTaxa); _btnFindTaxon = new JButton(); _btnFindTaxon.setAction(actionMap.get("btnFindTaxon")); _btnFindTaxon.setPreferredSize(new Dimension(30, 30)); _btnFindTaxon.setEnabled(false); _pnlRemainingTaxaButtons.add(_btnFindTaxon); _pnlEliminatedTaxa = new JPanel(); _innerSplitPaneRight.setRightComponent(_pnlEliminatedTaxa); _pnlEliminatedTaxa.setLayout(new BorderLayout(0, 0)); _sclPnEliminatedTaxa = new JScrollPane(); _pnlEliminatedTaxa.add(_sclPnEliminatedTaxa, BorderLayout.CENTER); _listEliminatedTaxa = new JList(); _listEliminatedTaxa.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { displayInfoForSelectedTaxa(); } } }); _sclPnEliminatedTaxa.setViewportView(_listEliminatedTaxa); _pnlEliminatedTaxaHeader = new JPanel(); _pnlEliminatedTaxa.add(_pnlEliminatedTaxaHeader, BorderLayout.NORTH); _pnlEliminatedTaxaHeader.setLayout(new BorderLayout(0, 0)); _lblEliminatedTaxa = new JLabel(); _lblEliminatedTaxa.setBorder(new EmptyBorder(7, 5, 7, 0)); _lblEliminatedTaxa.setFont(new Font("Tahoma", Font.PLAIN, 15)); _lblEliminatedTaxa.setText(MessageFormat.format(eliminatedTaxaCaption, 0)); _pnlEliminatedTaxaHeader.add(_lblEliminatedTaxa, BorderLayout.WEST); JMenuBar menuBar = buildMenus(_advancedMode); getMainView().setMenuBar(menuBar); _txtFldCmdBar = new JTextField(); _txtFldCmdBar.setCaretColor(Color.WHITE); _txtFldCmdBar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { String cmdStr = _txtFldCmdBar.getText(); cmdStr = cmdStr.trim(); if (_cmdMenus.containsKey(cmdStr)) { JMenu cmdMenu = _cmdMenus.get(cmdStr); cmdMenu.doClick(); } else { _context.parseAndExecuteDirective(cmdStr); } _txtFldCmdBar.setText(null); } }); _txtFldCmdBar.setFont(new Font("Courier New", Font.BOLD, 13)); _txtFldCmdBar.setForeground(SystemColor.text); _txtFldCmdBar.setBackground(Color.BLACK); _txtFldCmdBar.setOpaque(true); _txtFldCmdBar.setVisible(_advancedMode); _rootPanel.add(_txtFldCmdBar, BorderLayout.SOUTH); _txtFldCmdBar.setColumns(10); _logDialog = new RtfReportDisplayDialog(getMainFrame(), new SimpleRtfEditorKit(null), null, logDialogTitle); // Set context-sensitive help keys for toolbar buttons _helpController.setHelpKeyForComponent(_btnRestart, HELP_ID_CHARACTERS_TOOLBAR_RESTART); _helpController.setHelpKeyForComponent(_btnBestOrder, HELP_ID_CHARACTERS_TOOLBAR_BEST); _helpController.setHelpKeyForComponent(_btnSeparate, HELP_ID_CHARACTERS_TOOLBAR_SEPARATE); _helpController.setHelpKeyForComponent(_btnNaturalOrder, HELP_ID_CHARACTERS_TOOLBAR_NATURAL); _helpController.setHelpKeyForComponent(_btnDiffSpecimenTaxa, HELP_ID_CHARACTERS_TOOLBAR_DIFF_SPECIMEN_REMAINING); _helpController.setHelpKeyForComponent(_btnSetTolerance, HELP_ID_CHARACTERS_TOOLBAR_TOLERANCE); _helpController.setHelpKeyForComponent(_btnSetMatch, HELP_ID_CHARACTERS_TOOLBAR_SET_MATCH); _helpController.setHelpKeyForComponent(_btnSubsetCharacters, HELP_ID_CHARACTERS_TOOLBAR_SUBSET_CHARACTERS); _helpController.setHelpKeyForComponent(_btnFindCharacter, HELP_ID_CHARACTERS_TOOLBAR_FIND_CHARACTERS); _helpController.setHelpKeyForComponent(_btnTaxonInfo, HELP_ID_TAXA_TOOLBAR_INFO); _helpController.setHelpKeyForComponent(_btnDiffTaxa, HELP_ID_TAXA_TOOLBAR_DIFF_TAXA); _helpController.setHelpKeyForComponent(_btnSubsetTaxa, HELP_ID_TAXA_TOOLBAR_SUBSET_TAXA); _helpController.setHelpKeyForComponent(_btnFindTaxon, HELP_ID_TAXA_TOOLBAR_FIND_TAXA); // This mouse listener on the default glasspane is to assist with // context senstive help. It intercepts the mouse events, // determines what component was being clicked on, then takes the // appropriate action to provide help for the component _defaultGlassPane.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { // Determine what point has been clicked on Point glassPanePoint = e.getPoint(); Point containerPoint = SwingUtilities.convertPoint(getMainFrame().getGlassPane(), glassPanePoint, getMainFrame().getContentPane()); Component component = SwingUtilities.getDeepestComponentAt(getMainFrame().getContentPane(), containerPoint.x, containerPoint.y); // Get the java help ID for this component. If none has been // defined, this will be null String helpID = _helpController.getHelpKeyForComponent(component); // change the cursor back to the normal one and take down the // classpane mainFrame.setCursor(Cursor.getDefaultCursor()); mainFrame.getGlassPane().setVisible(false); // If a help ID was found, display the related help page in the // help viewer if (_helpController.getHelpKeyForComponent(component) != null) { _helpController.helpAction().actionPerformed(new ActionEvent(component, 0, null)); _helpController.displayHelpTopic(mainFrame, helpID); } else { // If a dynamically-defined toolbar button was clicked, show // the help for this button in the ToolbarHelpDialog. if (component instanceof JButton) { JButton button = (JButton) component; if (_dynamicButtonsFullHelp.containsKey(button)) { String fullHelpText = _dynamicButtonsFullHelp.get(button); if (fullHelpText == null) { fullHelpText = noHelpAvailableCaption; } RTFBuilder builder = new RTFBuilder(); builder.startDocument(); builder.appendText(fullHelpText); builder.endDocument(); ToolbarHelpDialog dlg = new ToolbarHelpDialog(mainFrame, builder.toString(), button.getIcon()); show(dlg); } } } } }); show(_rootPanel); }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private void loadIcons(JFrame f) { List<Image> icons = new ArrayList<Image>(); icons.add(loadIcon("WhiteRabbit16.png", f)); icons.add(loadIcon("WhiteRabbit32.png", f)); icons.add(loadIcon("WhiteRabbit48.png", f)); icons.add(loadIcon("WhiteRabbit64.png", f)); icons.add(loadIcon("WhiteRabbit128.png", f)); icons.add(loadIcon("WhiteRabbit256.png", f)); f.setIconImages(icons); }