List of usage examples for java.awt GridLayout GridLayout
public GridLayout(int rows, int cols)
From source file:components.PasswordDemo.java
protected JComponent createButtonPanel() { JPanel p = new JPanel(new GridLayout(0, 1)); JButton okButton = new JButton("OK"); JButton helpButton = new JButton("Help"); okButton.setActionCommand(OK);// w w w. j a v a 2s . co m helpButton.setActionCommand(HELP); okButton.addActionListener(this); helpButton.addActionListener(this); p.add(okButton); p.add(helpButton); return p; }
From source file:endrov.typeTimeRemap.TimeRemapWindow.java
/** * Make a new window/*from w w w .jav a 2 s .c om*/ */ public TimeRemapWindow() { bAdd.addActionListener(this); bRefresh.addActionListener(this); objectCombo.addActionListener(this); XYDataset xyDataset = new XYSeriesCollection(frametimeSeries); JFreeChart chart = ChartFactory.createXYLineChart("", "New time", "Original time", 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(1, 2)); buttonpanel.add(bAdd); 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("Time remapper"); packEvWindow(); setBoundsEvWindow(new Rectangle(100, 100, 1000, 600)); setVisibleEvWindow(true); }
From source file:components.ScrollDemo2.java
public ScrollDemo2() { super(new BorderLayout()); area = new Dimension(0, 0); circles = new Vector<Rectangle>(); //Set up the instructions. JLabel instructionsLeft = new JLabel("Click left mouse button to place a circle."); JLabel instructionsRight = new JLabel("Click right mouse button to clear drawing area."); JPanel instructionPanel = new JPanel(new GridLayout(0, 1)); instructionPanel.setFocusable(true); instructionPanel.add(instructionsLeft); instructionPanel.add(instructionsRight); //Set up the drawing area. drawingPane = new DrawingPane(); drawingPane.setBackground(Color.white); drawingPane.addMouseListener(this); //Put the drawing area in a scroll pane. JScrollPane scroller = new JScrollPane(drawingPane); scroller.setPreferredSize(new Dimension(200, 200)); //Lay out this demo. add(instructionPanel, BorderLayout.PAGE_START); add(scroller, BorderLayout.CENTER); }
From source file:org.csml.tommo.sugar.modules.heatmap.InteractiveHeatmapDialog.java
public InteractiveHeatmapDialog(int row, int col, ResultsTable table) { super(SugarApplication.getApplication()); initData(row, col, table);/*w w w. ja va 2s . co m*/ timer = new Timer(1000, this); List<TileBPCoordinates> tileBPCoordinateList = table.getTileBPCoordinateList(row, col); int colSpan = col == table.getColumnCount() - 1 ? 1 : 2; int rowSpan = tileBPCoordinateList.size() / colSpan; centerPanel = new JPanel(new GridLayout(rowSpan, colSpan)); JPanel buttonsPanel = createButtonsPanel(); setLayout(new BorderLayout()); rebuild(); add(centerPanel, BorderLayout.CENTER); add(buttonsPanel, BorderLayout.SOUTH); setLocation(400, 350); setSize(250 * colSpan, 250 * rowSpan); }
From source file:TreeIconDemo.java
public TreeIconDemo() { super(new GridLayout(1, 0)); // Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series"); createNodes(top);//from ww w . j a v 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); // Set the icon for leaf nodes. ImageIcon leafIcon = createImageIcon("images/middle.gif"); if (leafIcon != null) { DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer(); renderer.setLeafIcon(leafIcon); tree.setCellRenderer(renderer); } else { System.err.println("Leaf 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:edu.cornell.mannlib.vitro.webapp.imageprocessor.jai.JaiImageProcessorTester2.java
public JaiImageProcessorTester2(String imagePath, CropDataSet cropDataSet) { this.imagePath = imagePath; this.thumbnailer = new JaiImageProcessor(); setTitle("Cropping edging test"); addWindowListener(new CloseWindowListener()); setLayout(new GridLayout(ROWS, COLUMNS)); for (CropData cropData : cropDataSet.crops()) { add(createImagePanel(cropData)); }//w ww . ja v a2 s.co m pack(); setVisible(true); }
From source file:org.gumtree.vis.awt.AbstractPlotEditor.java
private JPanel createHelpPanel() { JPanel wrap = new JPanel(new GridLayout(1, 1)); JPanel helpPanel = new JPanel(new GridLayout(1, 1)); helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // helpPanel.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "Help Topics")); SpringLayout spring = new SpringLayout(); JPanel inner = new JPanel(spring); inner.setBorder(BorderFactory.createEmptyBorder()); final IHelpProvider provider = plot.getHelpProvider(); final JList list = new JList(provider.getHelpMap().keySet().toArray()); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // list.setBorder(BorderFactory.createEtchedBorder()); JScrollPane listPane1 = new JScrollPane(list); inner.add(listPane1);/*w w w. j av a 2 s. c om*/ listPane1.setMaximumSize(new Dimension(140, 0)); listPane1.setMinimumSize(new Dimension(70, 0)); // JPanel contentPanel = new JPanel(new GridLayout(2, 1)); // inner.add(list); final JTextField keyField = new JTextField(); keyField.setMaximumSize(new Dimension(400, 20)); keyField.setEditable(false); // keyField.setMaximumSize(); // keyArea.setLineWrap(true); // keyArea.setWrapStyleWord(true); // keyArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(keyField); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); final JTextArea helpArea = new JTextArea(); JScrollPane areaPane = new JScrollPane(helpArea); helpArea.setEditable(false); helpArea.setLineWrap(true); helpArea.setWrapStyleWord(true); // helpArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(areaPane); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); // inner.add(contentPanel); spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner); spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField); spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField); spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner); spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane); spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Object[] selected = list.getSelectedValues(); if (selected.length >= 0) { HelpObject help = provider.getHelpMap().get(selected[0]); if (help != null) { keyField.setText(help.getKey()); helpArea.setText(help.getDiscription()); } } } }); helpPanel.add(inner, BorderLayout.NORTH); wrap.setName("Help"); wrap.add(helpPanel, BorderLayout.NORTH); return wrap; }
From source file:com.game.ui.views.MapPanel.java
public void buildMap(MapInformation Map) throws IOException { getMapInformation(Map);/*from ww w .ja v a 2s .co m*/ mapPanel = new JPanel(); mapPanel.setLayout(new GridLayout(mapRows, mapColumns)); tile = new JButton[mapRows * mapColumns]; commandCounter = 1; for (int x = 0; x < mapRows; x++) { for (int y = 0; y < mapColumns; y++) { tile[commandCounter - 1] = new JButton(); (tile[commandCounter - 1]).setActionCommand("" + commandCounter); tile[commandCounter - 1].addActionListener(this); mapPanel.add(tile[commandCounter - 1]); tileInformation = pathMap.get(commandCounter); if (tileInformation != null) { mapPathPoints(); if (tileInformation.isEndTile()) { mapEndPoints(); } if (tileInformation.isStartTile()) { mapStartPoints(); numberofPlayers++; } if (tileInformation.getEnemy() != null) { mapEnemyPoints(tileInformation); numberofEnemys++; } } commandCounter++; } } UIManager.installLookAndFeel("SeaGlass", "com.seaglasslookandfeel.SeaGlassLookAndFeel"); wrapperPanel.add(mapPanel, BorderLayout.CENTER); add(wrapperPanel); pack(); setExtendedState(JFrame.MAXIMIZED_BOTH); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); setMaximizedBounds(env.getMaximumWindowBounds()); setVisible(true); }
From source file:Unicode.java
/** Construct the object including its GUI */ public Unicode() { super("Unicode"); Container cp = getContentPane(); // Used both for Buttons and Menus ResourceBundle b = ResourceBundle.getBundle("UnicodeWidgets"); JButton quitButton, nextButton, prevButton; Panel p = new Panel(); // Make a grid, add one for labels. p.setLayout(new GridLayout(ROWS + 1, COLUMNS + 1)); DecimalFormat df2d = new DecimalFormat("00"); // Add first row, just column labels. p.add(new JLabel("")); for (int i = 0; i < COLUMNS; i++) p.add(new JLabel(Integer.toString(i, 16), JLabel.CENTER)); // Add subsequent rows, each with an offset label for (int i = 0; i < ROWS; i++) { JLabel l = new JLabel("0000"); // room for max, i.e. \uFFFF p.add(l);//from ww w .ja va2 s .co m rowLabs[i] = l; for (int j = 0; j < COLUMNS; j++) { JLabel pb = new JLabel(" "); buttons[j][i] = pb; p.add(pb); } } // ActionListeners for jumping around; used by buttons and menus ActionListener firster = new ActionListener() { public void actionPerformed(ActionEvent e) { gotoPage(startNum = 0); } }; ActionListener previouser = new ActionListener() { public void actionPerformed(ActionEvent e) { if (startNum > 0) gotoPage(startNum -= QUADSIZE); } }; ActionListener nexter = new ActionListener() { public void actionPerformed(ActionEvent e) { if (startNum < 65535) gotoPage(startNum += QUADSIZE); } }; ActionListener laster = new ActionListener() { public void actionPerformed(ActionEvent e) { gotoPage(65536 - QUADSIZE); } }; cp.add(BorderLayout.NORTH, p); fontName = new JLabel("Default font", JLabel.CENTER); cp.add(BorderLayout.CENTER, fontName); Panel q = new Panel(); cp.add(BorderLayout.SOUTH, q); q.add(prevButton = mkButton(b, "page.prev")); prevButton.addActionListener(previouser); q.add(nextButton = mkButton(b, "page.next")); nextButton.addActionListener(nexter); q.add(quitButton = mkButton(b, "exit")); quitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); dispose(); System.exit(0); } }); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { setVisible(false); dispose(); System.exit(0); } }); MenuItem mi; // used in various spots MenuBar mb = new MenuBar(); setMenuBar(mb); String titlebar; try { titlebar = b.getString("program" + ".title"); } catch (MissingResourceException e) { titlebar = "Unicode Demo"; } setTitle(titlebar); ActionListener fontSelector = new ActionListener() { public void actionPerformed(ActionEvent e) { String font = e.getActionCommand(); mySetFont(font, FONTSIZE); } }; Menu fontMenu = mkMenu(b, "font"); // String[] fontList = Toolkit.getDefaultToolkit().getFontList(); String[] fontList = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); for (int i = 0; i < fontList.length; i++) { fontMenu.add(mi = new MenuItem(fontList[i])); mi.addActionListener(fontSelector); } mb.add(fontMenu); gotoPageUI = new GoToPage("Unicode Page"); centre(gotoPageUI); Menu vm = mkMenu(b, "page"); vm.add(mi = mkMenuItem(b, "page", "first")); mi.addActionListener(firster); vm.add(mi = mkMenuItem(b, "page", "prev")); mi.addActionListener(previouser); vm.add(mi = mkMenuItem(b, "page", "next")); mi.addActionListener(nexter); vm.add(mi = mkMenuItem(b, "page", "last")); mi.addActionListener(laster); vm.add(mi = mkMenuItem(b, "page", "goto")); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Unicode.this.gotoPageUI.setVisible(true); } }); mb.add(vm); Menu hm = mkMenu(b, "help"); hm.add(mi = mkMenuItem(b, "help", "about")); mb.setHelpMenu(hm); // needed for portability (Motif, etc.). pack(); // After packing the Frame, centre it on the screen. centre(this); // start at a known place mySetFont(fontList[0], FONTSIZE); gotoPage(startNum); }
From source file:components.TreeIconDemo.java
public TreeIconDemo() { super(new GridLayout(1, 0)); //Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series"); createNodes(top);// w w w .java2s . c om //Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); //Set the icon for leaf nodes. ImageIcon leafIcon = createImageIcon("images/middle.gif"); if (leafIcon != null) { DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer(); renderer.setLeafIcon(leafIcon); tree.setCellRenderer(renderer); } else { System.err.println("Leaf 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); }