Java Code Examples for java.awt.GraphicsEnvironment#getCenterPoint()
The following examples show how to use
java.awt.GraphicsEnvironment#getCenterPoint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JIntellitypeDemo.java From jintellitype with Apache License 2.0 | 6 votes |
/** * Centers window on desktop. * <p> * * @param aFrame the Frame to center */ private static void center(JFrame aFrame) { final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); final Point centerPoint = ge.getCenterPoint(); final Rectangle bounds = ge.getMaximumWindowBounds(); final int w = Math.min(aFrame.getWidth(), bounds.width); final int h = Math.min(aFrame.getHeight(), bounds.height); final int x = centerPoint.x - (w / 2); final int y = centerPoint.y - (h / 2); aFrame.setBounds(x, y, w, h); if ((w == bounds.width) && (h == bounds.height)) { aFrame.setExtendedState(Frame.MAXIMIZED_BOTH); } aFrame.validate(); }
Example 2
Source File: Console.java From AML-Project with Apache License 2.0 | 6 votes |
public Console() { super(); this.setTitle("Console"); this.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); console = new JTextArea(25,50); console.setEditable(false); out = new ConsoleOutputStream(console); stdout = System.out; stderr = System.err; System.setOut(new PrintStream(out, true)); System.setErr(new PrintStream(out, true)); JScrollPane scroll = new JScrollPane(console, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); DefaultCaret caret = (DefaultCaret)console.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); add(scroll); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); this.pack(); GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment(); int left = g.getCenterPoint().x - (int)(this.getPreferredSize().width / 2); this.setLocation(left, 0); }
Example 3
Source File: EvaluateAlignment.java From AML-Project with Apache License 2.0 | 5 votes |
public EvaluateAlignment() { super(); //Set the title and modality type this.setTitle("Evaluate Alignment"); this.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); selectRef = new JButton("Select Reference Alignment"); selectRef.addActionListener(this); refPath = new JTextArea(1,30); refPath.setEditable(false); JPanel selectPanel = new JPanel(); selectPanel.add(selectRef); selectPanel.add(refPath); cancel = new JButton("Cancel"); cancel.addActionListener(this); evaluate = new JButton("Evaluate"); evaluate.setEnabled(false); evaluate.addActionListener(this); JPanel buttonPanel = new JPanel(); buttonPanel.add(cancel); buttonPanel.add(evaluate); JPanel dialogPanel = new JPanel(); dialogPanel.setLayout(new BoxLayout(dialogPanel, BoxLayout.PAGE_AXIS)); dialogPanel.add(selectPanel); dialogPanel.add(buttonPanel); add(dialogPanel); this.pack(); GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment(); int left = g.getCenterPoint().x - (int)(this.getPreferredSize().width / 2); this.setLocation(left, 0); this.setVisible(true); }
Example 4
Source File: SearchAlignment.java From AML-Project with Apache License 2.0 | 4 votes |
public SearchAlignment() { super(); this.setTitle("Search Alignment"); this.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); this.setPreferredSize(new Dimension(700,140)); aml = AML.getInstance(); //The containing panel dialogPanel = new JPanel(); cl = new CardLayout(); dialogPanel.setLayout(cl); //The search panel JLabel desc = new JLabel("Enter Search Term: (min 3 characters)"); Font font = desc.getFont(); boldFont = new Font(font.getFontName(), Font.BOLD, font.getSize()); desc.setFont(boldFont); JPanel labelPanel = new JPanel(); labelPanel.add(desc); Alignment a = AML.getInstance().getAlignment(); int total = a.size(); mappings = new ArrayList<String>(total); for(int i = 0; i < total; i++) { Mapping m = a.get(i); String map = aml.getSource().getName(m.getSourceId()); map += " = "; map += aml.getTarget().getName(m.getTargetId()); mappings.add(map); } searchField = new JTextArea(1,60); searchField.setEditable(true); KeyStroke keyStroke = KeyStroke.getKeyStroke("ENTER"); Object actionKey = searchField.getInputMap( JComponent.WHEN_FOCUSED).get(keyStroke); searchField.getActionMap().put(actionKey, wrapper); AutoCompleteDecorator.decorate(searchField,mappings,false); JPanel selectionPanel = new JPanel(); selectionPanel.add(searchField); cancel = new JButton("Cancel"); cancel.setPreferredSize(new Dimension(70,28)); cancel.addActionListener(this); find = new JButton("Find"); find.setPreferredSize(new Dimension(70,28)); find.addActionListener(this); JPanel buttonPanel = new JPanel(); buttonPanel.add(cancel); buttonPanel.add(find); searchPanel = new JPanel(); searchPanel.setLayout(new BoxLayout(searchPanel, BoxLayout.PAGE_AXIS)); searchPanel.add(labelPanel); searchPanel.add(selectionPanel); searchPanel.add(buttonPanel); dialogPanel.add(searchPanel, "Search"); cl.show(dialogPanel, "Search"); this.add(dialogPanel); this.pack(); GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment(); int left = g.getCenterPoint().x - (int)(this.getPreferredSize().width / 2); this.setLocation(left, 0); this.setVisible(true); }
Example 5
Source File: OpenOntologies.java From AML-Project with Apache License 2.0 | 4 votes |
public OpenOntologies() { super(); aml = AML.getInstance(); this.setTitle("Open Ontologies"); this.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); selectSource = new JButton("Select Source Ontology"); selectSource.setMinimumSize(new Dimension(175,28)); selectSource.setPreferredSize(new Dimension(175,28)); selectSource.addActionListener(this); sourcePath = new JTextArea(1,30); sourcePath.setEditable(false); sourcePanel = new JPanel(); sourcePanel.add(selectSource); sourcePanel.add(sourcePath); selectTarget = new JButton("Select Target Ontology"); selectTarget.setMinimumSize(new Dimension(175,28)); selectTarget.setPreferredSize(new Dimension(175,28)); selectTarget.addActionListener(this); targetPath = new JTextArea(1,30); targetPath.setEditable(false); targetPanel = new JPanel(); targetPanel.add(selectTarget); targetPanel.add(targetPath); cancel = new JButton("Cancel"); cancel.setPreferredSize(new Dimension(70,28)); cancel.addActionListener(this); open = new JButton("Open"); open.setPreferredSize(new Dimension(70,28)); open.setEnabled(false); open.addActionListener(this); buttonPanel = new JPanel(); buttonPanel.add(cancel); buttonPanel.add(open); dialogPanel = new JPanel(); dialogPanel.setLayout(new BoxLayout(dialogPanel, BoxLayout.PAGE_AXIS)); dialogPanel.add(sourcePanel); dialogPanel.add(targetPanel); dialogPanel.add(buttonPanel); add(dialogPanel); this.pack(); GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment(); int left = g.getCenterPoint().x - (int)(this.getPreferredSize().width / 2); this.setLocation(left, 0); this.setVisible(true); }
Example 6
Source File: ViewMapping.java From AML-Project with Apache License 2.0 | 4 votes |
private void refresh() { a = aml.getAlignment(); mapping = aml.getActiveMapping(); m = a.get(mapping); sourceId = m.getSourceId(); targetId = m.getTargetId(); t = uris.getType(sourceId); //Set the title and modality this.setTitle(m.toGUI()); this.setModalityType(ModalityType.APPLICATION_MODAL); //Setup the Tabbed Pane tabbedPane = new JTabbedPane(); tabbedPane.setBackground(AMLColor.WHITE); //Add the graph buildGraph(); if(mappingViewer != null) { tabbedPane.addTab("Graph View", mappingViewer); mappingViewer.mouseClicked(); } else tabbedPane.addTab("Graph View", new JPanel()); JLabel lab1 = new JLabel("Graph View",SwingConstants.CENTER); lab1.setPreferredSize(new Dimension(120, 15)); tabbedPane.setTabComponentAt(0, lab1); //Add the details buildDetailPanel(); tabbedPane.addTab("Details", details); JLabel lab2 = new JLabel("Details",SwingConstants.CENTER); lab2.setPreferredSize(new Dimension(120, 15)); tabbedPane.setTabComponentAt(1, lab2); //Add the issues buildConflictPanel(); tabbedPane.addTab("Status & Conflicts", conflicts); JLabel lab3 = new JLabel("Status & Conflicts",SwingConstants.CENTER); lab3.setPreferredSize(new Dimension(120, 15)); tabbedPane.setTabComponentAt(2, lab3); //Set the tabbed pane as the content pane setContentPane(tabbedPane); //Wrap up this.pack(); GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment(); int left = g.getCenterPoint().x - (int)(this.getPreferredSize().width / 2); this.setLocation(left, 0); this.setVisible(true); }
Example 7
Source File: ViewOptions.java From AML-Project with Apache License 2.0 | 4 votes |
public ViewOptions() { super(); aml = AML.getInstance(); this.setTitle("Graph Options"); this.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); languageLabel = new JLabel("Label Language:"); Vector<String> languages = new Vector<String>(aml.getLanguages()); languageSelector = new JComboBox<String>(languages); languageSelector.setSelectedItem(aml.getLabelLanguage()); languagePanel = new JPanel(); languagePanel.add(languageLabel); languagePanel.add(languageSelector); ancestors = new JCheckBox("View Ancestors"); ancestors.setMnemonic(KeyEvent.VK_C); ancestors.setSelected(AML.getInstance().showAncestors()); descendants = new JCheckBox("View Descendants"); descendants.setMnemonic(KeyEvent.VK_C); descendants.setSelected(AML.getInstance().showDescendants()); directionPanel = new JPanel(); directionPanel.add(ancestors); directionPanel.add(descendants); classLabel = new JLabel("Class extension (edges):"); classSelector = new JComboBox<Integer>(DIST); classSelector.setSelectedIndex(AML.getInstance().getClassDistance()); classPanel = new JPanel(); classPanel.add(classLabel); classPanel.add(classSelector); individualLabel = new JLabel("Individual extension (edges):"); individualSelector = new JComboBox<Integer>(DIST); individualSelector.setSelectedIndex(AML.getInstance().getIndividualDistance()); individualPanel = new JPanel(); individualPanel.add(individualLabel); individualPanel.add(individualSelector); cancel = new JButton("Cancel"); cancel.setPreferredSize(new Dimension(70,28)); cancel.addActionListener(this); ok = new JButton("OK"); ok.setPreferredSize(new Dimension(70,28)); ok.addActionListener(this); buttonPanel = new JPanel(); buttonPanel.add(cancel); buttonPanel.add(ok); dialogPanel = new JPanel(); dialogPanel.setPreferredSize(new Dimension(300,150)); dialogPanel.setLayout(new BoxLayout(dialogPanel, BoxLayout.PAGE_AXIS)); if(!aml.getLanguageSetting().equals(LanguageSetting.SINGLE)) dialogPanel.add(languagePanel); dialogPanel.add(directionPanel); dialogPanel.add(classPanel); dialogPanel.add(individualPanel); dialogPanel.add(buttonPanel); add(dialogPanel); this.pack(); GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment(); int left = g.getCenterPoint().x - (int)(this.getPreferredSize().width / 2); this.setLocation(left, 0); this.setVisible(true); }