List of usage examples for java.awt GridLayout GridLayout
public GridLayout(int rows, int cols)
From source file:lospolloshermanos.BarChart.java
public BarChart(String title, int no_of_items, ResultSet result) { // super(title); this.Title = title; this.result = result; this.no_of_items = no_of_items; if (title.equals("Categories")) { CategoryDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(900, 300)); this.Title = "Categories 2"; CategoryDataset dataset2 = createDataset(); JFreeChart chart2 = createChart(dataset2); ChartPanel chartPanel2 = new ChartPanel(chart2, false); chartPanel2.setPreferredSize(new Dimension(900, 300)); this.setLayout(new GridLayout(2, 1)); this.add(chartPanel); this.add(chartPanel2); } else if (title.equals("Items")) { CategoryDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(900, 300)); this.Title = "Items 2"; CategoryDataset dataset2 = createDataset(); JFreeChart chart2 = createChart(dataset2); ChartPanel chartPanel2 = new ChartPanel(chart2, false); chartPanel2.setPreferredSize(new Dimension(900, 300)); this.setLayout(new GridLayout(2, 1)); this.add(chartPanel); this.add(chartPanel2); } else if (title.equals("Ratings")) { CategoryDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(900, 300)); this.setLayout(new GridLayout(1, 1)); this.add(chartPanel); }/*from w w w. j ava 2s .c o m*/ // setContentPane(chartPanel); // this.setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); }
From source file:GroupRadio.java
public static Container createRadioButtonGrouping(String elements[], String title, ActionListener actionListener, ItemListener itemListener, ChangeListener changeListener) { JPanel panel = new JPanel(new GridLayout(0, 1)); // If title set, create titled border if (title != null) { Border border = BorderFactory.createTitledBorder(title); panel.setBorder(border);/*w ww. j a va 2s. c om*/ } // Create group ButtonGroup group = new ButtonGroup(); JRadioButton aRadioButton; // For each String passed in: // Create button, add to panel, and add to group for (int i = 0, n = elements.length; i < n; i++) { aRadioButton = new JRadioButton(elements[i]); panel.add(aRadioButton); group.add(aRadioButton); if (actionListener != null) { aRadioButton.addActionListener(actionListener); } if (itemListener != null) { aRadioButton.addItemListener(itemListener); } if (changeListener != null) { aRadioButton.addChangeListener(changeListener); } } return panel; }
From source file:dnd.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. j av a2s . 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:org.csml.tommo.sugar.modules.heatmap.DensityHeatmapDialog.java
public DensityHeatmapDialog(int row, int col, DensityResultsTable densityResultsTable) { super(SugarApplication.getApplication()); initData(row, col, densityResultsTable); List<TileBPCoordinates> tileBPCoordinateList = densityResultsTable.getTileBPCoordinateList(row, col); int colSpan = col == densityResultsTable.getColumnCount() - 1 ? 1 : 2; int rowSpan = tileBPCoordinateList.size() / colSpan; centerPanel = new JPanel(new GridLayout(rowSpan, colSpan)); setLayout(new BorderLayout()); rebuild();/*from ww w . j a va2s . c o m*/ add(centerPanel, BorderLayout.CENTER); setLocation(400, 350); setSize(250 * colSpan, 250 * rowSpan); }
From source file:org.csml.tommo.sugar.modules.heatmap.MappingQualityThresholdDialog.java
public MappingQualityThresholdDialog(int row, int col, MappingQualityTable table, int threshold) { super(SugarApplication.getApplication()); initData(row, col, table, threshold); List<TileCoordinates> tileCoordinateList = table.getTileCoordinateList(row, col); int colSpan = col == table.getColumnCount() - 1 ? 1 : 2; int rowSpan = tileCoordinateList.size() / colSpan; centerPanel = new JPanel(new GridLayout(rowSpan, colSpan)); setLayout(new BorderLayout()); rebuild();//w w w . j av a2s. c o m add(centerPanel, BorderLayout.CENTER); setLocation(400, 350); setSize(250 * colSpan, 250 * rowSpan); }
From source file:com.thoughtworks.go.agent.bootstrapper.osx.MacAboutBox.java
public MacAboutBox() { super(""); setResizable(false);//from ww w.j a v a 2 s.c o m addWindowListener(new SymWindow()); getContentPane().setLayout(new BorderLayout(15, 15)); List<JLabel> aboutLabels = new ArrayList<JLabel>(); aboutLabels.add(emptyLabel()); aboutLabels.add(titleLabel("Go Agent")); aboutLabels.add(bodyLabel("Bootstrapper Version " + getBootstrapperVersion())); aboutLabels.add(emptyLabel()); aboutLabels.add(bodyLabel("Java Version " + System.getProperty("java.version"))); aboutLabels.add(bodyLabel("Copyright (C) 2015 ThoughtWorks Inc.")); aboutLabels.add(emptyLabel()); Panel textPanel2 = new Panel(new GridLayout(aboutLabels.size(), 1)); for (JLabel aboutLabel : aboutLabels) { textPanel2.add(aboutLabel); } getContentPane().add(textPanel2, BorderLayout.CENTER); pack(); setLocation(FRAME_LEFT, FRAME_TOP); setSize(FRAME_WIDTH, FRAME_HEIGHT); setResizable(false); }
From source file:LabelDnD.java
public LabelDnD() { super(new GridLayout(2, 1)); textField = new JTextField(40); textField.setDragEnabled(true);/*from ww w.j av a2s . c o m*/ JPanel tfpanel = new JPanel(new GridLayout(1, 1)); TitledBorder t1 = BorderFactory.createTitledBorder("JTextField: drag and drop is enabled"); tfpanel.add(textField); tfpanel.setBorder(t1); label = new JLabel("I'm a Label!", SwingConstants.LEADING); label.setTransferHandler(new TransferHandler("text")); MouseListener listener = new DragMouseAdapter(); label.addMouseListener(listener); JPanel lpanel = new JPanel(new GridLayout(1, 1)); TitledBorder t2 = BorderFactory.createTitledBorder("JLabel: drag from or drop to this label"); lpanel.add(label); lpanel.setBorder(t2); add(tfpanel); add(lpanel); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
From source file:components.TableDialogEditDemo.java
public TableDialogEditDemo() { super(new GridLayout(1, 0)); JTable table = new JTable(new MyTableModel()); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); table.setFillsViewportHeight(true);/*from ww w . j a va 2 s . c o m*/ //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 source file:BookTree.java
public BookCellRenderer() { renderer = new JPanel(new GridLayout(0, 1)); titleLabel = new JLabel(" "); titleLabel.setForeground(Color.blue); renderer.add(titleLabel);/* w w w .j a va 2 s . c o m*/ authorsLabel = new JLabel(" "); authorsLabel.setForeground(Color.blue); renderer.add(authorsLabel); priceLabel = new JLabel(" "); priceLabel.setHorizontalAlignment(JLabel.RIGHT); priceLabel.setForeground(Color.red); renderer.add(priceLabel); renderer.setBorder(BorderFactory.createLineBorder(Color.black)); backgroundSelectionColor = defaultRenderer.getBackgroundSelectionColor(); backgroundNonSelectionColor = defaultRenderer.getBackgroundNonSelectionColor(); }
From source file:BorderTest.java
public BorderFrame() { setTitle("BorderTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); demoPanel = new JPanel(); buttonPanel = new JPanel(); group = new ButtonGroup(); addRadioButton("Lowered bevel", BorderFactory.createLoweredBevelBorder()); addRadioButton("Raised bevel", BorderFactory.createRaisedBevelBorder()); addRadioButton("Etched", BorderFactory.createEtchedBorder()); addRadioButton("Line", BorderFactory.createLineBorder(Color.BLUE)); addRadioButton("Matte", BorderFactory.createMatteBorder(10, 10, 10, 10, Color.BLUE)); addRadioButton("Empty", BorderFactory.createEmptyBorder()); Border etched = BorderFactory.createEtchedBorder(); Border titled = BorderFactory.createTitledBorder(etched, "Border types"); buttonPanel.setBorder(titled);/*from ww w .jav a 2 s . c om*/ setLayout(new GridLayout(2, 1)); add(buttonPanel); add(demoPanel); }