List of usage examples for javax.swing JFrame setIconImage
public void setIconImage(Image image)
From source file:org.jivesoftware.sparkimpl.plugin.viewer.PluginViewer.java
private void downloadPlugin(final PublicPlugin plugin) { // Prepare HTTP post final GetMethod post = new GetMethod(plugin.getDownloadURL()); // Get HTTP client Protocol.registerProtocol("https", new Protocol("https", new EasySSLProtocolSocketFactory(), 443)); final HttpClient httpclient = new HttpClient(); String proxyHost = System.getProperty("http.proxyHost"); String proxyPort = System.getProperty("http.proxyPort"); if (Default.getBoolean("PLUGIN_REPOSITORY_USE_PROXY")) { if (ModelUtil.hasLength(proxyHost) && ModelUtil.hasLength(proxyPort)) { try { httpclient.getHostConfiguration().setProxy(proxyHost, Integer.parseInt(proxyPort)); } catch (NumberFormatException e) { Log.error(e);/*from www . ja v a2 s. c o m*/ } } } // Execute request try { int result = httpclient.executeMethod(post); if (result != 200) { return; } long length = post.getResponseContentLength(); int contentLength = (int) length; progressBar = new JProgressBar(0, contentLength); final JFrame frame = new JFrame(Res.getString("message.downloading", plugin.getName())); frame.setIconImage(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_IMAGE).getImage()); final Thread thread = new Thread(new Runnable() { public void run() { try { Thread.sleep(2000); InputStream stream = post.getResponseBodyAsStream(); URL url = new URL(plugin.getDownloadURL()); String name = URLFileSystem.getFileName(url); String directoryName = URLFileSystem.getName(url); File pluginDownload = new File(PluginManager.PLUGINS_DIRECTORY, name); FileOutputStream out = new FileOutputStream(pluginDownload); copy(stream, out); out.close(); frame.dispose(); // Remove SparkPlugUI // Clear all selections Component[] comps = availablePanel.getComponents(); for (Component comp : comps) { if (comp instanceof SparkPlugUI) { SparkPlugUI sparkPlug = (SparkPlugUI) comp; if (sparkPlug.getPlugin().getDownloadURL().equals(plugin.getDownloadURL())) { availablePanel.remove(sparkPlug); _deactivatedPlugins.remove(sparkPlug.getPlugin().getName()); _prefs.setDeactivatedPlugins(_deactivatedPlugins); PluginManager.getInstance().addPlugin(sparkPlug.getPlugin()); sparkPlug.showOperationButton(); installedPanel.add(sparkPlug); sparkPlug.getPlugin() .setPluginDir(new File(PluginManager.PLUGINS_DIRECTORY, directoryName)); installedPanel.invalidate(); installedPanel.repaint(); availablePanel.invalidate(); availablePanel.invalidate(); availablePanel.validate(); availablePanel.repaint(); } } } } catch (Exception ex) { // Nothing to do } finally { // Release current connection to the connection pool once you are done post.releaseConnection(); } } }); frame.getContentPane().setLayout(new GridBagLayout()); frame.getContentPane().add(new JLabel(Res.getString("message.downloading.spark.plug")), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); frame.getContentPane().add(progressBar, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); frame.pack(); frame.setSize(400, 100); GraphicUtils.centerWindowOnComponent(frame, this); frame.setVisible(true); thread.start(); } catch (IOException e) { Log.error(e); } }
From source file:org.jivesoftware.sparkimpl.updater.CheckUpdates.java
public void downloadUpdate(final File downloadedFile, final SparkVersion version) { final java.util.Timer timer = new java.util.Timer(); // Prepare HTTP post final GetMethod post = new GetMethod(version.getDownloadURL()); // Get HTTP client Protocol.registerProtocol("https", new Protocol("https", new EasySSLProtocolSocketFactory(), 443)); final HttpClient httpclient = new HttpClient(); String proxyHost = System.getProperty("http.proxyHost"); String proxyPort = System.getProperty("http.proxyPort"); if (ModelUtil.hasLength(proxyHost) && ModelUtil.hasLength(proxyPort)) { try {// w w w. j av a2s . c o m httpclient.getHostConfiguration().setProxy(proxyHost, Integer.parseInt(proxyPort)); } catch (NumberFormatException e) { Log.error(e); } } // Execute request try { int result = httpclient.executeMethod(post); if (result != 200) { return; } long length = post.getResponseContentLength(); int contentLength = (int) length; bar = new JProgressBar(0, contentLength); } catch (IOException e) { Log.error(e); } final JFrame frame = new JFrame(Res.getString("title.downloading.im.client")); frame.setIconImage(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_IMAGE).getImage()); titlePanel = new TitlePanel(Res.getString("title.upgrading.client"), Res.getString("message.version", version.getVersion()), SparkRes.getImageIcon(SparkRes.SEND_FILE_24x24), true); final Thread thread = new Thread(new Runnable() { public void run() { try { InputStream stream = post.getResponseBodyAsStream(); long size = post.getResponseContentLength(); ByteFormat formater = new ByteFormat(); sizeText = formater.format(size); titlePanel.setDescription(Res.getString("message.version", version.getVersion()) + " \n" + Res.getString("message.file.size", sizeText)); downloadedFile.getParentFile().mkdirs(); FileOutputStream out = new FileOutputStream(downloadedFile); copy(stream, out); out.close(); if (!cancel) { downloadComplete = true; promptForInstallation(downloadedFile, Res.getString("title.download.complete"), Res.getString("message.restart.spark")); } else { out.close(); downloadedFile.delete(); } UPDATING = false; frame.dispose(); } catch (Exception ex) { // Nothing to do } finally { timer.cancel(); // Release current connection to the connection pool once you are done post.releaseConnection(); } } }); frame.getContentPane().setLayout(new GridBagLayout()); frame.getContentPane().add(titlePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); frame.getContentPane().add(bar, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); JEditorPane pane = new JEditorPane(); boolean displayContentPane = version.getChangeLogURL() != null || version.getDisplayMessage() != null; try { pane.setEditable(false); if (version.getChangeLogURL() != null) { pane.setEditorKit(new HTMLEditorKit()); pane.setPage(version.getChangeLogURL()); } else if (version.getDisplayMessage() != null) { pane.setText(version.getDisplayMessage()); } if (displayContentPane) { frame.getContentPane().add(new JScrollPane(pane), new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); } } catch (IOException e) { Log.error(e); } frame.getContentPane().setBackground(Color.WHITE); frame.pack(); if (displayContentPane) { frame.setSize(600, 400); } else { frame.setSize(400, 100); } frame.setLocationRelativeTo(SparkManager.getMainWindow()); GraphicUtils.centerWindowOnScreen(frame); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { thread.interrupt(); cancel = true; UPDATING = false; if (!downloadComplete) { JOptionPane.showMessageDialog(SparkManager.getMainWindow(), Res.getString("message.updating.cancelled"), Res.getString("title.cancelled"), JOptionPane.ERROR_MESSAGE); } } }); frame.setVisible(true); thread.start(); timer.scheduleAtFixedRate(new TimerTask() { int seconds = 1; public void run() { ByteFormat formatter = new ByteFormat(); long value = bar.getValue(); long average = value / seconds; String text = formatter.format(average) + "/Sec"; String total = formatter.format(value); titlePanel.setDescription(Res.getString("message.version", version.getVersion()) + " \n" + Res.getString("message.file.size", sizeText) + "\n" + Res.getString("message.transfer.rate") + ": " + text + "\n" + Res.getString("message.total.downloaded") + ": " + total); seconds++; } }, 1000, 1000); }
From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java
/** * Setup System Tray Icon./*from w w w . j a v a2 s .com*/ * * @param frame owner frame */ private void setupTrayIcon(final JFrame frame) { idleIcon = Toolkit.getDefaultToolkit() .getImage(ClassLoader.getSystemResource("META-INF/resources/node_inactive.png")); activeIcon = Toolkit.getDefaultToolkit() .getImage(ClassLoader.getSystemResource("META-INF/resources/node_active.png")); frame.setIconImage(idleIcon); // If system tray is supported by OS if (SystemTray.isSupported()) { trayIcon = new TrayIcon(idleIcon, "Nebula Grid Node", createTrayPopup()); trayIcon.setImageAutoSize(true); trayIcon.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (!frame.isVisible()) { frame.setVisible(true); } frame.setExtendedState(JFrame.NORMAL); frame.requestFocus(); frame.toFront(); } } }); try { SystemTray.getSystemTray().add(trayIcon); } catch (AWTException ae) { log.debug("[UI] Unable to Initialize Tray Icon"); return; } frame.addWindowListener(new WindowAdapter() { @Override public void windowIconified(WindowEvent e) { // Hide (can be shown using tray icon) frame.setVisible(false); } }); } }
From source file:org.openscience.jmol.app.Jmol.java
Jmol(Splash splash, JFrame frame, Jmol parent, int startupWidth, int startupHeight, String commandOptions, Point loc) {/*from w w w .ja v a 2 s. c o m*/ super(true); this.frame = frame; this.startupWidth = startupWidth; this.startupHeight = startupHeight; numWindows++; try { say("history file is " + historyFile.getFile().getAbsolutePath()); } catch (Exception e) { } frame.setTitle("Jmol"); frame.getContentPane().setBackground(Color.lightGray); frame.getContentPane().setLayout(new BorderLayout()); this.splash = splash; setBorder(BorderFactory.createEtchedBorder()); setLayout(new BorderLayout()); language = GT.getLanguage(); status = (StatusBar) createStatusBar(); say(GT._("Initializing 3D display...")); // display = new DisplayPanel(status, guimap, haveDisplay.booleanValue(), startupWidth, startupHeight); String adapter = System.getProperty("model"); if (adapter == null || adapter.length() == 0) adapter = "smarter"; if (adapter.equals("smarter")) { report("using Smarter Model Adapter"); modelAdapter = new SmarterJmolAdapter(); } else if (adapter.equals("cdk")) { report("the CDK Model Adapter is currently no longer supported. Check out http://bioclipse.net/. -- using Smarter"); // modelAdapter = new CdkJmolAdapter(null); modelAdapter = new SmarterJmolAdapter(); } else { report("unrecognized model adapter:" + adapter + " -- using Smarter"); modelAdapter = new SmarterJmolAdapter(); } appletContext = commandOptions; viewer = JmolViewer.allocateViewer(display, modelAdapter); viewer.setAppletContext("", null, null, commandOptions); if (display != null) display.setViewer(viewer); say(GT._("Initializing Preferences...")); preferencesDialog = new PreferencesDialog(frame, guimap, viewer); say(GT._("Initializing Recent Files...")); recentFiles = new RecentFilesDialog(frame); if (haveDisplay.booleanValue()) { say(GT._("Initializing Script Window...")); scriptWindow = new ScriptWindow(viewer, frame); } MyStatusListener myStatusListener; myStatusListener = new MyStatusListener(); viewer.setJmolStatusListener(myStatusListener); say(GT._("Initializing Measurements...")); measurementTable = new MeasurementTable(viewer, frame); // Setup Plugin system // say(GT._("Loading plugins...")); // pluginManager = new CDKPluginManager( // System.getProperty("user.home") + System.getProperty("file.separator") // + ".jmol", new JmolEditBus(viewer) // ); // pluginManager.loadPlugin("org.openscience.cdkplugin.dirbrowser.DirBrowserPlugin"); // pluginManager.loadPlugin("org.openscience.cdkplugin.dirbrowser.DadmlBrowserPlugin"); // pluginManager.loadPlugins( // System.getProperty("user.home") + System.getProperty("file.separator") // + ".jmol/plugins" // ); // feature to allow for globally installed plugins // if (System.getProperty("plugin.dir") != null) { // pluginManager.loadPlugins(System.getProperty("plugin.dir")); // } if (haveDisplay.booleanValue()) { // install the command table say(GT._("Building Command Hooks...")); commands = new Hashtable(); if (display != null) { Action[] actions = getActions(); for (int i = 0; i < actions.length; i++) { Action a = actions[i]; commands.put(a.getValue(Action.NAME), a); } } menuItems = new Hashtable(); say(GT._("Building Menubar...")); executeScriptAction = new ExecuteScriptAction(); menubar = createMenubar(); add("North", menubar); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add("North", createToolbar()); JPanel ip = new JPanel(); ip.setLayout(new BorderLayout()); ip.add("Center", display); panel.add("Center", ip); add("Center", panel); add("South", status); say(GT._("Starting display...")); display.start(); //say(GT._("Setting up File Choosers...")); /* pcs.addPropertyChangeListener(chemFileProperty, exportAction); pcs.addPropertyChangeListener(chemFileProperty, povrayAction); pcs.addPropertyChangeListener(chemFileProperty, writeAction); pcs.addPropertyChangeListener(chemFileProperty, toWebAction); pcs.addPropertyChangeListener(chemFileProperty, printAction); pcs.addPropertyChangeListener(chemFileProperty, viewMeasurementTableAction); */ if (menuFile != null) { menuStructure = viewer.getFileAsString(menuFile); } jmolpopup = JmolPopup.newJmolPopup(viewer, true, menuStructure, true); } // prevent new Jmol from covering old Jmol if (loc != null) { frame.setLocation(loc); } else if (parent != null) { Point location = parent.frame.getLocationOnScreen(); int maxX = screenSize.width - 50; int maxY = screenSize.height - 50; location.x += 40; location.y += 40; if ((location.x > maxX) || (location.y > maxY)) { location.setLocation(0, 0); } frame.setLocation(location); } frame.getContentPane().add("Center", this); frame.addWindowListener(new Jmol.AppCloser()); frame.pack(); frame.setSize(startupWidth, startupHeight); ImageIcon jmolIcon = JmolResourceHandler.getIconX("icon"); Image iconImage = jmolIcon.getImage(); frame.setIconImage(iconImage); // Repositionning windows if (scriptWindow != null) historyFile.repositionWindow(SCRIPT_WINDOW_NAME, scriptWindow, 200, 100); say(GT._("Setting up Drag-and-Drop...")); FileDropper dropper = new FileDropper(); final JFrame f = frame; dropper.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { //System.out.println("Drop triggered..."); f.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (evt.getPropertyName().equals(FileDropper.FD_PROPERTY_FILENAME)) { final String filename = evt.getNewValue().toString(); viewer.openFile(filename); } else if (evt.getPropertyName().equals(FileDropper.FD_PROPERTY_INLINE)) { final String inline = evt.getNewValue().toString(); viewer.openStringInline(inline); } f.setCursor(Cursor.getDefaultCursor()); } }); this.setDropTarget(new DropTarget(this, dropper)); this.setEnabled(true); say(GT._("Launching main frame...")); }
From source file:org.sleeksnap.ScreenSnapper.java
/** * Open the settings panel/* w w w.ja v a 2 s . com*/ */ public boolean openSettings() { if (optionsOpen) { return false; } optionsOpen = true; final JFrame frame = new JFrame("Sleeksnap Settings"); final OptionPanel panel = new OptionPanel(this); panel.getUploaderPanel().setImageUploaders(uploaders.get(ImageUpload.class).values()); panel.getUploaderPanel().setTextUploaders(uploaders.get(TextUpload.class).values()); panel.getUploaderPanel().setURLUploaders(uploaders.get(URLUpload.class).values()); panel.getUploaderPanel().setFileUploaders(uploaders.get(FileUpload.class).values()); panel.setHistory(history); panel.doneBuilding(); frame.add(panel); frame.pack(); frame.setVisible(true); frame.setResizable(false); try { frame.setIconImage(ImageIO.read(Util.getResourceByName("/icon32x32.png"))); } catch (final IOException e1) { e1.printStackTrace(); } Util.centerFrame(frame); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosed(final WindowEvent e) { optionsOpen = false; LogPanelHandler.unbind(); } }); return true; }
From source file:org.sleeksnap.updater.Updater.java
/** * Download the specified file with a ProgressPanel to show progress. * //from w w w . j a v a2 s .c om * @param url * The URL to download from * @param file * The file to download to * @throws IOException * If a problem occurred while starting the download */ public void download(final URL url, final File file) throws IOException { final JFrame frame = new JFrame("Sleeksnap Update"); final ProgressPanel panel = new ProgressPanel(); frame.add(panel); frame.pack(); frame.setResizable(false); frame.setVisible(true); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); try { frame.setIconImage(ImageIO.read(Util.getResourceByName("/icon32x32.png"))); } catch (final IOException e1) { e1.printStackTrace(); } Util.centerFrame(frame); final Downloader downloader = new Downloader(url, new FileOutputStream(file)); downloader.addListener(panel); downloader.addListener(new DownloadAdapter() { @Override public void downloadFinished(final Downloader downloader) { updateFinished(file); } }); downloader.start(); }
From source file:org.springframework.richclient.application.support.AbstractApplicationWindow.java
protected void applyStandardLayout(JFrame windowControl, ApplicationWindowConfigurer configurer) { windowControl.setTitle(configurer.getTitle()); windowControl.setIconImage(configurer.getImage()); windowControl.setJMenuBar(createMenuBarControl()); windowControl.getContentPane().setLayout(new BorderLayout()); windowControl.getContentPane().add(createToolBarControl(), BorderLayout.NORTH); windowControl.getContentPane().add(createWindowContentPane()); windowControl.getContentPane().add(createStatusBarControl(), BorderLayout.SOUTH); }
From source file:org.swiftexplorer.SwiftExplorer.java
private static void openMainWindow(final MainPanel cp) throws IOException { JFrame frame = new JFrame(Configuration.INSTANCE.getAppName()); Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); float ratio = (float) 0.8; Dimension windowSize = new Dimension((int) (screenSize.getWidth() * ratio), (int) (screenSize.getHeight() * ratio)); frame.setSize(windowSize.getSize()); frame.setLocationByPlatform(true);//from w ww. j a va 2 s.c o m frame.setIconImage(ImageIO.read(SwiftExplorer.class.getResource("/icons/logo.png"))); frame.getContentPane().add(cp); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { if (cp.onClose()) { System.exit(0); } } }); cp.setOwner(frame); frame.setJMenuBar(cp.createMenuBar()); // center the frame int x = (int) ((screenSize.getWidth() - frame.getWidth()) / 2); int y = (int) ((screenSize.getHeight() - frame.getHeight()) / 2); frame.setLocation(x, y); frame.setVisible(true); }
From source file:qic.launcher.Main.java
private void startGUI(TakeDown installer) { TextAreaWithBackground textArea = new TextAreaWithBackground(); JButton launchButton = new JButton(" Launch "); launchButton.setEnabled(false);// w w w . j ava2s . co m JProgressBar progressBar = new JProgressBar(); launchButton.addActionListener(e -> { runAIC(); System.exit(0); }); JPanel southPanel = new JPanel(); southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.X_AXIS)); southPanel.add(progressBar); southPanel.add(launchButton); JFrame frame = new JFrame("QIC Search Updater"); frame.setIconImage(new ImageIcon(getClass().getResource("/q.png")).getImage()); frame.setLayout(new BorderLayout(5, 5)); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.getContentPane().add(southPanel, BorderLayout.SOUTH); frame.setSize(495, 445); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); textArea.setText("Loading path notes..."); String imgUrl = "http://poeqic.github.io/launcher/images/background.png"; try { Image image = ImageIO.read(new URL(imgUrl)); if (image != null) textArea.setBackgroundImage(image); } catch (IOException ex) { logger.error("Error while loading background image from: " + imgUrl, ex); } Worker<String> pathNotesWorker = new Worker<String>(() -> URLConnectionReader.getText(CHANGELOG_URL), s -> textArea.setText(s), e -> showErrorAndQuit(e)); pathNotesWorker.execute(); Worker<Boolean> updaterWorker = new Worker<Boolean>(() -> { progressBar.setIndeterminate(true); return installer.installOrUpdate(); }, b -> { progressBar.setIndeterminate(false); launchButton.setEnabled(true); }, e -> showErrorAndQuit(e)); updaterWorker.execute(); }
From source file:ro.nextreports.designer.action.report.ViewReportSqlAction.java
public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setDialogTitle(I18NSupport.getString("select.next.reports.file")); fc.setAcceptAllFileFilterUsed(false); fc.addChoosableFileFilter(new NextFileFilter()); int returnVal = fc.showOpenDialog(Globals.getMainFrame()); if (returnVal == JFileChooser.APPROVE_OPTION) { File f = fc.getSelectedFile(); if (f != null) { String sql = null;/*w w w . j a va 2s . c o m*/ String entityName = null; Object entity = null; FileInputStream fis = null; entityName = f.getName(); try { XStream xstream = XStreamFactory.createXStream(); fis = new FileInputStream(f); entity = xstream.fromXML(fis); } catch (Exception ex) { Show.error(ex); } finally { if (fis != null) { try { fis.close(); } catch (IOException e1) { e1.printStackTrace(); } } } if (entityName.endsWith(QueryFilter.QUERY_EXTENSION) || entityName.endsWith(ReportFilter.REPORT_EXTENSION)) { Report report = (Report) entity; if (report.getSql() != null) { sql = report.getSql(); } else if (report.getQuery() != null) { SelectQuery query = report.getQuery(); try { query.setDialect(DialectUtil.getDialect(Globals.getConnection())); } catch (Exception ex) { ex.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. LOG.error(ex.getMessage(), ex); } sql = query.toString(); } } else if (entityName.endsWith(ChartFilter.CHART_EXTENSION)) { Chart chart = (Chart) entity; if (chart.getReport().getSql() != null) { sql = chart.getReport().getSql(); } else if (chart.getReport().getQuery() != null) { SelectQuery query = chart.getReport().getQuery(); try { query.setDialect(DialectUtil.getDialect(Globals.getConnection())); } catch (Exception ex) { ex.printStackTrace(); LOG.error(ex.getMessage(), ex); } sql = query.toString(); } } Editor editor = new Editor(); editor.setText(sql); editor.setPreferredSize(new Dimension(400, 400)); JFrame frame = new JFrame(I18NSupport.getString("view.sql.info", entityName)); frame.setIconImage(ImageUtil.getImageIcon("report_view").getImage()); frame.setLayout(new GridBagLayout()); frame.add(editor, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); frame.pack(); Show.centrateComponent(Globals.getMainFrame(), frame); frame.setVisible(true); } } }