List of usage examples for javax.swing BoxLayout X_AXIS
int X_AXIS
To view the source code for javax.swing BoxLayout X_AXIS.
Click Source Link
From source file:medsavant.uhn.cancer.UserCommentApp.java
private JPanel getOntologyTitlePanel(final VariantRecord vr, final OntologyTerm ot) { String header = ot.getID() + " - " + ot.getName(); //ontology title. JPanel ontologyTitlePanel = new JPanel(); ontologyTitlePanel.setLayout(new BoxLayout(ontologyTitlePanel, BoxLayout.X_AXIS)); ontologyTitlePanel.add(new JLabel(header)); ontologyTitlePanel.add(Box.createHorizontalGlue()); JButton replyToOntologyButton = new JButton(new ImageIcon(REPLY_TO_ONTOLOGY_ICON.getImage() .getScaledInstance(ICON_WIDTH, ICON_HEIGHT, java.awt.Image.SCALE_SMOOTH))); replyToOntologyButton.addActionListener(new ActionListener() { @Override// w ww .j av a2 s. c o m public void actionPerformed(ActionEvent ae) { replyToOntology(vr, ot); } }); ontologyTitlePanel.add(replyToOntologyButton); return ontologyTitlePanel; }
From source file:es.emergya.ui.gis.popups.RouteDialog.java
private RouteDialog() { super();/*from ww w.ja v a 2 s . co m*/ setAlwaysOnTop(true); setResizable(false); iconTransparente = LogicConstants.getIcon("48x48_transparente"); iconEnviando = LogicConstants.getIcon("anim_calculando"); try { route = new OsmDataLayer(new DataSet(), "route", File.createTempFile("route", "route")); } catch (IOException e) { log.error(e.getMessage(), e); } setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { clear.doClick(); setVisible(false); } }); setTitle(i18n.getString("window.route.titleBar")); setMinimumSize(new Dimension(400, 200)); 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)); title.setOpaque(false); final JLabel labelTitle = new JLabel(i18n.getString("window.route.title"), LogicConstants.getIcon("tittleventana_icon_calcularruta"), JLabel.LEFT); labelTitle.setFont(LogicConstants.deriveBoldFont(12.0f)); title.add(labelTitle); base.add(title); JPanel content = new JPanel(new SpringLayout()); content.setOpaque(false); // Coordenadas content.add(new JLabel(i18n.getString("window.route.origen"), JLabel.LEFT)); JPanel coords = new JPanel(new GridLayout(1, 2)); coords.setOpaque(false); fx = new JTextField(8); fx.setEditable(false); fy = new JTextField(8); fy.setEditable(false); coords.add(fy); coords.add(fx); content.add(coords); content.add(new JLabel(i18n.getString("window.route.destino"), JLabel.LEFT)); JPanel coords2 = new JPanel(new GridLayout(1, 2)); coords2.setOpaque(false); tx = new JTextField(8); tx.setEditable(false); ty = new JTextField(8); ty.setEditable(false); coords2.add(ty); coords2.add(tx); content.add(coords2); SpringUtilities.makeCompactGrid(content, 2, 2, 6, 6, 6, 6); base.add(content); // Area para mensajes JPanel notificationArea = new JPanel(); notificationArea.setOpaque(false); notification = new JLabel("PLACEHOLDER"); 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)); search = new JButton(i18n.getString("window.route.calcular"), LogicConstants.getIcon("ventanacontextual_button_calcularruta")); search.addActionListener(this); buttons.add(search); clear = new JButton(i18n.getString("window.route.limpiar"), LogicConstants.getIcon("button_limpiar")); clear.addActionListener(this); buttons.add(clear); buttons.add(Box.createHorizontalGlue()); progressIcon = new JLabel(iconTransparente); buttons.add(progressIcon); buttons.add(Box.createHorizontalGlue()); JButton 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); } }
From source file:BRHInit.java
public void showVPSPrompt(JSONArray vps) throws Exception { vps_list = vps;// w w w. j a va2 s. com if (vps_list_window == null) { vps_list_window = new JFrame("BRH Console"); vps_list_window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel top_panel = new JPanel(); vps_list_window.getContentPane().add(top_panel); top_panel.setLayout(new BoxLayout(top_panel, BoxLayout.Y_AXIS)); top_panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); Vector values = new Vector(); for (int idx = 0; idx < vps_list.length(); ++idx) { JSONArray row = vps_list.getJSONArray(idx); values.addElement(row.getString(1)); } vps_list_box = new JList(values); top_panel.add(new JScrollPane(vps_list_box)); vps_list_box.setVisibleRowCount(10); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); JPanel col_panel = new JPanel(); p.add(col_panel); col_panel.setLayout(new BoxLayout(col_panel, BoxLayout.Y_AXIS)); col_panel.add(new JLabel("email")); col_panel.add(Box.createRigidArea(new Dimension(0, 5))); col_panel.add(new JLabel("password")); p.add(Box.createRigidArea(new Dimension(5, 0))); col_panel = new JPanel(); p.add(col_panel); col_panel.setLayout(new BoxLayout(col_panel, BoxLayout.Y_AXIS)); col_panel.add(email = new JTextField(20)); col_panel.add(Box.createRigidArea(new Dimension(0, 5))); col_panel.add(password = new JPasswordField()); top_panel.add(Box.createRigidArea(new Dimension(0, 10))); p = new JPanel(); top_panel.add(p); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.add(Box.createHorizontalGlue()); p.add(vps_list_ok = new JButton("OK")); p.add(Box.createRigidArea(new Dimension(5, 0))); p.add(vps_list_cancel = new JButton("Cancel")); p.add(Box.createHorizontalGlue()); vps_list_ok.addActionListener(this); vps_list_cancel.addActionListener(this); vps_list_window.pack(); } vps_list_window.setVisible(true); }
From source file:fungus.JungObserver.java
public JungObserver(String name) { this.name = name; this.hyphadataPid = Configuration.getPid(name + "." + PAR_HYPHADATA_PROTO); this.hyphalinkPid = Configuration.getPid(name + "." + PAR_HYPHALINK_PROTO); this.mycocastPid = Configuration.getPid(name + "." + PAR_MYCOCAST_PROTO); self = this;// w w w. j a v a2s . c o m mainThread = Thread.currentThread(); graph = new DirectedSparseGraph<MycoNode, String>(); edu.uci.ics.jung.algorithms.layout.SpringLayout<MycoNode, String> layout = new edu.uci.ics.jung.algorithms.layout.SpringLayout<MycoNode, String>( graph); layout.setSize(new Dimension(650, 650)); layout.setRepulsionRange(75); //layout.setForceMultiplier(0.75); layout.setStretch(0.85); Dimension preferredSize = new Dimension(650, 650); VisualizationModel<MycoNode, String> visualizationModel = new DefaultVisualizationModel<MycoNode, String>( layout, preferredSize); visualizer = new VisualizationViewer<MycoNode, String>(visualizationModel, preferredSize); visualizer.addGraphMouseListener(new InfoFrameVertexListener()); //visualizer = new BasicVisualizationServer<Node,String>(layout); //visualizer.setPreferredSize(new Dimension(650, 650)); Transformer<MycoNode, String> nodeLabeller = new Transformer<MycoNode, String>() { public String transform(MycoNode n) { return Long.toString(n.getID()); } }; final Shape biomassCircle = new Ellipse2D.Float(-2.5f, -2.5f, 5.0f, 5.0f); final Shape hyphaCircle = new Ellipse2D.Float(-5.0f, -5.0f, 10.0f, 10.0f); Transformer<MycoNode, Shape> shapeTransformer = new Transformer<MycoNode, Shape>() { public Shape transform(MycoNode n) { HyphaData data = n.getHyphaData(); if (data.isBiomass()) { return biomassCircle; } else { return hyphaCircle; } } }; Transformer<MycoNode, Paint> nodeFillRenderer = new Transformer<MycoNode, Paint>() { public Paint transform(MycoNode n) { HyphaData data = (HyphaData) n.getProtocol(hyphadataPid); if (!n.isUp()) { return Color.BLACK; } if (data.isBiomass()) { return Color.BLUE; } else if (data.isExtending()) { return Color.RED; } else if (data.isBranching()) { return Color.YELLOW; } else { return Color.GREEN; } } }; Transformer<MycoNode, Paint> nodeShapeRenderer = new Transformer<MycoNode, Paint>() { public Paint transform(MycoNode n) { HyphaData data = (HyphaData) n.getProtocol(hyphadataPid); if (data.isBiomass()) { return Color.BLUE; } else if (data.isExtending()) { return Color.RED; } else if (data.isBranching()) { return Color.YELLOW; } else { return Color.GREEN; } } }; final Stroke biomassStroke = new BasicStroke(0.25f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f); final Stroke hyphalStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f); Transformer<String, Stroke> edgeStrokeTransformer = new Transformer<String, Stroke>() { public Stroke transform(String s) { Pair<MycoNode> vertices = graph.getEndpoints(s); HyphaData firstData = vertices.getFirst().getHyphaData(); HyphaData secondData = vertices.getSecond().getHyphaData(); if (firstData.isHypha() && secondData.isHypha()) { return hyphalStroke; } else { return biomassStroke; } } }; visualizer.getRenderContext().setVertexFillPaintTransformer(nodeFillRenderer); visualizer.getRenderContext().setVertexShapeTransformer(shapeTransformer); visualizer.getRenderContext().setVertexLabelTransformer(nodeLabeller); visualizer.setVertexToolTipTransformer(new ToStringLabeller<MycoNode>()); visualizer.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = frame.getContentPane(); c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS)); //JScrollPane scrollPane = new JScrollPane(visualizer); //c.add(scrollPane); c.add(visualizer); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); JButton pauseButton = new JButton("pause"); ActionListener pauser = new ActionListener() { public void actionPerformed(ActionEvent e) { //e.consume(); synchronized (self) { stepBlocked = true; noBlock = false; //self.notifyAll(); } } }; pauseButton.addActionListener(pauser); JButton stepButton = new JButton("step"); ActionListener stepper = new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Clicked!\n"); //e.consume(); synchronized (self) { stepBlocked = false; self.notifyAll(); } } }; stepButton.addActionListener(stepper); JButton runButton = new JButton("run"); ActionListener runner = new ActionListener() { public void actionPerformed(ActionEvent e) { //e.consume(); synchronized (self) { stepBlocked = false; noBlock = true; self.notifyAll(); } } }; runButton.addActionListener(runner); buttonPane.add(pauseButton); buttonPane.add(stepButton); buttonPane.add(runButton); c.add(buttonPane); frame.pack(); frame.setVisible(true); }
From source file:com.apatar.ui.JPublishToApatarDialog.java
private void createDialog() { GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); this.setLayout(gridbag); c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0;//w w w .j av a 2 s . c o m c.weighty = 0.0; c.fill = GridBagConstraints.HORIZONTAL; //c.insets = new Insets(5, 5, 5, 5); JPanel panelLogin = new JPanel(); panelLogin.setBorder(new EmptyBorder(10, 10, 0, 10)); panelLogin.setLayout(new BoxLayout(panelLogin, BoxLayout.X_AXIS)); panelLogin.add(new JLabel("User Name")); panelLogin.add(Box.createHorizontalStrut(5)); panelLogin.add(username); username.setComponentPopupMenu(new JDefaultContextMenu(username)); panelLogin.add(Box.createHorizontalStrut(5)); panelLogin.add(new JLabel("Password")); panelLogin.add(Box.createHorizontalStrut(5)); panelLogin.add(password); JPanel panelForgotPassLink = new JPanel(); panelForgotPassLink.setBorder(new EmptyBorder(10, 10, 0, 10)); panelForgotPassLink.setLayout(new BoxLayout(panelForgotPassLink, BoxLayout.X_AXIS)); panelForgotPassLink.add(new JLabel("Lost your password? ")); panelForgotPassLink.add(Box.createHorizontalStrut(5)); panelForgotPassLink.add(forgotPassLinkLabel); forgotPassLinkLabel.setFont(UiUtils.NORMAL_SIZE_12_FONT); forgotPassLinkLabel.addMouseListener(new MouseHyperLinkEvent()); forgotPassLinkLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); forgotPassLinkLabel.setText( "<html><a href='http://www.apatarforge.org/profile/lostpassword.html'>Click here to retrieve it</a></html>"); JPanel panelFile = new JPanel(); panelFile.setBorder(new EmptyBorder(10, 10, 0, 10)); panelFile.setLayout(new BoxLayout(panelFile, BoxLayout.X_AXIS)); panelFile.add(selectFromFile); panelFile.add(Box.createHorizontalStrut(5)); panelFile.add(new JLabel("New File ")); panelFile.add(Box.createHorizontalStrut(5)); panelFile.add(nameFile); panelFile.add(Box.createHorizontalStrut(5)); panelFile.add(browse); nameFile.setEnabled(false); nameFile.setComponentPopupMenu(new JDefaultContextMenu(nameFile)); browse.setEnabled(false); JPanel panelLocation = new JPanel(); panelLocation.setBorder(new EmptyBorder(10, 10, 0, 10)); panelLocation.setLayout(new BoxLayout(panelLocation, BoxLayout.X_AXIS)); panelLocation.add(new JLabel("Suggest Location:")); panelLocation.add(Box.createHorizontalStrut(5)); panelLocation.add(location); JPanel panelDMName = new JPanel(); panelDMName.setBorder(new EmptyBorder(10, 10, 0, 10)); panelDMName.setLayout(new BoxLayout(panelDMName, BoxLayout.X_AXIS)); JLabel datamapNameLabel = new JLabel("DataMap Name:"); datamapNameLabel.setBorder(new EmptyBorder(0, 0, 0, 10)); panelDMName.add(datamapNameLabel); panelDMName.add(Box.createHorizontalStrut(5)); panelDMName.add(dataMapName); dataMapName.setComponentPopupMenu(new JDefaultContextMenu(dataMapName)); JPanel panelDMDescription = new JPanel(); panelDMDescription.setBorder(new EmptyBorder(10, 10, 0, 10)); panelDMDescription.setLayout(new BoxLayout(panelDMDescription, BoxLayout.X_AXIS)); panelDMDescription.add(new JLabel("DataMap Description (16000 Chars)")); panelDMDescription.add(Box.createHorizontalStrut(5)); //JScrollPane scroll = new JScrollPane(dataMapDescription); //scroll.setSize(300, 50); dataMapDescription.setLineWrap(true); dataMapDescription.setWrapStyleWord(true); panelDMDescription.add(new JScrollPane(dataMapDescription)); JPanel panelDMShortDescription = new JPanel(); panelDMShortDescription.setBorder(new EmptyBorder(10, 10, 0, 10)); panelDMShortDescription.setLayout(new BoxLayout(panelDMShortDescription, BoxLayout.X_AXIS)); JLabel labelShort = new JLabel("Short Description:"); labelShort.setBorder(new EmptyBorder(0, 0, 0, 85)); panelDMShortDescription.add(labelShort); panelDMShortDescription.add(Box.createHorizontalStrut(5)); shortDescription.setLineWrap(true); shortDescription.setWrapStyleWord(true); panelDMShortDescription.add(new JScrollPane(shortDescription)); setEnableShortDescription(false); // ------------- JPanel panelTitleForTags = new JPanel(); panelTitleForTags.setBorder(new EmptyBorder(10, 10, 0, 10)); panelTitleForTags.setLayout(new BoxLayout(panelTitleForTags, BoxLayout.X_AXIS)); panelTitleForTags.add(new JLabel("Add tags associated with your DataMap:")); // ------------- JPanel panelListAddedTags = new JPanel(); panelListAddedTags.setBorder(new EmptyBorder(0, 10, 10, 10)); panelListAddedTags.setLayout(new BoxLayout(panelListAddedTags, BoxLayout.X_AXIS)); // -- JPanel panelFrom = new JPanel(); panelFrom.setLayout(new BoxLayout(panelFrom, BoxLayout.Y_AXIS)); JPanel panelMiddle = new JPanel(); panelMiddle.setLayout(new BoxLayout(panelMiddle, BoxLayout.X_AXIS)); JPanel panelTo = new JPanel(); panelTo.setLayout(new BoxLayout(panelTo, BoxLayout.Y_AXIS)); // -- JPanel panelAddNewTag = new JPanel(); panelAddNewTag.setLayout(new BoxLayout(panelAddNewTag, BoxLayout.X_AXIS)); panelAddNewTag.add(new JLabel("Add new tag:")); panelAddNewTag.add(Box.createHorizontalStrut(5)); textfieldAddNewTag = new JTextField(); textfieldAddNewTag.setComponentPopupMenu(new JDefaultContextMenu(textfieldAddNewTag)); panelAddNewTag.add(textfieldAddNewTag); panelAddNewTag.add(Box.createHorizontalStrut(5)); JButton buttonAddTag = new JButton("Add"); buttonAddTag.addActionListener(addNewTagMouseListener); panelAddNewTag.add(buttonAddTag); // -- JPanel panelDeleteTags = new JPanel(); panelDeleteTags.setLayout(new BoxLayout(panelDeleteTags, BoxLayout.X_AXIS)); panelDeleteTags.add(new JLabel("Delete selected tag(s):")); panelDeleteTags.add(Box.createHorizontalStrut(5)); JButton buttonDeleteTag = new JButton("Delete"); buttonDeleteTag.addActionListener(deleteTagMouseListener); panelDeleteTags.add(buttonDeleteTag); panelDeleteTags.add(new JPanel()); // -- JButton moveTag = new JButton(UiUtils.ARROW_ICON); moveTag.addActionListener(addTagsMouseListener); panelMiddle.add(moveTag); tblModelFrom = new DefaultTableModel(); tblModelTo = new DefaultTableModel(); tblModelFrom.addColumn("Tag Name"); tblModelTo.addColumn("Tag Name"); tagsTableFrom = new JTable(tblModelFrom); tagsTableTo = new JTable(tblModelTo); tagsTableFrom.setOpaque(false); tagsTableFrom.setBackground(null); tagsTableFrom.setBorder(null); tagsTableFrom.setShowGrid(false); tagsTableTo.setOpaque(false); tagsTableTo.setBackground(null); tagsTableTo.setBorder(null); tagsTableTo.setShowGrid(false); tagsTableFrom.getColumn("Tag Name").setCellEditor(new CellEditor(new JTextField())); tagsTableTo.getColumn("Tag Name").setCellEditor(new CellEditor(new JTextField())); fillTableTags(); tagsTableFrom.setComponentPopupMenu(new JDefaultContextMenu(tagsTableFrom)); tagsTableTo.setComponentPopupMenu(new JDefaultContextMenu(tagsTableTo)); JScrollPane srollPane = new JScrollPane(tagsTableFrom); srollPane.setBorder(null); JScrollPane srollPane2 = new JScrollPane(tagsTableTo); srollPane.setBorder(null); panelFrom.add(srollPane); panelFrom.add(Box.createVerticalStrut(5)); panelFrom.add(panelAddNewTag); panelTo.add(srollPane2); panelTo.add(Box.createVerticalStrut(5)); panelTo.add(panelDeleteTags); panelListAddedTags.add(panelFrom); panelListAddedTags.add(Box.createHorizontalStrut(5)); panelListAddedTags.add(panelMiddle); panelListAddedTags.add(Box.createHorizontalStrut(5)); panelListAddedTags.add(panelTo); // ------- JPanel panelButton = new JPanel(); panelButton.setLayout(new BoxLayout(panelButton, BoxLayout.X_AXIS)); panelButton.add(Box.createHorizontalGlue()); panelButton.add(bOk); panelButton.add(Box.createHorizontalStrut(5)); panelButton.add(bCancel); panelButton.add(Box.createHorizontalStrut(5)); ComponentBuilder.makeComponent(new JCommentPanel(), gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelLogin, gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelForgotPassLink, gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelFile, gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelLocation, gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelDMName, gridbag, c, getContentPane()); c.fill = GridBagConstraints.BOTH; c.weighty = 2.0; ComponentBuilder.makeComponent(panelDMDescription, gridbag, c, getContentPane()); c.weighty = 0.0; ComponentBuilder.makeComponent(autoGenerateShortDescription, gridbag, c, getContentPane()); c.weighty = 1.0; ComponentBuilder.makeComponent(panelDMShortDescription, gridbag, c, getContentPane()); c.weighty = 1.0; ComponentBuilder.makeComponent(panelTitleForTags, gridbag, c, getContentPane()); c.weighty = 3.0; ComponentBuilder.makeComponent(panelListAddedTags, gridbag, c, getContentPane()); c.weighty = 0.0; ComponentBuilder.makeComponent(new JSeparator(), gridbag, c, getContentPane()); c.weighty = 1.0; ComponentBuilder.makeComponent(panelButton, gridbag, c, getContentPane()); }
From source file:mergedoc.ui.PreferencePanel.java
/** * ??????//from w ww . j ava2s . c o m * @return ?? * @throws MergeDocException ???????? */ private JComponent createLowerPanel() throws MergeDocException { // ??? JPanel checkPanel = new JPanel(); checkPanel.setLayout(new BoxLayout(checkPanel, BoxLayout.Y_AXIS)); List<ReplaceEntry> list = ConfigManager.getInstance().getGlobalEntries(); for (ReplaceEntry entry : list) { EntryCheckBox cb = new EntryCheckBox(entry); cb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { previewScrollPane.updatePreview(entryCheckList); } }); checkPanel.add(cb); entryCheckList.add(cb); } JScrollPane checkScrollPane = ComponentFactory.createScrollPane(checkPanel); checkScrollPane.getVerticalScrollBar().setUnitIncrement(10); // ? previewScrollPane = new PreviewScrollPane(); // ?? splitPane.setBorder(BorderFactory.createEmptyBorder()); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPane.setContinuousLayout(true); splitPane.setTopComponent(checkScrollPane); splitPane.setBottomComponent(previewScrollPane); JPanel splitPanel = new JPanel(); splitPanel.setLayout(new BoxLayout(splitPanel, BoxLayout.X_AXIS)); splitPanel.add(splitPane); // ?? JPanel panel = new TitledPanel(""); panel.setMaximumSize(ComponentFactory.createMaxDimension()); panel.add(splitPanel); // ??? Persister psst = Persister.getInstance(); int loc = psst.getInt(Persister.DETAIL_PANEL_HEIGHT, 88); splitPane.setDividerLocation(loc); // ??? String[] pDescs = psst.getStrings(Persister.REPLACE_DESCRIPTION_ARRAY); for (EntryCheckBox ecb : entryCheckList) { ReplaceEntry entry = ecb.getReplaceEntry(); String desc = entry.getDescription(); for (String pDesc : pDescs) { if (desc.equals(pDesc)) { ecb.setSelected(true); break; } } } previewScrollPane.updatePreview(entryCheckList); return panel; }
From source file:es.emergya.ui.gis.popups.ListaCapas.java
private void addCapa(final GpxLayer layer) { final JPanel capaP = new JPanel(); capaP.setOpaque(false);// w w w . j a va 2s .c om layer.visible = true; mapView.addLayer(layer, false, capasActuales.size()); capasActuales.add(layer); capaP.setLayout(new BoxLayout(capaP, BoxLayout.X_AXIS)); final JCheckBox capa = new JCheckBox(layer.getAssociatedFile().getAbsolutePath()); capa.setSelected(layer.visible); capa.setBackground(Color.WHITE); capa.setToolTipText(i18n.getString("window.gpx.checkbox.show.tooltip")); capa.setActionCommand(layer.name); capa.addActionListener(this); capaP.add(capa); capaP.add(Box.createHorizontalGlue()); JButton eliminar = new JButton(LogicConstants.getIcon("button_delone")); eliminar.setToolTipText(i18n.getString("window.gpx.button.delete.tooltip")); eliminar.setBorderPainted(false); eliminar.setContentAreaFilled(false); capaP.add(eliminar); eliminar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mapView.removeLayer(layer); mapView.repaint(); capasGpx.remove(capaP); capasGpx.updateUI(); capasActuales.remove(layer); } }); capasGpx.add(capaP); capasGpx.updateUI(); }
From source file:org.obiba.onyx.jade.instrument.summitdoppler.VantageABIInstrumentRunner.java
/** * Build action buttons sub panel/*from w ww. j a v a2 s .co m*/ */ protected JPanel buildActionButtonSubPanel() { // Add the action buttons sub panel. JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); JButton cancelButton = new JButton(resourceBundle.getString("Cancel")); cancelButton.setMnemonic('A'); cancelButton.setToolTipText(resourceBundle.getString("ToolTip.Cancel_measurement")); panel.add(Box.createHorizontalGlue()); panel.add(saveButton); panel.add(Box.createRigidArea(new Dimension(10, 0))); panel.add(cancelButton); // Save button listener. saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { sendOutputToServer(); } }); // Cancel button listener. cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { confirmOnExit(); } }); panel.setAlignmentX(Component.LEFT_ALIGNMENT); return (panel); }
From source file:medsavant.uhn.cancer.UserCommentApp.java
private JPanel getHeaderPanel(UserComment lc) { JPanel headerPanel = new JPanel(); headerPanel.setLayout(new BoxLayout(headerPanel, BoxLayout.Y_AXIS)); JPanel leftJustPanel = new JPanel(); leftJustPanel.setLayout(new BoxLayout(leftJustPanel, BoxLayout.X_AXIS)); leftJustPanel.add(new JLabel("Posted " + lc.getModificationDate().toString() + " by: ")); leftJustPanel.add(Box.createHorizontalGlue()); headerPanel.add(leftJustPanel);/*from w ww.j a va 2 s .c om*/ leftJustPanel = new JPanel(); leftJustPanel.setLayout(new BoxLayout(leftJustPanel, BoxLayout.X_AXIS)); leftJustPanel.add(new JLabel(lc.getUser())); leftJustPanel.add(Box.createHorizontalGlue()); headerPanel.add(leftJustPanel); headerPanel.add(Box.createHorizontalGlue()); return headerPanel; }
From source file:BeanContainer.java
protected JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); //from w ww. j a v a 2 s .c o m JMenu mFile = new JMenu("File"); JMenuItem mItem = new JMenuItem("New..."); ActionListener lst = new ActionListener() { public void actionPerformed(ActionEvent e) { Thread newthread = new Thread() { public void run() { String result = (String)JOptionPane.showInputDialog( BeanContainer.this, "Please enter class name to create a new bean", "Input", JOptionPane.INFORMATION_MESSAGE, null, null, m_className); repaint(); if (result==null) return; try { m_className = result; Class cls = Class.forName(result); Object obj = cls.newInstance(); if (obj instanceof Component) { m_activeBean = (Component)obj; m_activeBean.addFocusListener( BeanContainer.this); m_activeBean.requestFocus(); getContentPane().add(m_activeBean); } validate(); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog( BeanContainer.this, "Error: "+ex.toString(), "Warning", JOptionPane.WARNING_MESSAGE); } } }; newthread.start(); } }; mItem.addActionListener(lst); mFile.add(mItem); mItem = new JMenuItem("Load..."); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { Thread newthread = new Thread() { public void run() { m_chooser.setCurrentDirectory(m_currentDir); m_chooser.setDialogTitle( "Please select file with serialized bean"); int result = m_chooser.showOpenDialog( BeanContainer.this); repaint(); if (result != JFileChooser.APPROVE_OPTION) return; m_currentDir = m_chooser.getCurrentDirectory(); File fChoosen = m_chooser.getSelectedFile(); try { FileInputStream fStream = new FileInputStream(fChoosen); ObjectInput stream = new ObjectInputStream(fStream); Object obj = stream.readObject(); if (obj instanceof Component) { m_activeBean = (Component)obj; m_activeBean.addFocusListener( BeanContainer.this); m_activeBean.requestFocus(); getContentPane().add(m_activeBean); } stream.close(); fStream.close(); validate(); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog( BeanContainer.this, "Error: "+ex.toString(), "Warning", JOptionPane.WARNING_MESSAGE); } repaint(); } }; newthread.start(); } }; mItem.addActionListener(lst); mFile.add(mItem); mItem = new JMenuItem("Save..."); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { Thread newthread = new Thread() { public void run() { if (m_activeBean == null) return; m_chooser.setDialogTitle( "Please choose file to serialize bean"); m_chooser.setCurrentDirectory(m_currentDir); int result = m_chooser.showSaveDialog( BeanContainer.this); repaint(); if (result != JFileChooser.APPROVE_OPTION) return; m_currentDir = m_chooser.getCurrentDirectory(); File fChoosen = m_chooser.getSelectedFile(); try { FileOutputStream fStream = new FileOutputStream(fChoosen); ObjectOutput stream = new ObjectOutputStream(fStream); stream.writeObject(m_activeBean); stream.close(); fStream.close(); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog( BeanContainer.this, "Error: "+ex.toString(), "Warning", JOptionPane.WARNING_MESSAGE); } } }; newthread.start(); } }; mItem.addActionListener(lst); mFile.add(mItem); mFile.addSeparator(); mItem = new JMenuItem("Exit"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }; mItem.addActionListener(lst); mFile.add(mItem); menuBar.add(mFile); JMenu mEdit = new JMenu("Edit"); mItem = new JMenuItem("Delete"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { if (m_activeBean == null) return; Object obj = m_editors.get(m_activeBean); if (obj != null) { BeanEditor editor = (BeanEditor)obj; editor.dispose(); m_editors.remove(m_activeBean); } getContentPane().remove(m_activeBean); m_activeBean = null; validate(); repaint(); } }; mItem.addActionListener(lst); mEdit.add(mItem); mItem = new JMenuItem("Properties..."); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { if (m_activeBean == null) return; Object obj = m_editors.get(m_activeBean); if (obj != null) { BeanEditor editor = (BeanEditor)obj; editor.setVisible(true); editor.toFront(); } else { BeanEditor editor = new BeanEditor(m_activeBean); m_editors.put(m_activeBean, editor); } } }; mItem.addActionListener(lst); mEdit.add(mItem); menuBar.add(mEdit); JMenu mLayout = new JMenu("Layout"); ButtonGroup group = new ButtonGroup(); mItem = new JRadioButtonMenuItem("FlowLayout"); mItem.setSelected(true); lst = new ActionListener() { public void actionPerformed(ActionEvent e){ getContentPane().setLayout(new FlowLayout()); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); mItem = new JRadioButtonMenuItem("GridLayout"); lst = new ActionListener() { public void actionPerformed(ActionEvent e){ int col = 3; int row = (int)Math.ceil(getContentPane(). getComponentCount()/(double)col); getContentPane().setLayout(new GridLayout(row, col, 10, 10)); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); mItem = new JRadioButtonMenuItem("BoxLayout - X"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { getContentPane().setLayout(new BoxLayout( getContentPane(), BoxLayout.X_AXIS)); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); mItem = new JRadioButtonMenuItem("BoxLayout - Y"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { getContentPane().setLayout(new BoxLayout( getContentPane(), BoxLayout.Y_AXIS)); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); mItem = new JRadioButtonMenuItem("DialogLayout"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { getContentPane().setLayout(new DialogLayout()); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); menuBar.add(mLayout); return menuBar; }