List of usage examples for java.awt GridLayout GridLayout
public GridLayout(int rows, int cols)
From source file:sanger.team16.gui.genevar.eqtl.query.SNPGeneAssocPlot.java
public SNPGeneAssocPlot(List<Tuple> tuples, double max, double min) throws ArrayIndexOutOfBoundsException { JPanel mainPanel = new JPanel(new GridLayout(0, 3)); mainPanel.setBackground(Color.white); int size = tuples.size(); for (int i = 0; i < size; i++) { Tuple tuple = tuples.get(i);/*from w w w.jav a2 s. c o m*/ String populationName = tuple.populationName; // if (trait.expressionRanks != null) { // BUG FIXED 02/02/10 if (tuple.phenotypes != null && tuple.phenotypes.length != 0) { CategoryDataset dataset = this.createDataset(tuple); JFreeChart chart = createChart(populationName, dataset, max, min); chart.setBackgroundPaint(Color.white); TextTitle textTitle = new TextTitle(tuple.subtitle); textTitle.setFont(new Font("SansSerif", Font.PLAIN, 12)); //subtitle1.setPosition(RectangleEdge.BOTTOM); textTitle.setHorizontalAlignment(HorizontalAlignment.CENTER); chart.addSubtitle(textTitle); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(this.getAutoPreferredSize()); // Original Dimension(680, 420) mainPanel.add(chartPanel); } else { BaseJPane empty = new BaseJPane(2, 50, 0, 0); empty.setPreferredSize(this.getAutoPreferredSize()); BaseJPane na = new BaseJPane(); na.setLayout(new BorderLayout()); JLabel name = new JLabel(" " + populationName); name.setFont(new Font("Arial", Font.BOLD, 12)); name.setForeground(Color.gray); na.add(name, BorderLayout.PAGE_START); JLabel message = new JLabel("Not Available"); message.setForeground(Color.lightGray); na.add(message, BorderLayout.CENTER); empty.add(Box.createHorizontalGlue()); empty.add(na); empty.add(Box.createHorizontalGlue()); empty.setBaseSpringBox(); mainPanel.add(empty); } } this.add(mainPanel); }
From source file:com.twocents.test.ui.chart.ChartMain.java
/** * Creates a new demo instance./*w w w . j av a 2 s .co m*/ * * @param title * the frame title. * @throws CoreException */ public ChartMain(String title) throws CoreException { super(title); JPanel panel = new JPanel(new GridLayout(1, 1)); DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Section 1", 23.3); dataset.setValue("Section 2", 56.5); dataset.setValue("Section 3", 43.3); dataset.setValue("Section 4", 11.1); int sizeX = 600; int sizeY = 600; String titleChart = "Test"; JFreeChart chart = BuildChart.createChartPie(titleChart, dataset); panel.add(new ChartPanel(chart)); panel.setPreferredSize(new Dimension(sizeX, sizeY)); setContentPane(panel); }
From source file:QandE.Test1.java
public Component createComponents() { final JLabel label = new JLabel(labelText); /*/*from w w w . j ava 2 s . c o m*/ * An easy way to put space between a top-level container * and its contents is to put the contents in a JPanel * that has an "empty" border. */ JPanel pane = new JPanel(); pane.setBorder(BorderFactory.createEmptyBorder(30, //top 30, //left 10, //bottom 30) //right ); pane.setLayout(new GridLayout(0, 1)); pane.add(label); return pane; }
From source file:edu.stanford.smi.protegex.owl.ui.widget.HTMLEditorPanel.java
public HTMLEditorPanel(OWLModel owlModel, String text, String language) { setLayout(new BorderLayout()); ekitCore = new EkitCore(null, null, null, null, false, true, true, null, null, false, false); ekitCore.setDocumentText(text);//www .j a v a 2s. co m JPanel ekitTopPanel = new JPanel(); ekitTopPanel.setLayout(new GridLayout(2, 1)); ekitTopPanel.add(ekitCore.getMenuBar()); ekitTopPanel.add(ekitCore.getToolBar(true)); if (owlModel != null) { languageComboBox = ComponentUtil.createLanguageComboBox(owlModel, language); Box languagePanel = Box.createHorizontalBox(); languagePanel.add(new JLabel("Language: ")); languagePanel.add(languageComboBox); add(BorderLayout.SOUTH, languagePanel); } add(BorderLayout.NORTH, ekitTopPanel); add(BorderLayout.CENTER, ekitCore); }
From source file:com.emental.mindraider.ui.dialogs.AddLinkToConceptJDialog.java
/** * Constructor.//from w w w .ja v a 2s .c o m */ public AddLinkToConceptJDialog() { super("Add Link To Note"); JPanel framePanel = new JPanel(); framePanel.setLayout(new GridLayout(3, 1)); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(new JLabel(" Predicate: ")); predicateNs = new JTextField(38); predicateNs.setText("http://" + MindRaider.profile.getHostname() + "/e-mentality/conceptLink/custom#"); predicateNs.selectAll(); p.add(predicateNs); p.add(new JLabel("#")); predicateLocalName = new JTextField(15); p.add(predicateLocalName); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT)); p.add(new JLabel(" Note: ")); objectNs = new JTextField(38); objectNs.setText(""); objectNs.selectAll(); p.add(objectNs); findConceptButton = new JButton("Find Note"); findConceptButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OpenNoteJDialog.NoteToOpen conceptToOpen = new OpenNoteJDialog.NoteToOpen(); new OpenNoteJDialog("OpenNoteJDialog.titleLink", "OpenNoteJDialog.selectConceptToLink", "OpenNoteJDialog.link", null, conceptToOpen); if (conceptToOpen.conceptLabel != null) { objectNs.setText(conceptToOpen.conceptUri); } } }); p.add(findConceptButton); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton addButton = new JButton("Add"); p.add(addButton); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createTriplet(); } }); JButton cancelButton = new JButton("Cancel"); p.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AddLinkToConceptJDialog.this.dispose(); } }); framePanel.add(p); getContentPane().add(framePanel, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); }
From source file:de.dakror.virtualhub.client.dialog.ChooseCatalogDialog.java
public static void show(ClientFrame frame, final JSONArray data) { final JDialog dialog = new JDialog(frame, "Katalog whlen", true); dialog.setSize(400, 300);//from www. jav a 2 s. c o m dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { Client.currentClient.disconnect(); System.exit(0); } }); JPanel contentPane = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); dialog.setContentPane(contentPane); DefaultListModel dlm = new DefaultListModel(); for (int i = 0; i < data.length(); i++) { try { dlm.addElement(data.getJSONObject(i).getString("name")); } catch (JSONException e) { e.printStackTrace(); } } final JList catalogs = new JList(dlm); catalogs.setDragEnabled(false); catalogs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane jsp = new JScrollPane(catalogs, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); jsp.setPreferredSize(new Dimension(396, 200)); contentPane.add(jsp); JPanel mods = new JPanel(new GridLayout(1, 2)); mods.setPreferredSize(new Dimension(50, 22)); mods.add(new JButton(new AbstractAction("+") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { String name = JOptionPane.showInputDialog(dialog, "Bitte geben Sie den Namen des neuen Katalogs ein.", "Katalog hinzufgen", JOptionPane.PLAIN_MESSAGE); if (name != null && name.length() > 0) { DefaultListModel dlm = (DefaultListModel) catalogs.getModel(); for (int i = 0; i < dlm.getSize(); i++) { if (dlm.get(i).toString().equals(name)) { JOptionPane.showMessageDialog(dialog, "Es existert bereits ein Katalog mit diesem Namen!", "Katalog bereits vorhanden!", JOptionPane.ERROR_MESSAGE); actionPerformed(e); return; } } try { dlm.addElement(name); JSONObject o = new JSONObject(); o.put("name", name); o.put("sources", new JSONArray()); o.put("tags", new JSONArray()); data.put(o); Client.currentClient.sendPacket(new Packet0Catalogs(data)); } catch (Exception e1) { e1.printStackTrace(); } } } })); mods.add(new JButton(new AbstractAction("-") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { if (catalogs.getSelectedIndex() != -1) { if (JOptionPane.showConfirmDialog(dialog, "Sind Sie sicher, dass Sie diesen\r\nKatalog unwiderruflich lschen wollen?", "Katalog lschen", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { DefaultListModel dlm = (DefaultListModel) catalogs.getModel(); data.remove(catalogs.getSelectedIndex()); dlm.remove(catalogs.getSelectedIndex()); try { Client.currentClient.sendPacket(new Packet0Catalogs(data)); } catch (IOException e1) { e1.printStackTrace(); } } } } })); contentPane.add(mods); JLabel l = new JLabel(""); l.setPreferredSize(new Dimension(396, 14)); contentPane.add(l); JSeparator sep = new JSeparator(JSeparator.HORIZONTAL); sep.setPreferredSize(new Dimension(396, 10)); contentPane.add(sep); JPanel buttons = new JPanel(new GridLayout(1, 2)); buttons.setPreferredSize(new Dimension(396, 22)); buttons.add(new JButton(new AbstractAction("Abbrechen") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { Client.currentClient.disconnect(); System.exit(0); } })); buttons.add(new JButton(new AbstractAction("Katalog whlen") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { if (catalogs.getSelectedIndex() != -1) { try { Client.currentClient .setCatalog(new Catalog(data.getJSONObject(catalogs.getSelectedIndex()))); Client.currentClient.frame.setTitle("- " + Client.currentClient.getCatalog().getName()); dialog.dispose(); } catch (JSONException e1) { e1.printStackTrace(); } } } })); dialog.add(buttons); dialog.setLocationRelativeTo(frame); dialog.setResizable(false); dialog.setVisible(true); }
From source file:AlphaCompositeDemo.java
public AlphaCompositeDemo() { super();/* www . j a v a 2s .c o m*/ Container container = getContentPane(); canvas = new MyCanvas(); container.add(canvas); rulesBox = new JComboBox(rulesLabels); rulesBox.setSelectedIndex(0); rulesBox.setAlignmentX(Component.LEFT_ALIGNMENT); rulesBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); canvas.compositeRule = rules[cb.getSelectedIndex()]; canvas.repaint(); } }); slider.setPaintTicks(true); slider.setMajorTickSpacing(25); slider.setMinorTickSpacing(25); slider.setPaintLabels(true); slider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider slider = (JSlider) e.getSource(); canvas.alphaValue = (float) slider.getValue() / 100; canvas.repaint(); } }); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(1, 3)); panel.add(rulesBox); panel.add(new JLabel("Alpha Adjustment x E-2: ", JLabel.RIGHT)); panel.add(slider); container.add(panel, BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setSize(500, 300); setVisible(true); }
From source file:components.BorderDemo.java
public BorderDemo() { super(new GridLayout(1, 0)); //Keep references to the next few borders, //for use in titles and compound borders. Border blackline, raisedetched, loweredetched, raisedbevel, loweredbevel, empty; //A border that puts 10 extra pixels at the sides and //bottom of each pane. Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10); blackline = BorderFactory.createLineBorder(Color.black); raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); raisedbevel = BorderFactory.createRaisedBevelBorder(); loweredbevel = BorderFactory.createLoweredBevelBorder(); empty = BorderFactory.createEmptyBorder(); //First pane: simple borders JPanel simpleBorders = new JPanel(); simpleBorders.setBorder(paneEdge);//from ww w .ja va 2 s.c o m simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS)); addCompForBorder(blackline, "line border", simpleBorders); addCompForBorder(raisedetched, "raised etched border", simpleBorders); addCompForBorder(loweredetched, "lowered etched border", simpleBorders); addCompForBorder(raisedbevel, "raised bevel border", simpleBorders); addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders); addCompForBorder(empty, "empty border", simpleBorders); //Second pane: matte borders JPanel matteBorders = new JPanel(); matteBorders.setBorder(paneEdge); matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS)); ImageIcon icon = createImageIcon("images/wavy.gif", "wavy-line border icon"); //20x22 Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon); if (icon != null) { addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders); } else { addCompForBorder(border, "matte border (-1,-1,-1,-1,<null-icon>)", matteBorders); } border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red); addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders); border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon); if (icon != null) { addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders); } else { addCompForBorder(border, "matte border (0,20,0,0,<null-icon>)", matteBorders); } //Third pane: titled borders JPanel titledBorders = new JPanel(); titledBorders.setBorder(paneEdge); titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS)); TitledBorder titled; titled = BorderFactory.createTitledBorder("title"); addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders); titled = BorderFactory.createTitledBorder(blackline, "title"); addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(loweredetched, "title"); addCompForTitledBorder(titled, "titled lowered etched border" + " (right just., default pos.)", TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(loweredbevel, "title"); addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders); titled = BorderFactory.createTitledBorder(empty, "title"); addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders); //Fourth pane: compound borders JPanel compoundBorders = new JPanel(); compoundBorders.setBorder(paneEdge); compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS)); Border redline = BorderFactory.createLineBorder(Color.red); Border compound; compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel); addCompForBorder(compound, "compound border (two bevels)", compoundBorders); compound = BorderFactory.createCompoundBorder(redline, compound); addCompForBorder(compound, "compound border (add a red outline)", compoundBorders); titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER, TitledBorder.BELOW_BOTTOM); addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Simple", null, simpleBorders, null); tabbedPane.addTab("Matte", null, matteBorders, null); tabbedPane.addTab("Titled", null, titledBorders, null); tabbedPane.addTab("Compound", null, compoundBorders, null); tabbedPane.setSelectedIndex(0); String toolTip = new String( "<html>Blue Wavy Line border art crew:<br> Bill Pauley<br> Cris St. Aubyn<br> Ben Wronsky<br> Nathan Walrath<br> Tommy Adams, special consultant</html>"); tabbedPane.setToolTipTextAt(1, toolTip); add(tabbedPane); }
From source file:TabbedPaneDemo.java
public TabbedPaneDemo() { super(new GridLayout(1, 1)); JTabbedPane tabbedPane = new JTabbedPane(); ImageIcon icon = createImageIcon("images/middle.gif"); JComponent panel1 = makeTextPanel("Panel #1"); tabbedPane.addTab("Tab 1", icon, panel1, "Does nothing"); tabbedPane.setMnemonicAt(0, KeyEvent.VK_1); JComponent panel2 = makeTextPanel("Panel #2"); tabbedPane.addTab("Tab 2", icon, panel2, "Does twice as much nothing"); tabbedPane.setMnemonicAt(1, KeyEvent.VK_2); JComponent panel3 = makeTextPanel("Panel #3"); tabbedPane.addTab("Tab 3", icon, panel3, "Still does nothing"); tabbedPane.setMnemonicAt(2, KeyEvent.VK_3); JComponent panel4 = makeTextPanel("Panel #4 (has a preferred size of 410 x 50)."); panel4.setPreferredSize(new Dimension(410, 50)); tabbedPane.addTab("Tab 4", icon, panel4, "Does nothing at all"); tabbedPane.setMnemonicAt(3, KeyEvent.VK_4); //Add the tabbed pane to this panel. add(tabbedPane);// w ww . j a v a 2s .c om //Uncomment the following line to use scrolling tabs. //tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); }
From source file:com.joey.software.memoryToolkit.MemoryUsagePanel.java
public static JFrame getMemoryUsagePanel(int dataNum, int delay) { final MemoryUsagePanel u = new MemoryUsagePanel(dataNum, delay); JFrame f = new JFrame("Memory Usage"); f.setLayout(new BorderLayout()); f.getContentPane().add(u, BorderLayout.CENTER); f.setSize(800, 400);/*from w w w . j a va 2 s.c o m*/ f.setVisible(true); final JButton runButton = new JButton("Start"); runButton.addActionListener(new ActionListener() { boolean running = false; @Override public void actionPerformed(ActionEvent e) { if (running) { running = false; u.stopUpdating(); runButton.setText("Start"); } else { running = true; u.startUpdating(); runButton.setText("Stop"); } } }); JButton garbage = new JButton("Run GC"); garbage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.gc(); } }); JPanel temp = new JPanel(new GridLayout(1, 1)); temp.add(runButton); temp.add(garbage); f.getContentPane().add(temp, BorderLayout.SOUTH); return f; }