List of usage examples for javax.swing BoxLayout BoxLayout
@ConstructorProperties({ "target", "axis" }) public BoxLayout(Container target, int axis)
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/*from w w w. j a va 2 s . c om*/ public void actionPerformed(ActionEvent ae) { replyToOntology(vr, ot); } }); ontologyTitlePanel.add(replyToOntologyButton); return ontologyTitlePanel; }
From source file:FileChooserDemo.java
public FileChooserDemo() { UIManager.LookAndFeelInfo[] installedLafs = UIManager.getInstalledLookAndFeels(); for (UIManager.LookAndFeelInfo lafInfo : installedLafs) { try {//from ww w .j a va2 s . com Class lnfClass = Class.forName(lafInfo.getClassName()); LookAndFeel laf = (LookAndFeel) (lnfClass.newInstance()); if (laf.isSupportedLookAndFeel()) { String name = lafInfo.getName(); supportedLaFs.add(new SupportedLaF(name, laf)); } } catch (Exception e) { // If ANYTHING weird happens, don't add it continue; } } setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); chooser = new JFileChooser(); previewer = new FilePreviewer(chooser); // Create Custom FileView fileView = new ExampleFileView(); // fileView.putIcon("jpg", new ImageIcon(getClass().getResource("/resources/images/jpgIcon.jpg"))); // fileView.putIcon("gif", new ImageIcon(getClass().getResource("/resources/images/gifIcon.gif"))); // create a radio listener to listen to option changes OptionListener optionListener = new OptionListener(); // Create options openRadioButton = new JRadioButton("Open"); openRadioButton.setSelected(true); openRadioButton.addActionListener(optionListener); saveRadioButton = new JRadioButton("Save"); saveRadioButton.addActionListener(optionListener); customButton = new JRadioButton("Custom"); customButton.addActionListener(optionListener); customField = new JTextField(8) { public Dimension getMaximumSize() { return new Dimension(getPreferredSize().width, getPreferredSize().height); } }; customField.setText("Doit"); customField.setAlignmentY(JComponent.TOP_ALIGNMENT); customField.setEnabled(false); customField.addActionListener(optionListener); ButtonGroup group1 = new ButtonGroup(); group1.add(openRadioButton); group1.add(saveRadioButton); group1.add(customButton); // filter buttons showAllFilesFilterCheckBox = new JCheckBox("Show \"All Files\" Filter"); showAllFilesFilterCheckBox.addActionListener(optionListener); showAllFilesFilterCheckBox.setSelected(true); showImageFilesFilterCheckBox = new JCheckBox("Show JPG and GIF Filters"); showImageFilesFilterCheckBox.addActionListener(optionListener); showImageFilesFilterCheckBox.setSelected(false); accessoryCheckBox = new JCheckBox("Show Preview"); accessoryCheckBox.addActionListener(optionListener); accessoryCheckBox.setSelected(false); // more options setHiddenCheckBox = new JCheckBox("Show Hidden Files"); setHiddenCheckBox.addActionListener(optionListener); showFullDescriptionCheckBox = new JCheckBox("With File Extensions"); showFullDescriptionCheckBox.addActionListener(optionListener); showFullDescriptionCheckBox.setSelected(true); showFullDescriptionCheckBox.setEnabled(false); useFileViewCheckBox = new JCheckBox("Use FileView"); useFileViewCheckBox.addActionListener(optionListener); useFileViewCheckBox.setSelected(false); useEmbedInWizardCheckBox = new JCheckBox("Embed in Wizard"); useEmbedInWizardCheckBox.addActionListener(optionListener); useEmbedInWizardCheckBox.setSelected(false); useControlsCheckBox = new JCheckBox("Show Control Buttons"); useControlsCheckBox.addActionListener(optionListener); useControlsCheckBox.setSelected(true); enableDragCheckBox = new JCheckBox("Enable Dragging"); enableDragCheckBox.addActionListener(optionListener); // File or Directory chooser options ButtonGroup group3 = new ButtonGroup(); justFilesRadioButton = new JRadioButton("Just Select Files"); justFilesRadioButton.setSelected(true); group3.add(justFilesRadioButton); justFilesRadioButton.addActionListener(optionListener); justDirectoriesRadioButton = new JRadioButton("Just Select Directories"); group3.add(justDirectoriesRadioButton); justDirectoriesRadioButton.addActionListener(optionListener); bothFilesAndDirectoriesRadioButton = new JRadioButton("Select Files or Directories"); group3.add(bothFilesAndDirectoriesRadioButton); bothFilesAndDirectoriesRadioButton.addActionListener(optionListener); singleSelectionRadioButton = new JRadioButton("Single Selection", true); singleSelectionRadioButton.addActionListener(optionListener); multiSelectionRadioButton = new JRadioButton("Multi Selection"); multiSelectionRadioButton.addActionListener(optionListener); ButtonGroup group4 = new ButtonGroup(); group4.add(singleSelectionRadioButton); group4.add(multiSelectionRadioButton); // Create show button showButton = new JButton("Show FileChooser"); showButton.addActionListener(this); showButton.setMnemonic('s'); // Create laf combo box lafComboBox = new JComboBox(supportedLaFs); lafComboBox.setEditable(false); lafComboBox.addActionListener(optionListener); // ******************************************************** // ******************** Dialog Type *********************** // ******************************************************** JPanel control1 = new InsetPanel(insets); control1.setBorder(BorderFactory.createTitledBorder("Dialog Type")); control1.setLayout(new BoxLayout(control1, BoxLayout.Y_AXIS)); control1.add(Box.createRigidArea(vpad20)); control1.add(openRadioButton); control1.add(Box.createRigidArea(vpad7)); control1.add(saveRadioButton); control1.add(Box.createRigidArea(vpad7)); control1.add(customButton); control1.add(Box.createRigidArea(vpad4)); JPanel fieldWrapper = new JPanel(); fieldWrapper.setLayout(new BoxLayout(fieldWrapper, BoxLayout.X_AXIS)); fieldWrapper.setAlignmentX(Component.LEFT_ALIGNMENT); fieldWrapper.add(Box.createRigidArea(hpad10)); fieldWrapper.add(Box.createRigidArea(hpad10)); fieldWrapper.add(customField); control1.add(fieldWrapper); control1.add(Box.createRigidArea(vpad20)); control1.add(Box.createGlue()); // ******************************************************** // ***************** Filter Controls ********************** // ******************************************************** JPanel control2 = new InsetPanel(insets); control2.setBorder(BorderFactory.createTitledBorder("Filter Controls")); control2.setLayout(new BoxLayout(control2, BoxLayout.Y_AXIS)); control2.add(Box.createRigidArea(vpad20)); control2.add(showAllFilesFilterCheckBox); control2.add(Box.createRigidArea(vpad7)); control2.add(showImageFilesFilterCheckBox); control2.add(Box.createRigidArea(vpad4)); JPanel checkWrapper = new JPanel(); checkWrapper.setLayout(new BoxLayout(checkWrapper, BoxLayout.X_AXIS)); checkWrapper.setAlignmentX(Component.LEFT_ALIGNMENT); checkWrapper.add(Box.createRigidArea(hpad10)); checkWrapper.add(Box.createRigidArea(hpad10)); checkWrapper.add(showFullDescriptionCheckBox); control2.add(checkWrapper); control2.add(Box.createRigidArea(vpad20)); control2.add(Box.createGlue()); // ******************************************************** // ****************** Display Options ********************* // ******************************************************** JPanel control3 = new InsetPanel(insets); control3.setBorder(BorderFactory.createTitledBorder("Display Options")); control3.setLayout(new BoxLayout(control3, BoxLayout.Y_AXIS)); control3.add(Box.createRigidArea(vpad20)); control3.add(setHiddenCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(useFileViewCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(accessoryCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(useEmbedInWizardCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(useControlsCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(enableDragCheckBox); control3.add(Box.createRigidArea(vpad20)); control3.add(Box.createGlue()); // ******************************************************** // ************* File & Directory Options ***************** // ******************************************************** JPanel control4 = new InsetPanel(insets); control4.setBorder(BorderFactory.createTitledBorder("File and Directory Options")); control4.setLayout(new BoxLayout(control4, BoxLayout.Y_AXIS)); control4.add(Box.createRigidArea(vpad20)); control4.add(justFilesRadioButton); control4.add(Box.createRigidArea(vpad7)); control4.add(justDirectoriesRadioButton); control4.add(Box.createRigidArea(vpad7)); control4.add(bothFilesAndDirectoriesRadioButton); control4.add(Box.createRigidArea(vpad20)); control4.add(singleSelectionRadioButton); control4.add(Box.createRigidArea(vpad7)); control4.add(multiSelectionRadioButton); control4.add(Box.createRigidArea(vpad20)); control4.add(Box.createGlue()); // ******************************************************** // **************** Look & Feel Switch ******************** // ******************************************************** JPanel panel = new JPanel(); panel.add(new JLabel("Look and Feel: ")); panel.add(lafComboBox); panel.add(showButton); // ******************************************************** // ****************** Wrap 'em all up ********************* // ******************************************************** JPanel wrapper = new JPanel(); wrapper.setLayout(new BoxLayout(wrapper, BoxLayout.X_AXIS)); add(Box.createRigidArea(vpad20)); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(control1); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(control2); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(control3); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(control4); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(Box.createRigidArea(hpad10)); add(wrapper); add(Box.createRigidArea(vpad20)); add(panel); add(Box.createRigidArea(vpad20)); }
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 ava 2s . 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.gdc.nms.web.mibquery.wizard.ciscavate.cjwizard.WizardContainer.java
/** * /*from ww w .java2s. c om*/ */ private void initComponents() { final JButton prevBtn = new JButton(_prevAction); final JButton nextBtn = new JButton(_nextAction); final JButton finishBtn = new JButton(_finishAction); final JButton cancelBtn = new JButton(_cancelAction); _extraButtonPanel = new JPanel(); _extraButtonPanel.setLayout(new BoxLayout(_extraButtonPanel, BoxLayout.LINE_AXIS)); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.add(_extraButtonPanel); buttonPanel.add(Box.createHorizontalGlue()); buttonPanel.add(prevBtn); buttonPanel.add(Box.createHorizontalStrut(5)); buttonPanel.add(nextBtn); buttonPanel.add(Box.createHorizontalStrut(10)); buttonPanel.add(finishBtn); buttonPanel.add(Box.createHorizontalStrut(10)); buttonPanel.add(cancelBtn); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15)); //this.setLayout(new BorderLayout()); //this.add(_template, BorderLayout.CENTER); //this.add(buttonPanel, BorderLayout.SOUTH); }
From source file:com.github.cjwizard.WizardContainer.java
/** * /*from www. ja v a 2 s.c om*/ */ private void initComponents() { final JButton prevBtn = new JButton(_prevAction); final JButton nextBtn = new JButton(_nextAction); final JButton finishBtn = new JButton(_finishAction); final JButton cancelBtn = new JButton(_cancelAction); _extraButtonPanel = new JPanel(); _extraButtonPanel.setLayout(new BoxLayout(_extraButtonPanel, BoxLayout.LINE_AXIS)); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.add(_extraButtonPanel); buttonPanel.add(Box.createHorizontalGlue()); buttonPanel.add(prevBtn); buttonPanel.add(Box.createHorizontalStrut(5)); buttonPanel.add(nextBtn); buttonPanel.add(Box.createHorizontalStrut(10)); buttonPanel.add(finishBtn); buttonPanel.add(Box.createHorizontalStrut(10)); buttonPanel.add(cancelBtn); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15)); this.setLayout(new BorderLayout()); this.add(_template, BorderLayout.CENTER); this.add(buttonPanel, BorderLayout.SOUTH); }
From source file:io.github.jeremgamer.editor.panels.components.PanelsPanel.java
public PanelsPanel(JFrame frame, final PanelSave ps) { this.ps = ps; this.frame = frame; this.setSize(new Dimension(395, frame.getHeight() - 27 - 23)); this.setLocation(300, 0); this.setBorder(BorderFactory.createTitledBorder("Edition du panneau")); JPanel content = new JPanel(); JScrollPane scroll = new JScrollPane(content); scroll.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); scroll.setBorder(null);/*from w w w . ja v a2 s .co m*/ content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS)); scroll.setPreferredSize(new Dimension(382, frame.getHeight() - 27 - 46 - 20)); JPanel namePanel = new JPanel(); name.setPreferredSize(new Dimension(this.getWidth() - 280, 30)); name.setEditable(false); namePanel.add(new JLabel("Nom :")); namePanel.add(name); namePanel.add(Box.createRigidArea(new Dimension(10, 1))); layout.addItem("Basique"); layout.addItem("Bordures"); layout.addItem("Ligne"); layout.addItem("Colonne"); layout.addItem("Grille"); layout.addItem("Empil"); layout.setPreferredSize(new Dimension(110, 30)); layout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); cl.show(advanced, listContent[combo.getSelectedIndex()]); ps.set("layout", combo.getSelectedIndex()); ActionPanel.updateLists(); } }); namePanel.add(new JLabel("Disposition :")); namePanel.add(layout); namePanel.setPreferredSize(new Dimension(365, 50)); namePanel.setMaximumSize(new Dimension(365, 50)); content.add(namePanel); advanced.setPreferredSize(new Dimension(365, 300)); advanced.setMaximumSize(new Dimension(365, 300)); advanced.add(ble, listContent[0]); advanced.add(brdle, listContent[1]); advanced.add(lle, listContent[2]); advanced.add(rle, listContent[3]); advanced.add(gle, listContent[4]); advanced.add(cle, listContent[5]); content.add(advanced); topBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); ps.set("border.top", combo.getSelectedItem()); } }); leftBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); ps.set("border.left", combo.getSelectedItem()); } }); centerBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); ps.set("border.center", combo.getSelectedItem()); } }); rightBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); ps.set("border.right", combo.getSelectedItem()); } }); bottomBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); ps.set("border.bottom", combo.getSelectedItem()); } }); JPanel prefSize = new JPanel(); prefSize.setPreferredSize(new Dimension(365, 110)); prefSize.setMaximumSize(new Dimension(365, 110)); prefSize.setBorder(BorderFactory.createTitledBorder("Taille prfre")); JPanel prefSizePanel = new JPanel(); prefSizePanel.setLayout(new GridLayout(2, 4)); prefSizePanel.setPreferredSize(new Dimension(300, 55)); prefSizePanel.setMaximumSize(new Dimension(300, 55)); prefSizePanel.add(prefSizeEnabled); prefSizePanel.add(new JLabel("")); prefSizePanel.add(new JLabel("")); prefSizePanel.add(new JLabel("(en pixels)")); prefSizePanel.add(new JLabel("Largeur :")); prefSizePanel.add(prefWidth); prefSizePanel.add(new JLabel("Hauteur :")); prefSizePanel.add(prefHeight); prefWidth.setEnabled(false); prefHeight.setEnabled(false); prefSizeEnabled.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JCheckBox check = (JCheckBox) event.getSource(); ps.set("preferredSize", check.isSelected()); prefWidth.setEnabled(check.isSelected()); prefHeight.setEnabled(check.isSelected()); } }); prefWidth.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JSpinner spinner = (JSpinner) event.getSource(); ps.set("preferredWidth", spinner.getValue()); } }); prefHeight.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JSpinner spinner = (JSpinner) event.getSource(); ps.set("preferredHeight", spinner.getValue()); } }); prefSize.add(prefSizePanel); content.add(prefSize); JPanel insetsPanel = new JPanel(); insetsPanel.setBorder(BorderFactory.createTitledBorder("carts")); insetsPanel.setPreferredSize(new Dimension(365, 100)); insetsPanel.setMaximumSize(new Dimension(365, 100)); JPanel insetsContent = new JPanel(); insetsContent.setLayout(new BoxLayout(insetsContent, BoxLayout.PAGE_AXIS)); JPanel insetInput = new JPanel(); insetInput.setLayout(new GridLayout(2, 4)); insetInput.add(insetsEnabled); insetInput.add(new JLabel("")); insetInput.add(new JLabel("")); insetInput.add(new JLabel("(en pixels)")); insetInput.add(new JLabel("Horizontaux :")); insetInput.add(insetHz); insetInput.add(new JLabel("Verticaux :")); insetInput.add(insetVt); insetsEnabled.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JCheckBox check = (JCheckBox) event.getSource(); if (check.isSelected()) { insetHz.setEnabled(true); insetVt.setEnabled(true); ps.set("insets", true); } else { insetHz.setEnabled(true); insetVt.setEnabled(true); ps.set("insets", false); } } }); insetHz.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JSpinner spinner = (JSpinner) event.getSource(); ps.set("insets.horizontal", spinner.getValue()); } }); insetVt.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JSpinner spinner = (JSpinner) event.getSource(); ps.set("insets.vertical", spinner.getValue()); } }); insetsContent.add(insetInput); insetsPanel.add(insetsContent); content.add(insetsPanel); JPanel web = new JPanel(); web.setPreferredSize(new Dimension(365, 100)); web.setMaximumSize(new Dimension(365, 100)); web.setBorder(BorderFactory.createTitledBorder("Page Web")); JPanel webContent = new JPanel(); webContent.setLayout(new BorderLayout()); webContent.add(webEnabled, BorderLayout.NORTH); webEnabled.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCheckBox check = (JCheckBox) e.getSource(); ps.set("web", check.isSelected()); if (check.isSelected() == true) { layout.setSelectedIndex(0); layout.setEnabled(false); ble.removeAllComponents(); ble.disableComponents(); adress.setEnabled(true); } else { ble.enableComponents(); layout.setEnabled(true); adress.setEnabled(false); } } }); JPanel webInput = new JPanel(); webInput.add(new JLabel("Adresse :")); adress.setPreferredSize(new Dimension(250, 30)); CaretListener caretUpdate = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); ps.set("web.adress", text.getText()); } }; adress.addCaretListener(caretUpdate); webInput.add(adress); webContent.add(webInput, BorderLayout.CENTER); web.add(webContent); JPanel background = new JPanel(); BorderLayout bLayout = new BorderLayout(); bLayout.setVgap(12); background.setLayout(bLayout); background.setBorder(BorderFactory.createTitledBorder("Couleur de fond")); background.setPreferredSize(new Dimension(365, 210)); background.setMaximumSize(new Dimension(365, 210)); cp.setPreferredSize(new Dimension(347, 145)); cp.setMaximumSize(new Dimension(347, 145)); opaque.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCheckBox check = (JCheckBox) e.getSource(); ps.set("background.opaque", check.isSelected()); cp.enableComponents(check.isSelected()); } }); background.add(opaque, BorderLayout.NORTH); background.add(cp, BorderLayout.CENTER); JPanel image = new JPanel(); image.setBorder(BorderFactory.createTitledBorder("Image de fond")); image.setPreferredSize(new Dimension(365, 125)); image.setMaximumSize(new Dimension(365, 125)); image.setLayout(new BorderLayout()); try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.setEnabled(false); remove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { File img = new File( "projects/" + Editor.getProjectName() + "/panels/" + name.getText() + "/background.png"); if (img.exists()) { img.delete(); } browseImage.setEnabled(true); } }); JPanel top = new JPanel(); browseImage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JButton button = (JButton) e.getSource(); String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "background.png"); nameBackground.setText(new File(path).getName()); ps.set("background.image", new File(path).getName()); button.setEnabled(false); size.setEnabled(true); size2.setEnabled(true); remove.setEnabled(true); } } }); bg.add(size); bg.add(size2); JPanel sizePanel = new JPanel(); sizePanel.setLayout(new BoxLayout(sizePanel, BoxLayout.PAGE_AXIS)); size.setEnabled(false); size2.setEnabled(false); sizePanel.add(size); sizePanel.add(size2); size.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { ps.set("background.size", 0); } }); size2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { ps.set("background.size", 1); } }); top.add(browseImage); top.add(sizePanel); remove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JButton button = (JButton) event.getSource(); new File("projects/" + Editor.getProjectName() + "/panels/" + name.getText() + "/background.png") .delete(); nameBackground.setText(""); ps.set("background.image", ""); button.setEnabled(false); } }); nameBackground.setFont(new Font("Sans Serif", Font.PLAIN, 15)); JPanel center = new JPanel(new BorderLayout()); center.add(nameBackground, BorderLayout.CENTER); center.add(remove, BorderLayout.EAST); image.add(top, BorderLayout.NORTH); image.add(center, BorderLayout.CENTER); content.add(web); content.add(background); content.add(image); this.add(scroll); }
From source file:flexflux.analyses.result.PP2DResult.java
public void plot() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); // one chart by group Map<Integer, Integer> correspGroup = new HashMap<Integer, Integer>(); XYSeriesCollection dataset = new XYSeriesCollection(); int index = 0; XYSeries series = new XYSeries(""); for (double point : fluxValues) { series.add(point, resultValues.get(point)); correspGroup.put(index, pointIndex.get(point)); index++;/*from w w w .ja v a 2 s. c om*/ } dataset.addSeries(series); if (!expValues.isEmpty()) { XYSeries expSeries = new XYSeries("Experimental values"); if (!expValues.isEmpty()) { for (Double d : expValues.keySet()) { for (Double d2 : expValues.get(d)) { expSeries.add(d, d2); } } } dataset.addSeries(expSeries); } final JFreeChart chart = ChartFactory.createXYLineChart("", // chart // title reacName, // domain axis label objName, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.GRAY); plot.setDomainGridlinePaint(Color.GRAY); XYLineAndShapeRenderer renderer = new MyRenderer(true, false, correspGroup); plot.setRenderer(0, renderer); if (!expValues.isEmpty()) { renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); renderer.setSeriesPaint(1, Color.BLUE); } ChartPanel chartPanel = new ChartPanel(chart); panel.add(chartPanel); JPanel fvaPanel = new JPanel(); fvaPanel.setLayout(new BoxLayout(fvaPanel, BoxLayout.PAGE_AXIS)); for (int i = 1; i <= groupIndex.size(); i++) { Color color = COLORLIST[i % COLORLIST.length]; JPanel groupPanel = new JPanel(); groupPanel.setLayout(new BoxLayout(groupPanel, BoxLayout.PAGE_AXIS)); List<BioEntity> newEssentialReactions = comparator.getNewEssentialEntities().get(i); List<BioEntity> noLongerEssentialReactions = comparator.getNoLongerEssentialEntities().get(i); JPanel colorPanel = new JPanel(); colorPanel.setBackground(color); groupPanel.add(colorPanel); groupPanel.add(new JLabel( "Phenotypic phase " + i + ", " + newEssentialReactions.size() + " new essential reactions")); fvaPanel.add(groupPanel); if (newEssentialReactions.size() > 0) { fvaPanel.add(new JScrollPane(comparator.getNewEssentialEntitiesPanel().get(i))); } fvaPanel.add(new JLabel("Phenotypic phase " + i + ", " + noLongerEssentialReactions.size() + " no longer essential reactions")); if (noLongerEssentialReactions.size() > 0) { fvaPanel.add(fvaPanel.add(new JScrollPane(comparator.getNoLongerEssentialEntitiesPanel().get(i)))); } } JScrollPane fvaScrollPane = new JScrollPane(fvaPanel); JFrame frame = new JFrame("Phenotypic phase analysis results"); if (expValues.size() > 0) { frame.setTitle("Pareto analysis two dimensions results"); } if (groupIndex.size() > 0) { JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panel, fvaScrollPane); frame.setContentPane(splitPane); frame.setSize(600, 1000); } else { frame.setContentPane(panel); frame.setSize(600, 600); } panel.setPreferredSize(new Dimension(600, 600)); panel.setMinimumSize(new Dimension(600, 600)); RefineryUtilities.centerFrameOnScreen(frame); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:moviedatas.MovieDatas.java
public JPanel createGlobalPanel() { SortPanelView sortFilterView = new SortPanelView(); FilterPanelView filterPanelView = new FilterPanelView(); JPanel sortPanel = sortFilterView.createSortPanel(); JPanel filterPanel = filterPanelView.createFilterPanel(); JPanel globalPanel = new JPanel(); globalPanel.setLayout(new BoxLayout(globalPanel, BoxLayout.PAGE_AXIS)); globalPanel.add(sortPanel);/*w ww . j a v a 2 s. c om*/ globalPanel.add(filterPanel); return globalPanel; }
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;//from w w w . jav a 2s . 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:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication2.java
protected void initGraphPanel() { //System.out.println("initGraphPanel called"); graphPanel = new JPanel(); graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); JFreeChart chart = createEmptyChart("SOCR Applications", null); //create a empty graph first chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y)); graphPanel.add(chartPanel);/* ww w . j a va2 s . c o m*/ graphPanel.validate(); }