List of usage examples for javax.swing BoxLayout Y_AXIS
int Y_AXIS
To view the source code for javax.swing BoxLayout Y_AXIS.
Click Source Link
From source file:marytts.tools.voiceimport.DatabaseImportMain.java
protected void setupGUI() { // A scroll pane containing one labelled checkbox per component, // and a "run selected components" button below. GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridC = new GridBagConstraints(); getContentPane().setLayout(gridBagLayout); JPanel checkboxPane = new JPanel(); checkboxPane.setLayout(new BoxLayout(checkboxPane, BoxLayout.Y_AXIS)); //checkboxPane.setPreferredSize(new Dimension(300, 300)); int compIndex = 0; for (int j = 0; j < groups2Comps.length; j++) { String[] nextGroup = groups2Comps[j]; JPanel groupPane = new JPanel(); groupPane.setLayout(new BoxLayout(groupPane, BoxLayout.Y_AXIS)); groupPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(nextGroup[0]), BorderFactory.createEmptyBorder(1, 1, 1, 1))); for (int i = 1; i < nextGroup.length; i++) { JButton configButton = new JButton(); Icon configIcon = new ImageIcon(DatabaseImportMain.class.getResource("configure.png"), "Configure"); configButton.setIcon(configIcon); configButton.setPreferredSize(new Dimension(configIcon.getIconWidth(), configIcon.getIconHeight())); configButton.addActionListener(new ConfigButtonActionListener(nextGroup[i])); configButton.setBorderPainted(false); //System.out.println("Adding checkbox for "+components[i].getClass().getName()); checkboxes[compIndex] = new JCheckBox(nextGroup[i]); checkboxes[compIndex].setFocusable(true); //checkboxes[i].setPreferredSize(new Dimension(200, 30)); JPanel line = new JPanel(); line.setLayout(new BorderLayout(5, 0)); line.add(configButton, BorderLayout.WEST); line.add(checkboxes[compIndex], BorderLayout.CENTER); groupPane.add(line);/*w ww .java 2s . c om*/ compIndex++; } checkboxPane.add(groupPane); } gridC.gridx = 0; gridC.gridy = 0; gridC.fill = GridBagConstraints.BOTH; JScrollPane scrollPane = new JScrollPane(checkboxPane); scrollPane.setPreferredSize(new Dimension(450, 300)); gridBagLayout.setConstraints(scrollPane, gridC); getContentPane().add(scrollPane); JButton helpButton = new JButton("Help"); helpButton.setMnemonic(KeyEvent.VK_H); helpButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { displayHelpGUI(); } }); JButton settingsButton = new JButton("Settings"); settingsButton.setMnemonic(KeyEvent.VK_S); settingsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { currentComponent = "Global properties"; displaySettingsGUI(); } }); runButton = new JButton("Run"); runButton.setMnemonic(KeyEvent.VK_R); runButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { runSelectedComponents(); } }); JButton quitAndSaveButton = new JButton("Quit"); quitAndSaveButton.setMnemonic(KeyEvent.VK_Q); quitAndSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); gridC.gridy = 1; JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); //buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS)); //runButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(runButton); //helpButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(helpButton); //settingsButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(settingsButton); //buttonPanel.add(Box.createHorizontalGlue()); //quitAndSaveButton.setAlignmentX(JButton.RIGHT_ALIGNMENT); buttonPanel.add(quitAndSaveButton); gridBagLayout.setConstraints(buttonPanel, gridC); getContentPane().add(buttonPanel); //getContentPane().setPreferredSize(new Dimension(300, 300)); // End program when closing window: addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); }
From source file:CutAndPasteDemo.java
public CutAndPasteDemo() { super("Cut And Paste Demonstration"); clipboard = getToolkit().getSystemClipboard(); GraphicsEnvironment.getLocalGraphicsEnvironment(); Font font = new Font("LucidaSans", Font.PLAIN, 15); textArea1 = new JTextArea(davidMessage + andyMessage, 5, 25); textArea2 = new JTextArea("<Paste text here>", 5, 25); textArea1.setFont(font);/*www . j a v a2s .c o m*/ textArea2.setFont(font); JPanel jPanel = new JPanel(); JMenuBar jMenuBar = new JMenuBar(); JMenuItem cutItem = new JMenuItem("Cut"); JMenuItem pasteItem = new JMenuItem("Paste"); JMenu jMenu = new JMenu("Edit"); jMenu.add(cutItem); jMenu.add(pasteItem); cutItem.addActionListener(new CutActionListener()); pasteItem.addActionListener(new PasteActionListener()); jMenuBar.add(jMenu); jPanel.add(jMenuBar); jPanel.setLayout(new BoxLayout(jPanel, BoxLayout.Y_AXIS)); jPanel.add(textArea1); jPanel.add(Box.createRigidArea(new Dimension(0, 10))); jPanel.add(textArea2); getContentPane().add(jPanel, BorderLayout.CENTER); }
From source file:edu.ucla.stat.SOCR.chart.demo.PowerTransformHistogramChart.java
protected void initGraphPanel() { //System.out.println("initGraphPanel called"); graphPanel = new JPanel(); graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); JFreeChart chart = createEmptyChart(null); //create a empty graph first chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y - 100)); graphPanel.add(chartPanel);//from w w w . jav a 2 s .c om graphPanel.add(sliderPanel); graphPanel.validate(); }
From source file:view.App.java
private void initGUI() { try {//from w w w. j av a2s. c o m { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); getContentPane().add(jPanel1, BorderLayout.CENTER); jPanel1.setPreferredSize(new java.awt.Dimension(901, 398)); { jPanel2 = new JPanel(); BoxLayout jPanel2Layout = new BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS); jPanel2.setLayout(jPanel2Layout); jPanel1.add(jPanel2, BorderLayout.WEST); jPanel2.setPreferredSize(new java.awt.Dimension(292, 446)); { jPanel5 = new JPanel(); jPanel2.add(jPanel5); jPanel5.setPreferredSize(new java.awt.Dimension(292, 109)); { { jTextArea1 = new JTextArea(); jTextArea1.setWrapStyleWord(true); jTextArea1.setLineWrap(true); DefaultCaret caret = (DefaultCaret) jTextArea1.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); jTextArea1.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent evt) { if (jTable1.getModel().getRowCount() == 0 && !jButton1.isEnabled()) { jButton1.setEnabled(true); jTextArea1.setText(""); } } }); JScrollPane sp = new JScrollPane(); sp.setPreferredSize(new java.awt.Dimension(281, 97)); sp.setViewportView(jTextArea1); jPanel5.add(sp, BorderLayout.CENTER); } } } { jPanel4 = new JPanel(); jPanel2.add(jPanel4); FlowLayout jPanel4Layout = new FlowLayout(); jPanel4Layout.setAlignment(FlowLayout.RIGHT); jPanel4.setPreferredSize(new java.awt.Dimension(292, 45)); jPanel4.setSize(102, 51); jPanel4.setLayout(jPanel4Layout); { jButton1 = new JButton(); jPanel4.add(jButton1); jButton1.setText("Get Quotes"); jButton1.setSize(100, 50); jButton1.setPreferredSize(new java.awt.Dimension(100, 26)); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // String tickerStr = jTextArea1.getText(); if (tickerStr.equals("") || tickerStr.equals(null) || tickerStr.equals(" ")) { jTextArea1.setText(" "); return; } StringTokenizer tokenizer = new StringTokenizer(tickerStr, " "); String[] tickers = new String[tokenizer.countTokens()]; int i = 0; while (tokenizer.hasMoreTokens()) { tickers[i] = tokenizer.nextToken(); i++; } try { Controller.getQuotes(tickers); } catch (CloneNotSupportedException e) { JOptionPane.showMessageDialog(jPanel1, " "); } jButton1.setEnabled(false); } }); } } { jPanel6 = new JPanel(); BorderLayout jPanel6Layout = new BorderLayout(); jPanel6.setLayout(jPanel6Layout); jPanel2.add(jPanel6); { jScrollPane1 = new JScrollPane(); jPanel6.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(292, 341)); { TableModel jTable1Model = new DefaultTableModel(null, new String[] { "", "MA Value", "", "MA Value" }); jTable1 = new JTable(); jScrollPane1.setViewportView(jTable1); jTable1.setModel(jTable1Model); jTable1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } } } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jPanel1.add(jPanel3, BorderLayout.CENTER); { // chart = ChartFactory.createLineChart(" ", "dates", "correlation ratio", null, // PlotOrientation.VERTICAL, true, true, false); // ChartPanel chartPanel = new ChartPanel(chart); // chartPanel.setPreferredSize( new java.awt.Dimension( 560 , 367 ) ); // jPanel3.add(chartPanel); } { } } } this.setSize(966, 531); { jMenuBar1 = new JMenuBar(); setJMenuBar(jMenuBar1); { jMenu3 = new JMenu(); jMenuBar1.add(jMenu3); jMenu3.setText("File"); { // newFileMenuItem = new JMenuItem(); // jMenu3.add(newFileMenuItem); // newFileMenuItem.setText("New"); // newFileMenuItem.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent evt) { //// jTextArea1.setText(""); //// DefaultTableModel model = (DefaultTableModel)jTable1.getModel(); //// model.setRowCount(0); //// Controller.clearPortfolio(); // } // }); } { jSeparator2 = new JSeparator(); jMenu3.add(jSeparator2); } { exitMenuItem = new JMenuItem(); jMenu3.add(exitMenuItem); exitMenuItem.setText("Exit"); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { int action = JOptionPane.showConfirmDialog(jPanel1, " ?", "Confirm Exit", JOptionPane.OK_CANCEL_OPTION); if (action == JOptionPane.OK_OPTION) System.exit(0); } }); } } { jMenu4 = new JMenu(); jMenuBar1.add(jMenu4); jMenu4.setText("Edit"); { cutMenuItem = new JMenuItem(); jMenu4.add(cutMenuItem); cutMenuItem.setText("Cut"); cutMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String txt = jTextArea1.getText(); StringSelection selection = new StringSelection(txt); Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard(); clp.setContents(selection, null); jTextArea1.setText(""); } }); } { copyMenuItem = new JMenuItem(); jMenu4.add(copyMenuItem); copyMenuItem.setText("Copy"); copyMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { String txt = jTextArea1.getText(); StringSelection selection = new StringSelection(txt); Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard(); clp.setContents(selection, null); } }); } { pasteMenuItem = new JMenuItem(); jMenu4.add(pasteMenuItem); pasteMenuItem.setText("Paste"); pasteMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard(); try { String data = (String) clp.getData(DataFlavor.stringFlavor); jTextArea1.setText(data); } catch (UnsupportedFlavorException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); } } { jMenu5 = new JMenu(); jMenuBar1.add(jMenu5); jMenu5.setText("Help"); { helpMenuItem = new JMenuItem(); jMenu5.add(helpMenuItem); helpMenuItem.setText("About"); helpMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { JOptionPane.showMessageDialog(jPanel1, " . r.zhumagulov@gmail.com", "About", JOptionPane.PLAIN_MESSAGE); } }); } } } } catch (Exception e) { e.printStackTrace(); } }
From source file:it.iit.genomics.cru.igb.bundles.mi.view.StructuresPanel.java
public StructuresPanel(IgbService service, String label) { super("MI Structures", "MI Structures", "Display structure", true); igbLogger = IGBLogger.getInstance(label); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // Create hidden JmolFrame jmolFrame = new JFrame(); jmolPanel = new JmolPanel(); jmolPanel.setPreferredSize(new Dimension(500, 500)); Box jmolBox = new Box(BoxLayout.Y_AXIS); Box jmolButtonBox = new Box(BoxLayout.X_AXIS); jmolFrame.add(jmolBox);//w w w .j a v a2s. co m jmolBox.add(jmolPanel); jmolBox.add(jmolButtonBox); jmolButtonBox.add(new JLabel("Display type:")); ButtonGroup displayGroup = new ButtonGroup(); JRadioButton cartoonButton = new JRadioButton(JMOL_DISPLAY_CARTOON); JRadioButton ballAndSticksButton = new JRadioButton(JMOL_DISPLAY_BALL_AND_STICK); JmolDisplayListener listener = new JmolDisplayListener(); cartoonButton.addActionListener(listener); ballAndSticksButton.addActionListener(listener); displayGroup.add(cartoonButton); displayGroup.add(ballAndSticksButton); jmolButtonBox.add(cartoonButton); jmolButtonBox.add(ballAndSticksButton); ballAndSticksButton.setSelected(true); jmolFrame.pack(); jmolFrame.setVisible(false); jmolButton.addActionListener(new JmolActionListener()); jmolButton.setIcon(new ImageIcon(getClass().getResource("/jmol.jpg"))); linkButton.addActionListener(new ExternalLinkActionListener()); linkButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/searchweb.png")); StructureTableModel model = new StructureTableModel(new ArrayList<StructureItem>(0)); structureList = new StructureTable(model, service); structureList.setTableHeader(null); structureList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane structureListPane = new JScrollPane(structureList); add(structureListPane); }
From source file:com.intel.stl.ui.common.view.DistributionPiePanel.java
public void setLabels(String[] itemNames, ImageIcon[] icons, int labelColumns) { if (icons.length != itemNames.length) { throw new IllegalArgumentException( "Inconsistent number of items. " + " itemNames=" + itemNames.length + " icons=" + icons.length); }/*from w w w . ja va 2s . c om*/ labels = new JLabel[icons.length]; for (int i = 0; i < icons.length; i++) { labels[i] = new JLabel(itemNames[i], icons[i], JLabel.LEFT); } int rows = 1; if (labelColumns <= 0) { labelPanel.setLayout(new FlowLayout()); for (JLabel label : labels) { labelPanel.add(label); } } else { BoxLayout layout = new BoxLayout(labelPanel, BoxLayout.X_AXIS); labelPanel.setLayout(layout); JPanel[] columns = new JPanel[labelColumns]; for (int i = 0; i < columns.length; i++) { labelPanel.add(Box.createHorizontalGlue()); columns[i] = new JPanel(); columns[i].setOpaque(false); columns[i].setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3)); BoxLayout cLayout = new BoxLayout(columns[i], BoxLayout.Y_AXIS); columns[i].setLayout(cLayout); labelPanel.add(columns[i]); } labelPanel.add(Box.createHorizontalGlue()); rows = (int) Math.ceil((double) labels.length / labelColumns); int index = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < labelColumns; j++) { columns[i].add(index < labels.length ? labels[index] : Box.createGlue()); index += 1; } } } }
From source file:BoxAlignmentDemo.java
protected JPanel createLabelAndComponent(boolean doItRight) { JPanel pane = new JPanel(); JComponent component = new JPanel(); Dimension size = new Dimension(150, 100); component.setMaximumSize(size);//from w w w.j a va 2 s . com component.setPreferredSize(size); component.setMinimumSize(size); TitledBorder border = new TitledBorder(new LineBorder(Color.black), "A JPanel", TitledBorder.CENTER, TitledBorder.BELOW_TOP); border.setTitleColor(Color.black); component.setBorder(border); JLabel label = new JLabel("This is a JLabel"); String title; if (doItRight) { title = "Matched"; label.setAlignmentX(CENTER_ALIGNMENT); } else { title = "Mismatched"; } pane.setBorder(BorderFactory.createTitledBorder(title)); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); pane.add(label); pane.add(component); return pane; }
From source file:edu.ucla.stat.SOCR.chart.SuperCategoryChart_vertical.java
public void setChart() { // update graph // System.out.println("setChart called"); graphPanel.removeAll();/*w w w . j a v a 2 s .co m*/ graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y)); if (legendPanelOn) { JFreeChart chart2 = createLegendChart(createLegend(dataset)); legendPanel = new ChartPanel(chart2, false); //legendPanel.setPreferredSize(new Dimension(CHART_SIZE_X,CHART_SIZE_Y*2/3)); } graphPanel.add(chartPanel); JScrollPane legendPane = new JScrollPane(legendPanel); if (legendPanelOn) { legendPane.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 5)); graphPanel.add(legendPane); } graphPanel.validate(); // get the GRAPH panel to the front if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) != ALL) { tabbedPanelContainer.setSelectedIndex(tabbedPanelContainer.indexOfComponent(graphPanel)); graphPanel.removeAll(); graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); graphPanel.add(chartPanel); if (legendPanelOn) { legendPane = new JScrollPane(legendPanel); legendPane.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 5)); graphPanel.add(legendPane); } graphPanel.validate(); } else { graphPanel2.removeAll(); chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 3)); //legendPanel.setPreferredSize(new Dimension(CHART_SIZE_X*2/3,CHART_SIZE_Y*2/5)); graphPanel2.add(chartPanel); if (legendPanelOn) { legendPane = new JScrollPane(legendPanel); legendPane.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 5)); graphPanel2.add(legendPane); } graphPanel2.validate(); summaryPanel.validate(); } }
From source file:es.emergya.ui.gis.popups.SDSDialog.java
public SDSDialog(Recurso r) { super();/*from ww w . ja va2 s . c o m*/ setAlwaysOnTop(true); setResizable(false); iconTransparente = LogicConstants.getIcon("48x48_transparente"); iconEnviando = LogicConstants.getIcon("anim_enviando"); destino = r; setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { super.windowClosing(e); cancel.doClick(); } }); // setPreferredSize(new Dimension(400, 150)); setTitle(i18n.getString("window.sds.titleBar") + " " + r.getIdentificador()); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } JPanel base = new JPanel(); base.setBackground(Color.WHITE); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); // Icono del titulo JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); final JLabel titleLabel = new JLabel(i18n.getString("window.sds.title"), LogicConstants.getIcon("tittleventana_icon_enviarsds"), JLabel.LEFT); titleLabel.setFont(LogicConstants.deriveBoldFont(12f)); title.add(titleLabel); title.setOpaque(false); base.add(title); // Espacio para el mensaje sds = new JTextArea(7, 40); sds.setLineWrap(true); final JScrollPane sdsp = new JScrollPane(sds); sdsp.setOpaque(false); sdsp.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.BLACK), i18n.getString("Admin.message") + "\t (0/" + maxChars + ")")); sds.setDocument(new PlainDocument() { @Override public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { if (this.getLength() + str.length() <= maxChars) { super.insertString(offs, str, a); } } }); sds.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateChars(e); } @Override public void insertUpdate(DocumentEvent e) { updateChars(e); } @Override public void changedUpdate(DocumentEvent e) { updateChars(e); } private void updateChars(DocumentEvent e) { ((TitledBorder) sdsp.getBorder()).setTitle( i18n.getString("Admin.message") + "\t (" + sds.getText().length() + "/" + maxChars + ")"); sdsp.repaint(); send.setEnabled(!sds.getText().isEmpty()); notification.setForeground(Color.WHITE); notification.setText("PLACEHOLDER"); } }); base.add(sdsp); // Area para mensajes JPanel notificationArea = new JPanel(); notificationArea.setOpaque(false); notification = new JLabel("TEXT"); notification.setForeground(Color.WHITE); notificationArea.add(notification); base.add(notificationArea); JPanel buttons = new JPanel(); buttons.setOpaque(false); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); send = new JButton(i18n.getString("Buttons.send"), LogicConstants.getIcon("ventanacontextual_button_enviarsds")); send.addActionListener(this); send.setEnabled(false); buttons.add(send); buttons.add(Box.createHorizontalGlue()); progressIcon = new JLabel(iconTransparente); buttons.add(progressIcon); buttons.add(Box.createHorizontalGlue()); cancel = new JButton(i18n.getString("Buttons.cancel"), LogicConstants.getIcon("button_cancel")); cancel.addActionListener(this); buttons.add(cancel); base.add(buttons); getContentPane().add(base); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) x = ((parentSize.width - mySize.width) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > mySize.height) y = ((parentSize.height - mySize.height) / 2) + topLeft.y; else y = topLeft.y; setLocation(x, y); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent arg0) { deleteErrorMessage(); } @Override public void windowClosed(WindowEvent arg0) { deleteErrorMessage(); } private void deleteErrorMessage() { SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { if (bandejaSalida != null) { MessageGenerator.remove(bandejaSalida.getId()); } bandejaSalida = null; return null; } @Override protected void done() { super.done(); SDSDialog.this.sds.setText(""); SDSDialog.this.sds.setEnabled(true); SDSDialog.this.sds.repaint(); SDSDialog.this.progressIcon.setIcon(iconTransparente); SDSDialog.this.progressIcon.repaint(); SDSDialog.this.notification.setText(""); SDSDialog.this.notification.repaint(); } }; sw.execute(); } }); }
From source file:AlternateAppearanceScopeTest.java
public void init() { Container contentPane = getContentPane(); Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); contentPane.add("Center", c); BranchGroup scene = createSceneGraph(); // SimpleUniverse is a Convenience Utility class u = new SimpleUniverse(c); // add mouse behaviors to the viewingPlatform ViewingPlatform viewingPlatform = u.getViewingPlatform(); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. viewingPlatform.setNominalViewingTransform(); OrbitBehavior orbit = new OrbitBehavior(c, OrbitBehavior.REVERSE_ALL); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); orbit.setSchedulingBounds(bounds);// www .j av a 2s . c o m viewingPlatform.setViewPlatformBehavior(orbit); u.addBranchGraph(scene); // Create GUI JPanel p = new JPanel(); BoxLayout boxlayout = new BoxLayout(p, BoxLayout.Y_AXIS); p.add(createScopingPanel()); p.add(createMaterialPanel()); p.setLayout(boxlayout); contentPane.add("South", p); }