List of usage examples for javax.swing JFrame setLocation
@Override public void setLocation(int x, int y)
The method changes the geometry-related data.
From source file:com.isencia.passerelle.hmi.HMIBase.java
protected void showModelGraph(final String modelKey) { try {/* w w w . ja v a2s. c om*/ final JFrame gf = new JFrame(HMIMessages.getString(HMIMessages.GRAPH_TITLE)); gf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); if (graphPanelEffigy == null) { graphPanelEffigy = new PtolemyEffigy(getPtolemyConfiguration(), modelKey); } graphPanel = new ModelGraphPanel(currentModel, graphPanelEffigy); // TODO BEWARE : animation now happens in the actor // thread and blocks for a second!! // graphPanel.setAnimationDelay(1000); gf.addWindowListener(new WindowAdapter() { @Override public void windowClosed(final WindowEvent e) { clearModelGraphs(); } }); gf.getContentPane().add(graphPanel); gf.setLocation(400, 300); gf.setSize(700, 400); gf.setVisible(true); } catch (final Throwable t) { logger.error(HMIMessages.getString(HMIMessages.ERROR_GENERIC), t); } }
From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java
private void wireUp() { fileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { if (actionEvent.getSource() == fileItem) { currentLocation = new File(retrieveFromDb.retrieveOpenLocation()); fileChooser.setCurrentDirectory(currentLocation); int returnedVal = fileChooser.showOpenDialog(getParent()); if (returnedVal == JFileChooser.APPROVE_OPTION) { currentLocation = fileChooser.getCurrentDirectory(); retrieveFromDb.saveOpenLocation(currentLocation.getAbsolutePath()); RootPaneContainer root = (RootPaneContainer) getRootPane().getTopLevelAncestor(); root.getGlassPane().setCursor(WAIT_CURSOR); root.getGlassPane().setVisible(true); File[] files = fileChooser.getSelectedFiles(); for (File file : files) { if (file.isDirectory()) { File[] fileArray = file.listFiles(); Arrays.sort(fileArray, new FileNameComparator()); for (File children : fileArray) { if (isCorrect(children)) { xmlEadListModel.addFile(children); }/*w ww . ja va 2 s . c o m*/ } } else { if (isCorrect(file)) { xmlEadListModel.addFile(file); } } } root.getGlassPane().setCursor(DEFAULT_CURSOR); root.getGlassPane().setVisible(false); } } } }); repositoryCodeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createOptionPaneForRepositoryCode(); } }); countryCodeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createOptionPaneForCountryCode(); } }); checksLoadingFilesItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { createOptionPaneForChecksLoadingFiles(); } }); createEag2012FromExistingEag2012.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser eagFileChooser = new JFileChooser(); eagFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); eagFileChooser.setMultiSelectionEnabled(false); eagFileChooser.setCurrentDirectory(new File(retrieveFromDb.retrieveOpenLocation())); if (eagFileChooser.showOpenDialog(getParent()) == JFileChooser.APPROVE_OPTION) { currentLocation = eagFileChooser.getCurrentDirectory(); retrieveFromDb.saveOpenLocation(currentLocation.getAbsolutePath()); File eagFile = eagFileChooser.getSelectedFile(); if (!Eag2012Frame.isUsed()) { try { if (ReadXml.isXmlFile(eagFile, "eag")) { new Eag2012Frame(eagFile, getContentPane().getSize(), (ProfileListModel) getXmlEadList().getModel(), labels); } else { JOptionPane.showMessageDialog(rootPane, labels.getString("eag2012.errors.notAnEagFile")); } } catch (SAXException ex) { if (ex instanceof SAXParseException) { JOptionPane.showMessageDialog(rootPane, labels.getString("eag2012.errors.notAnEagFile")); } java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (IOException ex) { java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (ParserConfigurationException ex) { java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (Exception ex) { try { JOptionPane.showMessageDialog(rootPane, labels.getString(ex.getMessage())); } catch (Exception ex1) { JOptionPane.showMessageDialog(rootPane, "Error..."); } } } } } }); createEag2012FromScratch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!Eag2012Frame.isUsed()) { new Eag2012Frame(getContentPane().getSize(), (ProfileListModel) getXmlEadList().getModel(), labels, retrieveFromDb.retrieveCountryCode(), retrieveFromDb.retrieveRepositoryCode()); } } }); digitalObjectTypeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!DigitalObjectAndRightsOptionFrame.isInUse()) { JFrame DigitalObjectAndRightsOptionFrame = new DigitalObjectAndRightsOptionFrame(labels, retrieveFromDb); DigitalObjectAndRightsOptionFrame.setPreferredSize(new Dimension( getContentPane().getWidth() * 3 / 8, getContentPane().getHeight() * 3 / 4)); DigitalObjectAndRightsOptionFrame.setLocation(getContentPane().getWidth() / 8, getContentPane().getHeight() / 8); DigitalObjectAndRightsOptionFrame.pack(); DigitalObjectAndRightsOptionFrame.setVisible(true); } } }); defaultSaveFolderItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JFileChooser defaultSaveFolderChooser = new JFileChooser(); defaultSaveFolderChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); defaultSaveFolderChooser.setMultiSelectionEnabled(false); defaultSaveFolderChooser.setCurrentDirectory(new File(retrieveFromDb.retrieveDefaultSaveFolder())); if (defaultSaveFolderChooser.showOpenDialog(getParent()) == JFileChooser.APPROVE_OPTION) { File directory = defaultSaveFolderChooser.getSelectedFile(); if (directory.canWrite() && DirectoryPermission.canWrite(directory)) { retrieveFromDb.saveDefaultSaveFolder(directory + "/"); } else { createErrorOrWarningPanel(new Exception(labels.getString("error.directory.nowrites")), false, labels.getString("error.directory.nowrites"), getContentPane()); } } } }); listDateConversionRulesItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JDialog dateConversionRulesDialog = new DateConversionRulesDialog(labels, retrieveFromDb); dateConversionRulesDialog.setPreferredSize( new Dimension(getContentPane().getWidth() * 3 / 8, getContentPane().getHeight() * 7 / 8)); dateConversionRulesDialog.setLocation(getContentPane().getWidth() / 8, getContentPane().getHeight() / 8); dateConversionRulesDialog.pack(); dateConversionRulesDialog.setVisible(true); } }); edmGeneralOptionsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!EdmGeneralOptionsFrame.isInUse()) { JFrame edmGeneralOptionsFrame = new EdmGeneralOptionsFrame(labels, retrieveFromDb); edmGeneralOptionsFrame.setPreferredSize(new Dimension(getContentPane().getWidth() * 3 / 8, getContentPane().getHeight() * 3 / 8)); edmGeneralOptionsFrame.setLocation(getContentPane().getWidth() / 8, getContentPane().getHeight() / 8); edmGeneralOptionsFrame.pack(); edmGeneralOptionsFrame.setVisible(true); } } }); closeSelectedItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { xmlEadListModel.removeFiles(xmlEadList.getSelectedValues()); } }); saveSelectedItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String defaultOutputDirectory = retrieveFromDb.retrieveDefaultSaveFolder(); boolean isMultipleFiles = xmlEadList.getSelectedIndices().length > 1; RootPaneContainer root = (RootPaneContainer) getRootPane().getTopLevelAncestor(); root.getGlassPane().setCursor(WAIT_CURSOR); root.getGlassPane().setVisible(true); for (Object selectedValue : xmlEadList.getSelectedValues()) { File selectedFile = (File) selectedValue; String filename = selectedFile.getName(); FileInstance fileInstance = fileInstances.get(filename); String filePrefix = fileInstance.getFileType().getFilePrefix(); //todo: do we really need this? filename = filename.startsWith("temp_") ? filename.replace("temp_", "") : filename; filename = !filename.endsWith(".xml") ? filename + ".xml" : filename; if (!fileInstance.isValid()) { filePrefix = "NOT_" + filePrefix; } if (fileInstance.getLastOperation().equals(FileInstance.Operation.EDIT_TREE)) { TreeTableModel treeTableModel = tree.getTreeTableModel(); Document document = (Document) treeTableModel.getRoot(); try { File file2 = new File(defaultOutputDirectory + filePrefix + "_" + filename); File filetemp = new File(Utilities.TEMP_DIR + "temp_" + filename); TransformerFactory tf = TransformerFactory.newInstance(); Transformer output = tf.newTransformer(); output.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, "yes"); output.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); DOMSource domSource = new DOMSource(document.getFirstChild()); output.transform(domSource, new StreamResult(filetemp)); output.transform(domSource, new StreamResult(file2)); fileInstance.setLastOperation(FileInstance.Operation.SAVE); fileInstance.setCurrentLocation(filetemp.getAbsolutePath()); } catch (Exception ex) { createErrorOrWarningPanel(ex, true, labels.getString("errorSavingTreeXML"), getContentPane()); } } else if (fileInstance.isConverted()) { try { File newFile = new File(defaultOutputDirectory + filePrefix + "_" + filename); FileUtils.copyFile(new File(fileInstance.getCurrentLocation()), newFile); fileInstance.setLastOperation(FileInstance.Operation.SAVE); // fileInstance.setCurrentLocation(newFile.getAbsolutePath()); } catch (IOException ioe) { LOG.error("Error when saving file", ioe); } } else { try { File newFile = new File(defaultOutputDirectory + filePrefix + "_" + filename); FileUtils.copyFile(selectedFile, newFile); fileInstance.setLastOperation(FileInstance.Operation.SAVE); // fileInstance.setCurrentLocation(newFile.getAbsolutePath()); } catch (IOException ioe) { LOG.error("Error when saving file", ioe); } } } root.getGlassPane().setCursor(DEFAULT_CURSOR); root.getGlassPane().setVisible(false); if (isMultipleFiles) { JOptionPane.showMessageDialog(getContentPane(), MessageFormat.format(labels.getString("filesInOutput"), defaultOutputDirectory) + ".", labels.getString("fileSaved"), JOptionPane.INFORMATION_MESSAGE, Utilities.icon); } else { JOptionPane.showMessageDialog(getContentPane(), MessageFormat.format(labels.getString("fileInOutput"), defaultOutputDirectory) + ".", labels.getString("fileSaved"), JOptionPane.INFORMATION_MESSAGE, Utilities.icon); } xmlEadList.updateUI(); } }); saveMessageReportItem.addActionListener( new MessageReportActionListener(retrieveFromDb, this, fileInstances, labels, this)); sendFilesWebDAV.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { throw new UnsupportedOperationException("Not supported yet."); } }); quitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); xsltItem.addActionListener(new XsltAdderActionListener(this, labels)); xsdItem.addActionListener(new XsdAdderActionListener(this, labels, retrieveFromDb)); if (Utilities.isDev) { databaseItem.addActionListener(new DatabaseCheckerActionListener(retrieveFromDb, getContentPane())); } xmlEadList.addMouseListener(new ListMouseAdapter(xmlEadList, xmlEadListModel, deleteFileItem, this)); xmlEadList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (xmlEadList.getSelectedValues() != null && xmlEadList.getSelectedValues().length != 0) { if (xmlEadList.getSelectedValues().length > 1) { // convertAndValidateBtn.setEnabled(true); // validateSelectionBtn.setEnabled(true); // if (isValidated(xmlEadList)) { // convertEdmSelectionBtn.setEnabled(true); // } else { // convertEdmSelectionBtn.setEnabled(false); // } // disableAllBtnAndItems(); saveMessageReportItem.setEnabled(true); changeInfoInGUI(""); } else { // convertAndValidateBtn.setEnabled(false); // validateSelectionBtn.setEnabled(false); // convertEdmSelectionBtn.setEnabled(false); changeInfoInGUI(((File) xmlEadList.getSelectedValue()).getName()); if (apePanel.getApeTabbedPane().getSelectedIndex() == APETabbedPane.TAB_EDITION) { apePanel.getApeTabbedPane() .createEditionTree(((File) xmlEadList.getSelectedValue())); if (tree != null) { FileInstance fileInstance = fileInstances .get(((File) getXmlEadList().getSelectedValue()).getName()); tree.addMouseListener(new PopupMouseListener(tree, getDataPreparationToolGUI(), getContentPane(), fileInstance)); } } disableTabFlashing(); } checkHoldingsGuideButton(); } else { // convertAndValidateBtn.setEnabled(false); // validateSelectionBtn.setEnabled(false); // convertEdmSelectionBtn.setEnabled(false); createHGBtn.setEnabled(false); analyzeControlaccessBtn.setEnabled(false); changeInfoInGUI(""); } } } private boolean isValidated(JList xmlEadList) { for (Object selectedValue : xmlEadList.getSelectedValues()) { File selectedFile = (File) selectedValue; String filename = selectedFile.getName(); FileInstance fileInstance = fileInstances.get(filename); if (!fileInstance.isValid()) { return false; } } return true; } }); summaryWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_SUMMARY)); validationWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_VALIDATION)); conversionWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_CONVERSION)); edmConversionWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_EDM)); editionWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_EDITION)); internetApexItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { BareBonesBrowserLaunch.openURL("http://www.apex-project.eu/"); } }); /** * Option Edit apeEAC-CPF file in the menu */ this.editEacCpfFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser eacFileChooser = new JFileChooser(); eacFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); eacFileChooser.setMultiSelectionEnabled(false); eacFileChooser.setCurrentDirectory(new File(retrieveFromDb.retrieveOpenLocation())); if (eacFileChooser.showOpenDialog(getParent()) == JFileChooser.APPROVE_OPTION) { currentLocation = eacFileChooser.getCurrentDirectory(); retrieveFromDb.saveOpenLocation(currentLocation.getAbsolutePath()); File eacFile = eacFileChooser.getSelectedFile(); if (!EacCpfFrame.isUsed()) { try { if (ReadXml.isXmlFile(eacFile, "eac-cpf")) { new EacCpfFrame(eacFile, true, getContentPane().getSize(), (ProfileListModel) getXmlEadList().getModel(), labels); } else { JOptionPane.showMessageDialog(rootPane, labels.getString("eaccpf.error.notAnEacCpfFile")); } } catch (SAXException ex) { if (ex instanceof SAXParseException) { JOptionPane.showMessageDialog(rootPane, labels.getString("eaccpf.error.notAnEacCpfFile")); } java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (IOException ex) { java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (ParserConfigurationException ex) { java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (Exception ex) { try { JOptionPane.showMessageDialog(rootPane, labels.getString(ex.getMessage())); } catch (Exception ex1) { JOptionPane.showMessageDialog(rootPane, "Error..."); } } } } } }); /** * Option Create apeEAC-CPF in the menu */ this.createEacCpf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!EacCpfFrame.isUsed()) { EacCpfFrame eacCpfFrame = new EacCpfFrame(getContentPane().getSize(), (ProfileListModel) getXmlEadList().getModel(), labels, retrieveFromDb.retrieveCountryCode(), retrieveFromDb.retrieveRepositoryCode(), null, null, null); } } }); }
From source file:com.mirth.connect.plugins.imageviewer.ImageViewer.java
public void viewAttachments(String channelId, Long messageId, String attachmentId) { JFrame frame = new JFrame("Image Viewer"); try {//from w w w. jav a 2 s . c o m Attachment attachment = parent.mirthClient.getAttachment(channelId, messageId, attachmentId); byte[] rawData = attachment.getContent(); ByteArrayInputStream bis = new ByteArrayInputStream(rawData); image = ImageIO.read(new Base64InputStream(bis)); JScrollPane pictureScrollPane = new JScrollPane(new JLabel(new ImageIcon(image))); pictureScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); pictureScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); frame.add(pictureScrollPane); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { e.getWindow().dispose(); } }); frame.pack(); int imageWidth = image.getWidth(); int imageHeight = image.getHeight(); // Resize the frame so that it fits and scrolls images larger than // 800x600 properly. if (imageWidth > 800 || imageHeight > 600) { int width = imageWidth; int height = imageHeight; if (imageWidth > 800) { width = 800; } if (imageHeight > 600) { height = 600; } // Also add the scrollbars to the window width if necessary. Integer scrollBarWidth = (Integer) UIManager.get("ScrollBar.width"); int verticalScrollBar = 0; int horizontalScrollBar = 0; if (width == 800) { horizontalScrollBar = scrollBarWidth.intValue(); } if (height == 600) { verticalScrollBar = scrollBarWidth.intValue(); } // Also add the window borders to the width. width = width + frame.getInsets().left + frame.getInsets().right + verticalScrollBar; height = height + frame.getInsets().top + frame.getInsets().bottom + horizontalScrollBar; frame.setSize(width, height); } Dimension dlgSize = frame.getSize(); Dimension frmSize = parent.getSize(); Point loc = parent.getLocation(); if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) { frame.setLocationRelativeTo(null); } else { frame.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); } frame.setVisible(true); } catch (Exception e) { parent.alertThrowable(parent, e); } }
From source file:omr.jai.TestImage3.java
public TestImage3() { JFrame frame = new JFrame(getClass().getName()); Container pane = frame.getContentPane(); pane.setLayout(new BorderLayout()); pane.add(this); image = decodeImage(new String[] { "#-###############", "-----------------", "#################", "-----------------", "#################", "-----------------", "#################", "-----------------", "#################", "-----------------", "#################", "-----------------", "-----------------", "-----------------", "---####----------", "-------##--------", "---------####----", "-------------#---", "-------------#---", "-----------------", "--#############--", "--#############--", "--#############--", "--#############--", "--#############--", "--#############--", "--#############--", "--#############--", "--#############--", "--#############--", "--#############--", "-----------------", "-----------------", "---####----------", "-------##--------", "---------####----", "-------------#---", "-------------#---", "-----------------", "--#############--", "--#############--", "-----------------", "-----------------" });/*w w w. j av a 2 s . com*/ // checkImageFormat(); ImageInfo.print(image); // Scaling final float scale = 1f; ParameterBlock pb = new ParameterBlock() .addSource(image) .add(scale) .add(scale) .add(0f) .add(0f) .add(new InterpolationNearest()); image = JAI.create("scale", pb); dumpPixels(0, 0, 5, 7); if (false) { System.out.println("\nBand Selection"); image = JAI.create("bandselect",image,new int[] {0, 1, 2}); ImageInfo.print(image); dumpPixels(0, 0, 5, 7); } frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocation(100, 100); frame.pack(); frame.setSize(100, 250); frame.setVisible(true); }
From source file:ffx.ui.MainPanel.java
/** * Load preferences from the user node//w w w . j a v a 2 s .co m */ public void loadPrefs() { String c = MainPanel.class.getName(); JFrame frame1 = (JFrame) SwingUtilities.getRoot(this); Toolkit toolkit = getToolkit(); Dimension screenSize = toolkit.getScreenSize(); int x = preferences.getInt(c + ".x", screenSize.width / 8); int y = preferences.getInt(c + ".y", screenSize.height / 8); int width = preferences.getInt(c + ".width", screenSize.width * 3 / 4); int height = preferences.getInt(c + ".height", screenSize.height * 3 / 4); if (width > screenSize.width * 0.4 && width < screenSize.width * 0.8 && height > screenSize.height * 0.4 && height < screenSize.height * 0.8) { frame1.setSize(width, height); } else { frame1.setSize(screenSize.width * 4 / 5, screenSize.height * 4 / 5); } if (x > 0 && x < screenSize.width / 2 && y > 0 && y < screenSize.height / 2) { frame1.setLocation(x, y); } else { frame1.setLocation(screenSize.width / 8, screenSize.height / 8); } splitPaneDivider = preferences.getInt(c + ".divider", 200); if (splitPaneDivider < frame1.getWidth() * (1.0f / 4.0f)) { splitPaneDivider = (int) (frame1.getWidth() * (1.0f / 4.0f)); } splitPane.setDividerLocation(splitPaneDivider); if (!preferences.getBoolean(c + ".system", true)) { mainMenu.setSystemShowing(false); splitPane.setDividerLocation(0); } else { mainMenu.setSystemShowing(true); } if (!preferences.getBoolean(c + ".menu", true)) { remove(mainMenu.getToolBar()); mainMenu.setMenuShowing(false); validate(); } else { mainMenu.setMenuShowing(true); } try { port = preferences.getInt(c + ".port", 2000); ip = preferences.get(c + ".ip", InetAddress.getLocalHost().getHostAddress()); if (ip != null) { address = InetAddress.getByName(ip); socketAddress = new InetSocketAddress(address, port); } else { socketAddress = new InetSocketAddress(port); } } catch (Exception e) { logger.log(Level.WARNING, e.toString()); } if (graphicsCanvas != null) { graphicsCanvas.loadPrefs(); } }
From source file:TestImage2.java
public TestImage2() { JFrame frame = new JFrame(getClass().getName()); Container pane = frame.getContentPane(); pane.setLayout(new BorderLayout()); pane.add(this); image = toRenderedImage(// w w w.j av a2 s . c om new String[] { "-##########################################################################-", "----------------------------------------------------------------------------", "-##########################################################################-", "----------------------------------------------------------------------------", "-##########################################################################-", "----------------------------------------------------------------------------", "-##########################################################################-", "----------------------------------------------------------------------------", "-##########################################################################-", "----------------------------------------------------------------------------", "-##########################################################################-", "----------------------------------------------------------------------------", "----------------------------------------------------------------------------", "----------------------------------------------------------------------------", "----####---------------####---------------####---------------####-----------", "--------##-----------------##-----------------##-----------------##---------", "----------####---------------####---------------####---------------####-----", "--------------#------------------#------------------#------------------#----", "--------------#------------------#------------------#------------------#----", "----------------------------------------------------------------------------", "---#############------#############------#############------#############---", "---#############------#############------#############------#############---", "---#############------#############------#############------#############---", "---#############------#############------#############------#############---", "---#############------#############------#############------#############---", "---#############------#############------#############------#############---", "---#############------#############------#############------#############---", "---#############------#############------#############------#############---", "---#############------#############------#############------#############---", "---#############------#############------#############------#############---", "---#############------#############------#############------#############---", "----------------------------------------------------------------------------", "----------------------------------------------------------------------------", "----####---------------####---------------####---------------####-----------", "--------##-----------------##-----------------##-----------------##---------", "----------####---------------####---------------####---------------####-----", "--------------#------------------#------------------#------------------#----", "--------------#------------------#------------------#------------------#----", "----------------------------------------------------------------------------", "---#############------#############------#############------#############---", "---#############------#############------#############------#############---", "----------------------------------------------------------------------------", "----------------------------------------------------------------------------" }); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocation(100, 100); frame.pack(); frame.setSize(200, 200); frame.setVisible(true); }
From source file:net.sourceforge.pmd.util.designer.Designer.java
private void createRuleXML() { CreateXMLRulePanel rulePanel = new CreateXMLRulePanel(xpathQueryArea, codeEditorPane); JFrame xmlframe = new JFrame("Create XML Rule"); xmlframe.setContentPane(rulePanel);/*from w w w . j a v a 2s. c o m*/ xmlframe.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); xmlframe.setSize(new Dimension(600, 700)); xmlframe.addComponentListener(new java.awt.event.ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { JFrame tmp = (JFrame) e.getSource(); if (tmp.getWidth() < 600 || tmp.getHeight() < 700) { tmp.setSize(600, 700); } } }); int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height; int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width; xmlframe.pack(); xmlframe.setLocation((screenWidth - xmlframe.getWidth()) / 2, (screenHeight - xmlframe.getHeight()) / 2); xmlframe.setVisible(true); }
From source file:org.gridchem.client.GridChem.java
public static void main(String[] args) { Trace.entry();/* w w w.j a va 2s .c om*/ try { setCommandLineOptions(); parseCommandLine(args); } catch (Exception e) { System.out.println("Invalid command line option given: " + e.getMessage()); } //JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); // Edited by Shashank & Sandeep @ CCS,UKY April 10 2005 JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); /*MetalTheme theme = new G03Input.ColorTheme(); MetalLookAndFeel.setCurrentTheme(theme); try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); SwingUtilities.updateComponentTreeUI(frame); } catch(Exception e) { System.out.println(e); }*/ // Use the native look and feel since Java's is pretty lame. try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { // Ignore exceptions, which only result in the wrong look and feel. System.out.println("GridChem.main: an exception related to the" + " look and feel was ignored."); } init(); frame.setTitle("GridChem " + Env.getVersion()); frame.getContentPane().add(oc); frame.addWindowListener(new WindowListener() { public void windowActivated(WindowEvent arg0) { } public void windowClosed(WindowEvent arg0) { } public void windowClosing(WindowEvent arg0) { if (Settings.authenticated) { GMS3.logout(); } } public void windowDeactivated(WindowEvent arg0) { } public void windowDeiconified(WindowEvent arg0) { } public void windowIconified(WindowEvent arg0) { } public void windowOpened(WindowEvent arg0) { } }); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); // Centering the frame on the screen Toolkit kit = frame.getToolkit(); Dimension screenSize = kit.getScreenSize(); int screenWidth = screenSize.width; int screenHeight = screenSize.height; Dimension windowSize = frame.getSize(); int windowWidth = windowSize.width; int windowHeight = windowSize.height; int upperLeftX = (screenWidth - windowWidth) / 2; int upperLeftY = (screenHeight - windowHeight) / 2; frame.setLocation(upperLeftX, upperLeftY); frame.setVisible(true); Trace.exit(); }
From source file:org.kchine.rpf.PoolUtils.java
public static void redirectIO() { final JTextArea area = new JTextArea(); JFrame f = new JFrame("out/err"); f.add(new JScrollPane(area), BorderLayout.CENTER); f.pack();/*from w w w . j av a 2s . co m*/ f.setVisible(true); f.setSize(500, 500); f.setLocation(100, 100); PrintStream ps = new PrintStream(new OutputStream() { public void write(final int b) throws IOException { SwingUtilities.invokeLater(new Runnable() { public void run() { area.setText(area.getText() + new String(new byte[] { (byte) b })); } }); SwingUtilities.invokeLater(new Runnable() { public void run() { area.setCaretPosition(area.getText().length()); area.repaint(); } }); } public void write(final byte[] b) throws IOException { SwingUtilities.invokeLater(new Runnable() { public void run() { area.setText(area.getText() + new String(b)); } }); SwingUtilities.invokeLater(new Runnable() { public void run() { area.setCaretPosition(area.getText().length()); area.repaint(); } }); } public void write(byte[] b, int off, int len) throws IOException { final byte[] r = new byte[len]; for (int i = 0; i < len; ++i) r[i] = b[off + i]; SwingUtilities.invokeLater(new Runnable() { public void run() { area.setText(area.getText() + new String(r)); } }); SwingUtilities.invokeLater(new Runnable() { public void run() { area.setCaretPosition(area.getText().length()); area.repaint(); } }); } }); System.setOut(ps); System.setErr(ps); }
From source file:org.openconcerto.task.TodoListPanel.java
private void initTable(int mode) { this.t.setBlockRepaint(true); this.t.setBlockEventOnColumn(true); this.model.setMode(mode); this.t.getColumnModel().getColumn(0).setCellRenderer(this.a); this.t.getColumnModel().getColumn(0).setCellEditor(this.a); this.t.setBlockEventOnColumn(true); setIconForColumn(0, this.iconTache); setIconForColumn(1, this.iconPriorite); this.t.setBlockEventOnColumn(true); this.t.getColumnModel().getColumn(1).setCellEditor(this.iconEditor); final JTextField textField = new JTextField() { @Override// ww w . j a v a 2s . co m public void paint(Graphics g) { super.paint(g); g.setColor(TodoListPanel.this.t.getGridColor()); g.fillRect(getWidth() - 19, 0, 1, getHeight()); g.setColor(new Color(250, 250, 250)); g.fillRect(getWidth() - 18, 0, 18, getHeight()); g.setColor(Color.BLACK); for (int i = 0; i < 3; i++) { int x = getWidth() - 14 + i * 4; int y = getHeight() - 5; g.fillRect(x, y, 1, 2); } } }; textField.setBorder(BorderFactory.createEmptyBorder()); final DefaultCellEditor defaultCellEditor = new DefaultCellEditor(textField); textField.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { if (e.getX() > textField.getWidth() - 19) { TodoListElement l = getTaskAt( SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), TodoListPanel.this.t)); TodoListPanel.this.t.editingCanceled(new ChangeEvent(this)); JFrame f = new JFrame(TM.tr("details")); f.setContentPane(new TodoListElementEditorPanel(l)); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setSize(500, 200); f.setLocation(50, e.getYOnScreen() + TodoListPanel.this.t.getRowHeight()); f.setVisible(true); } } }); this.t.getColumnModel().getColumn(2).setCellEditor(defaultCellEditor); this.t.getColumnModel().getColumn(3).setMaxWidth(300); this.t.getColumnModel().getColumn(3).setMinWidth(100); this.timestampTableCellEditorCreated.stopCellEditing(); this.timestampTableCellEditorDone.stopCellEditing(); this.timestampTableCellEditorDeadLine.stopCellEditing(); if (this.model.getMode() == TodoListModel.EXTENDED_MODE) { this.t.getColumnModel().getColumn(3).setCellRenderer(this.timestampTableCellRendererCreated); this.t.getColumnModel().getColumn(3).setCellEditor(this.timestampTableCellEditorCreated); this.t.getColumnModel().getColumn(4).setCellRenderer(this.timestampTableCellRendererDone); this.t.getColumnModel().getColumn(4).setCellEditor(this.timestampTableCellEditorDone); this.t.getColumnModel().getColumn(5).setCellRenderer(this.timestampTableCellRendererDeadLine); this.t.getColumnModel().getColumn(5).setCellEditor(this.timestampTableCellEditorDeadLine); } else { this.t.getColumnModel().getColumn(3).setCellRenderer(this.timestampTableCellRendererDeadLine); this.t.getColumnModel().getColumn(3).setCellEditor(this.timestampTableCellEditorDeadLine); } final TableColumn userColumn = this.t.getColumnModel() .getColumn(this.t.getColumnModel().getColumnCount() - 1); userColumn.setCellRenderer(this.userTableCellRenderer); userColumn.setMaxWidth(150); userColumn.setMinWidth(100); t.setEnabled(false); initUserCellEditor(userColumn); this.t.setBlockEventOnColumn(false); this.t.setBlockRepaint(false); this.t.getColumnModel().getColumn(1).setCellRenderer(this.iconRenderer); // Better look this.t.setShowHorizontalLines(false); this.t.setGridColor(new Color(230, 230, 230)); this.t.setRowHeight(new JTextField(" ").getPreferredSize().height + 4); AlternateTableCellRenderer.UTILS.setAllColumns(this.t); this.t.repaint(); }