List of usage examples for java.awt GridLayout GridLayout
public GridLayout(int rows, int cols)
From source file:TableDialogEditDemo.java
public TableDialogEditDemo() { super(new GridLayout(1, 0)); JTable table = new JTable(new MyTableModel()); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); //Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); //Set up renderer and editor for the Favorite Color column. table.setDefaultRenderer(Color.class, new ColorRenderer(true)); table.setDefaultEditor(Color.class, new ColorEditor()); //Add the scroll pane to this panel. add(scrollPane);//from w ww . j a va 2 s .c om }
From source file:endrov.frameTime.FrameTimeWindow.java
/** * Make a new window at some specific location */// www.j a v a2 s . c om public FrameTimeWindow(Rectangle bounds) { bAdd.addActionListener(this); bApply.addActionListener(this); bRefresh.addActionListener(this); objectCombo.addActionListener(this); XYDataset xyDataset = new XYSeriesCollection(frametimeSeries); JFreeChart chart = ChartFactory.createXYLineChart("", "Time", "Frame", xyDataset, PlotOrientation.HORIZONTAL, false/*legend*/, false/*tooltips*/, false/*urls*/); ChartPanel graphpanel = new ChartPanel(chart); //Put GUI together JPanel datapanel = new JPanel(new BorderLayout()); JPanel dataparto = new JPanel(new BorderLayout()); dataparto.add(datapart, BorderLayout.NORTH); JScrollPane datapartscroll = new JScrollPane(dataparto, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); JPanel buttonpanel = new JPanel(new GridLayout(2, 2)); buttonpanel.add(bAdd); buttonpanel.add(bApply); buttonpanel.add(bRefresh); datapanel.add(buttonpanel, BorderLayout.SOUTH); datapanel.add(datapartscroll, BorderLayout.CENTER); setLayout(new BorderLayout()); add(datapanel, BorderLayout.EAST); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.add(graphpanel, BorderLayout.CENTER); leftPanel.add(objectCombo, BorderLayout.SOUTH); add(leftPanel, BorderLayout.CENTER); loadData(); //Window overall things setTitleEvWindow("Frame/Time"); packEvWindow(); setVisibleEvWindow(true); setBoundsEvWindow(bounds); }
From source file:TextCutPaste.java
public TextCutPaste() { super(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); // Create the transfer handler. TextTransferHandler th = new TextTransferHandler(); // Create some text fields. JPanel buttonPanel = new JPanel(new GridLayout(3, 1)); JTextField textField = new JTextField("Cut, copy and paste...", 30); textField.setTransferHandler(th);//from www .ja va 2 s.c o m textField.setDragEnabled(true); buttonPanel.add(textField); textField = new JTextField("or drag and drop...", 30); textField.setTransferHandler(th); textField.setDragEnabled(true); buttonPanel.add(textField); textField = new JTextField("from any of these text fields.", 30); textField.setTransferHandler(th); textField.setDragEnabled(true); buttonPanel.add(textField); add(buttonPanel, BorderLayout.CENTER); }
From source file:GraphPanel.java
/** * create an instance of a simple graph in two views with controls to * demo the zoom features.//from w ww. ja v a 2 s .c o m * */ @SuppressWarnings("unchecked") public GraphPanel(Graph<V, E> graph) { super(new GridLayout(1, 0)); this.graph = graph; //TestGraphs.getOneComponentGraph(); // create one layout for the graph //ISOMLayout<AbstractAgent,Number> layout = new ISOMLayout<AbstractAgent,Number>(graph); CircleLayout<V, E> layout = new CircleLayout<V, E>(graph); // create one model that all 3 views will share DefaultVisualizationModel<V, E> visualizationModel = new DefaultVisualizationModel<V, E>(layout, preferredSize); // create 3 views that share the same model vv1 = new VisualizationViewer<V, E>(visualizationModel, preferredSize); vv1.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); // this class will provide both label drawing and vertex shapes VertexLabelAsShapeRenderer<V, E> vlasr = new VertexLabelAsShapeRenderer<V, E>(vv1.getRenderContext()); // customize the render context vv1.getRenderContext().setVertexLabelTransformer( // this chains together Transformers so that the html tags // are prepended to the toString method output new Transformer<V, String>() { public String transform(V input) { return input.toString(); } }); vv1.getRenderContext().setVertexShapeTransformer(vlasr); vv1.getRenderer().setVertexLabelRenderer(vlasr); vv1.getRenderer().setVertexRenderer(new GradientVertexRenderer<V, E>(Color.gray, Color.white, true)); vv1.setBackground(Color.white); final JPanel p1 = new JPanel(new BorderLayout()); p1.add(new GraphZoomScrollPane(vv1)); /* JButton h1 = new JButton("?"); h1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textArea.setText(messageOne); JOptionPane.showMessageDialog(p1, scrollPane, "View 1", JOptionPane.PLAIN_MESSAGE); }}); */ // create a GraphMouse for each view // each one has a different scaling plugin /* DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse() { protected void loadPlugins() { pickingPlugin = new PickingGraphMousePlugin(); animatedPickingPlugin = new AnimatedPickingGraphMousePlugin(); translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK); scalingPlugin = new ScalingGraphMousePlugin(new LayoutScalingControl(), 0); rotatingPlugin = new RotatingGraphMousePlugin(); shearingPlugin = new ShearingGraphMousePlugin(); add(scalingPlugin); setMode(Mode.TRANSFORMING); } }; vv1.setGraphMouse(gm1); vv1.setToolTipText("<html><center>MouseWheel Scales Layout</center></html>"); */ this.add(p1); //content.add(panel); }
From source file:Main.java
public DynamicTree() { super(new GridLayout(1, 0)); treeModel.addTreeModelListener(new MyTreeModelListener()); tree = new JTree(treeModel); tree.setEditable(true);/* ww w . jav a 2s. co m*/ tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setShowsRootHandles(true); JScrollPane scrollPane = new JScrollPane(tree); add(scrollPane); }
From source file:appletComponentArch.DynamicTreePanel.java
public DynamicTreePanel() { super(new BorderLayout()); //Create the components. treePanel = new DynamicTree(); populateTree(treePanel);//from w w w . ja v a 2s . c o m JButton addButton = new JButton("Add"); addButton.setActionCommand(ADD_COMMAND); addButton.addActionListener(this); JButton removeButton = new JButton("Remove"); removeButton.setActionCommand(REMOVE_COMMAND); removeButton.addActionListener(this); JButton clearButton = new JButton("Clear"); clearButton.setActionCommand(CLEAR_COMMAND); clearButton.addActionListener(this); //Lay everything out. treePanel.setPreferredSize(new Dimension(300, 150)); add(treePanel, BorderLayout.CENTER); JPanel panel = new JPanel(new GridLayout(0, 3)); panel.add(addButton); panel.add(removeButton); panel.add(clearButton); add(panel, BorderLayout.SOUTH); }
From source file:de.fhg.iais.asc.ui.parts.TransformersPanel.java
public TransformersPanel(MyCortexModel myCortexModel, SipMakerFactory sipMakerFactory) { super(new GridLayout(2, 1)); this.sipMakerFactory = sipMakerFactory; init(myCortexModel);/*from w w w .java2 s . co m*/ this.myCortexModel = myCortexModel; myCortexModel.addObserver(this); update(myCortexModel, null); }
From source file:TreeIconDemo2.java
public TreeIconDemo2() { super(new GridLayout(1, 0)); //Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series"); createNodes(top);/*from www. jav a 2 s . co m*/ //Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); //Enable tool tips. ToolTipManager.sharedInstance().registerComponent(tree); //Set the icon for leaf nodes. ImageIcon tutorialIcon = createImageIcon("images/middle.gif"); if (tutorialIcon != null) { tree.setCellRenderer(new MyRenderer(tutorialIcon)); } else { System.err.println("Tutorial icon missing; using default."); } //Listen for when the selection changes. tree.addTreeSelectionListener(this); //Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); //Create the HTML viewing pane. htmlPane = new JEditorPane(); htmlPane.setEditable(false); initHelp(); JScrollPane htmlView = new JScrollPane(htmlPane); //Add the scroll panes to a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(htmlView); Dimension minimumSize = new Dimension(100, 50); htmlView.setMinimumSize(minimumSize); treeView.setMinimumSize(minimumSize); splitPane.setDividerLocation(100); //XXX: ignored in some releases //of Swing. bug 4101306 //workaround for bug 4101306: //treeView.setPreferredSize(new Dimension(100, 100)); splitPane.setPreferredSize(new Dimension(500, 300)); //Add the split pane to this panel. add(splitPane); }
From source file:com.springsource.samples.resttemplate.FlickrClient.java
private void showPhotos(String searchTerm, List<BufferedImage> imageList) { JFrame frame = new JFrame(searchTerm + " photos"); frame.setLayout(new GridLayout(2, imageList.size() / 2)); for (BufferedImage image : imageList) { if (image != null) frame.add(new JLabel(new ImageIcon(image))); }/*from www. j av a2 s. c om*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public Main() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); // Initialize an empty list of buttons. buttonList = new Vector<JButton>(10, 10); // Create all the components. addButton = new JButton("Add a button"); addButton.setActionCommand(ADD);//from ww w . j a v a 2 s . c om addButton.addActionListener(this); removeButton = new JButton("Remove a button"); removeButton.setActionCommand(REMOVE); removeButton.addActionListener(this); buttonPanel = new JPanel(new GridLayout(1, 1)); buttonPanel.setPreferredSize(new Dimension(200, 75)); buttonPanel.addContainerListener(this); display = new JTextArea(); display.setEditable(false); JScrollPane scrollPane = new JScrollPane(display); scrollPane.setPreferredSize(new Dimension(200, 75)); clearButton = new JButton("Clear text area"); clearButton.setActionCommand(CLEAR); clearButton.addActionListener(this); c.fill = GridBagConstraints.BOTH; // Fill entire cell. c.weighty = 1.0; // Button area and message area have equal height. c.gridwidth = GridBagConstraints.REMAINDER; // end of row gridbag.setConstraints(scrollPane, c); add(scrollPane); c.weighty = 0.0; gridbag.setConstraints(clearButton, c); add(clearButton); c.weightx = 1.0; // Add/remove buttons have equal width. c.gridwidth = 1; // NOT end of row gridbag.setConstraints(addButton, c); add(addButton); c.gridwidth = GridBagConstraints.REMAINDER; // end of row gridbag.setConstraints(removeButton, c); add(removeButton); c.weighty = 1.0; // Button area and message area have equal height. gridbag.setConstraints(buttonPanel, c); add(buttonPanel); setPreferredSize(new Dimension(400, 400)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }