List of usage examples for java.awt GridLayout GridLayout
public GridLayout(int rows, int cols)
From source file:org.jfree.chart.demo.PlotOrientationDemo2.java
/** * Creates a new demo instance./*from www. j a v a 2 s .c om*/ * * @param title the frame title. */ public PlotOrientationDemo2(String title) { super(title); JPanel panel = new JPanel(new GridLayout(2, 4)); for (int i = 0; i < CHART_COUNT; i++) { this.datasets[i] = createDataset(i); this.charts[i] = createChart(i, this.datasets[i]); XYPlot plot = this.charts[i].getXYPlot(); XYShapeAnnotation a1 = new XYShapeAnnotation(new Rectangle2D.Double(1.0, 2.0, 2.0, 3.0), new BasicStroke(1.0f), Color.blue); XYLineAnnotation a2 = new XYLineAnnotation(0.0, -5.0, 10.0, -5.0); plot.addAnnotation(a1); plot.addAnnotation(a2); plot.addDomainMarker(new IntervalMarker(5.0, 10.0), Layer.BACKGROUND); plot.addRangeMarker(new IntervalMarker(-2.0, 0.0), Layer.BACKGROUND); this.panels[i] = new ChartPanel(this.charts[i]); } this.charts[1].getXYPlot().getDomainAxis().setInverted(true); this.charts[2].getXYPlot().getRangeAxis().setInverted(true); this.charts[3].getXYPlot().getDomainAxis().setInverted(true); this.charts[3].getXYPlot().getRangeAxis().setInverted(true); this.charts[5].getXYPlot().getDomainAxis().setInverted(true); this.charts[6].getXYPlot().getRangeAxis().setInverted(true); this.charts[4].getXYPlot().getDomainAxis().setInverted(true); this.charts[4].getXYPlot().getRangeAxis().setInverted(true); this.charts[4].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); this.charts[5].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); this.charts[6].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); this.charts[7].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); panel.add(this.panels[0]); panel.add(this.panels[1]); panel.add(this.panels[4]); panel.add(this.panels[5]); panel.add(this.panels[2]); panel.add(this.panels[3]); panel.add(this.panels[6]); panel.add(this.panels[7]); panel.setPreferredSize(new Dimension(800, 600)); setContentPane(panel); }
From source file:TrackEvent.java
public void init() { Container c = getContentPane(); c.setLayout(new GridLayout(event.length + 1, 2)); for (int i = 0; i < event.length; i++) { JTextField t = new JTextField(); t.setEditable(false);//from ww w . j a v a 2s .c om c.add(new JLabel(event[i], JLabel.RIGHT)); c.add(t); h.put(event[i], t); } c.add(b1); c.add(b2); }
From source file:OptionDialogTest.java
public OptionDialogFrame() { setTitle("OptionDialogTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); JPanel gridPanel = new JPanel(); gridPanel.setLayout(new GridLayout(2, 3)); typePanel = new ButtonPanel("Type", "Message", "Confirm", "Option", "Input"); messageTypePanel = new ButtonPanel("Message Type", "ERROR_MESSAGE", "INFORMATION_MESSAGE", "WARNING_MESSAGE", "QUESTION_MESSAGE", "PLAIN_MESSAGE"); messagePanel = new ButtonPanel("Message", "String", "Icon", "Component", "Other", "Object[]"); optionTypePanel = new ButtonPanel("Confirm", "DEFAULT_OPTION", "YES_NO_OPTION", "YES_NO_CANCEL_OPTION", "OK_CANCEL_OPTION"); optionsPanel = new ButtonPanel("Option", "String[]", "Icon[]", "Object[]"); inputPanel = new ButtonPanel("Input", "Text field", "Combo box"); gridPanel.add(typePanel);//from ww w . j a v a2 s. com gridPanel.add(messageTypePanel); gridPanel.add(messagePanel); gridPanel.add(optionTypePanel); gridPanel.add(optionsPanel); gridPanel.add(inputPanel); // add a panel with a Show button JPanel showPanel = new JPanel(); JButton showButton = new JButton("Show"); showButton.addActionListener(new ShowAction()); showPanel.add(showButton); add(gridPanel, BorderLayout.CENTER); add(showPanel, BorderLayout.SOUTH); }
From source file:DragColorDemo.java
public DragColorDemo() { super(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); JColorChooser chooser = new JColorChooser(); chooser.setDragEnabled(true);/*from www . j a va 2 s . c o m*/ add(chooser, BorderLayout.PAGE_START); //Create the color transfer handler. colorHandler = new ColorTransferHandler(); //Create a matrix of 9 buttons. JPanel buttonPanel = new JPanel(new GridLayout(3, 3)); for (int i = 0; i < 9; i++) { JButton tmp = new JButton("Button " + i); tmp.setTransferHandler(colorHandler); buttonPanel.add(tmp); } add(buttonPanel, BorderLayout.CENTER); //Create a check box. toggleForeground = new JCheckBox("Change the foreground color."); toggleForeground.setSelected(true); toggleForeground.addActionListener(this); JPanel textPanel = new JPanel(new BorderLayout()); textPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); textPanel.add(toggleForeground, BorderLayout.PAGE_START); //Create a label. JLabel label = new JLabel("Change the color of any button or this label by dropping a color."); label.setTransferHandler(colorHandler); label.setOpaque(true); //So the background color can be changed. textPanel.add(label, BorderLayout.PAGE_END); add(textPanel, BorderLayout.PAGE_END); }
From source file:MainClass.java
public MainClass() { super("Selection Model Test"); setSize(450, 350);/*w w w. j a v a2 s . co m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); TableModel tm = new AbstractTableModel() { public int getRowCount() { return 10; } public int getColumnCount() { return 10; } public Object getValueAt(int r, int c) { return "0"; } }; final JTable jt = new JTable(tm); JScrollPane jsp = new JScrollPane(jt); getContentPane().add(jsp, BorderLayout.CENTER); JPanel controlPanel, buttonPanel, columnPanel, rowPanel; buttonPanel = new JPanel(); final JCheckBox cellBox, columnBox, rowBox; cellBox = new JCheckBox("Cells", jt.getCellSelectionEnabled()); columnBox = new JCheckBox("Columns", jt.getColumnSelectionAllowed()); rowBox = new JCheckBox("Rows", jt.getRowSelectionAllowed()); cellBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { jt.setCellSelectionEnabled(cellBox.isSelected()); columnBox.setSelected(jt.getColumnSelectionAllowed()); rowBox.setSelected(jt.getRowSelectionAllowed()); } }); columnBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { jt.setColumnSelectionAllowed(columnBox.isSelected()); cellBox.setSelected(jt.getCellSelectionEnabled()); } }); rowBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { jt.setRowSelectionAllowed(rowBox.isSelected()); cellBox.setSelected(jt.getCellSelectionEnabled()); } }); buttonPanel.add(new JLabel("Selections allowed:")); buttonPanel.add(cellBox); buttonPanel.add(columnBox); buttonPanel.add(rowBox); columnPanel = new JPanel(); ListSelectionModel csm = jt.getColumnModel().getSelectionModel(); JLabel columnCounter = new JLabel("Selected Column Indices:"); csm.addListSelectionListener(new SelectionDebugger(columnCounter, csm)); columnPanel.add(new JLabel("Selected columns:")); columnPanel.add(columnCounter); rowPanel = new JPanel(); ListSelectionModel rsm = jt.getSelectionModel(); JLabel rowCounter = new JLabel("Selected Row Indices:"); rsm.addListSelectionListener(new SelectionDebugger(rowCounter, rsm)); rowPanel.add(new JLabel("Selected rows:")); rowPanel.add(rowCounter); controlPanel = new JPanel(new GridLayout(0, 1)); controlPanel.add(buttonPanel); controlPanel.add(columnPanel); controlPanel.add(rowPanel); getContentPane().add(controlPanel, BorderLayout.SOUTH); }
From source file:playground.artemc.calibration.charts.CustomChartPanel.java
protected void createUIComponents() { int size = Math.min(layoutInstructions.getColumns() * layoutInstructions.getRows(), charts.size()); this.setLayout(new GridLayout(layoutInstructions.getRows(), layoutInstructions.getColumns())); for (int i = 0; i < size; i++) { System.err.println("Adding chart"); ChartPanel chartPanel = new ChartPanel(charts.get(i)); chartPanel.setMaximumDrawHeight(20000); chartPanel.setMinimumDrawHeight(0); chartPanel.setMaximumDrawWidth(20000); chartPanel.setMinimumDrawWidth(0); chartPanel.setPopupMenu(null);//from w ww. j a va 2 s. c o m panels.add(chartPanel); this.add(chartPanel); } }
From source file:org.jfree.chart.demo.AxisOffsetsDemo1.java
public static JPanel createDemoPanel() { JFreeChart jfreechart = createChart("Axis Offsets: 0", createDataset()); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setAxisOffset(RectangleInsets.ZERO_INSETS); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setMinimumDrawWidth(0);/*from w w w .ja v a 2 s . c o m*/ chartpanel.setMinimumDrawHeight(0); JFreeChart jfreechart1 = createChart("Axis Offsets: 5", createDataset()); ChartPanel chartpanel1 = new ChartPanel(jfreechart1); chartpanel1.setMinimumDrawWidth(0); chartpanel1.setMinimumDrawHeight(0); CategoryPlot categoryplot1 = (CategoryPlot) jfreechart1.getPlot(); categoryplot1.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); DemoPanel demopanel = new DemoPanel(new GridLayout(2, 1)); demopanel.add(chartpanel); demopanel.add(chartpanel1); demopanel.addChart(jfreechart); demopanel.addChart(jfreechart1); return demopanel; }
From source file:logdruid.ui.table.EventRecordingEditorTable.java
/** * @wbp.parser.constructor/* ww w. j a v a 2 s . c o m*/ */ @SuppressWarnings("unchecked") public EventRecordingEditorTable(JTextPane textPane) { super(new GridLayout(1, 0)); model = new MyTableModel(data, header); table = new JTable(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setFont(new Font("SansSerif", Font.PLAIN, 11)); // table.setPreferredScrollableViewportSize(new Dimension(500, 200)); table.setPreferredScrollableViewportSize(table.getPreferredSize()); table.setFillsViewportHeight(true); this.theLine = textPane.getText(); this.examplePane = textPane; // Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); // Set up column sizes. initColumnSizes(table); // Fiddle with the type and processing column's cell editors/renderers. setUpTypeColumn(table, table.getColumnModel().getColumn(2)); setUpProcessingColumn(table, table.getColumnModel().getColumn(3)); // Add the scroll pane to this panel. add(scrollPane); Add(); FixValues(); }
From source file:components.CrayonPanel.java
protected void buildChooser() { setLayout(new GridLayout(0, 1)); ButtonGroup boxOfCrayons = new ButtonGroup(); Border border = BorderFactory.createEmptyBorder(4, 4, 4, 4); redCrayon = createCrayon("red", border); boxOfCrayons.add(redCrayon);/*from w ww .jav a 2s .c o m*/ add(redCrayon); yellowCrayon = createCrayon("yellow", border); boxOfCrayons.add(yellowCrayon); add(yellowCrayon); greenCrayon = createCrayon("green", border); boxOfCrayons.add(greenCrayon); add(greenCrayon); blueCrayon = createCrayon("blue", border); boxOfCrayons.add(blueCrayon); add(blueCrayon); }
From source file:components.ComboBoxDemo2.java
public ComboBoxDemo2() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; //Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); JComboBox patternList = new JComboBox(patternExamples); patternList.setEditable(true);//from w ww . j a va2 s .c o m patternList.addActionListener(this); //Create the UI for displaying result. JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); //== LEFT result = new JLabel(" "); result.setForeground(Color.black); result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); }