List of usage examples for java.awt GridLayout GridLayout
public GridLayout(int rows, int cols)
From source file:MenuItemChooser.java
private void initGUI() { JPanel itemDetailsPanel = new JPanel(); itemDetailsPanel.setLayout(new GridLayout(4, 2)); itemDetailsPanel.setBackground(Color.WHITE); JLabel lbl = new JLabel("Item: "); itemDetailsPanel.add(lbl);/*from ww w . j a va 2s . c om*/ itemName = new JLabel(""); itemDetailsPanel.add(itemName); lbl = new JLabel("Type: "); itemDetailsPanel.add(lbl); itemType = new JLabel(""); itemDetailsPanel.add(itemType); lbl = new JLabel("Price: $ "); itemDetailsPanel.add(lbl); price = new JLabel(""); itemDetailsPanel.add(price); lbl = new JLabel("Quantity: "); itemDetailsPanel.add(lbl); qty = new JTextField("0", 1); qty.addActionListener(this); qty.addFocusListener(this); itemDetailsPanel.add(qty); JPanel imgDescPanel = new JPanel(new BorderLayout()); imgDescPanel.setBackground(Color.WHITE); image = new JLabel(""); image.setHorizontalAlignment(SwingConstants.CENTER); image.setVerticalAlignment(SwingConstants.CENTER); imgDescPanel.add(image, BorderLayout.NORTH); desc = new JLabel("desc"); imgDescPanel.add(desc, BorderLayout.SOUTH); JPanel buttonPanel = new JPanel(); buttonPanel.setBackground(Color.WHITE); next = new JButton("Next"); next.addActionListener(this); buttonPanel.add(next); prev = new JButton("Previous"); prev.addActionListener(this); buttonPanel.add(prev); order = new JButton("Order"); order.addActionListener(this); buttonPanel.add(order); cancel = new JButton("Cancel / New"); cancel.addActionListener(this); buttonPanel.add(cancel); close = new JButton("Close"); close.addActionListener(this); close.setEnabled(false); buttonPanel.add(close); totalLbl = new JLabel(""); totalLbl.setFont(new Font("Serif", Font.BOLD, 14)); totalLbl.setForeground((Color.GREEN).darker()); buttonPanel.add(totalLbl); BorderLayout bl = new BorderLayout(); bl.setHgap(30); bl.setVgap(20); setLayout(bl); setBackground(Color.WHITE); add(itemDetailsPanel, BorderLayout.WEST); add(imgDescPanel, BorderLayout.EAST); add(buttonPanel, BorderLayout.SOUTH); TitledBorder title = BorderFactory.createTitledBorder("Choose Menu Items And Place Order"); setBorder(title); loadMenuItem(); }
From source file:fr.irit.smac.libs.tooling.plot.server.AgentPlotChart.java
private static JPanel getChartContainer(boolean _refresh) { if (chartContainer == null) { chartContainer = new JPanel(); }// w w w. ja v a 2 s.c o m if (_refresh) { switch (chartCount) { case 1: case 2: chartContainer.setLayout(new GridLayout(0, chartCount)); break; default: chartContainer.setLayout(new GridLayout(0, 3)); break; } } return chartContainer; }
From source file:org.jfree.chart.demo.TimeSeriesDemo11.java
/** * A demonstration application showing how to... * * @param title the frame title.//from w w w .j a va2 s . c om */ public TimeSeriesDemo11(final String title) { super(title); final JPanel panel = new JPanel(new GridLayout(2, 2)); panel.setPreferredSize(new java.awt.Dimension(800, 600)); final Day today = new Day(); final XYDataset dataset = createDataset("Series 1", 100.0, today, 365); final JFreeChart chart1 = createChart("Chart 1 : 1 Year", dataset); final ChartPanel chartPanel1 = new ChartPanel(chart1); panel.add(chartPanel1); final JFreeChart chart2 = createChart("Chart 2 : 6 Months", dataset); final SerialDate t = today.getSerialDate(); final SerialDate t6m = SerialDate.addMonths(-6, t); final Day sixMonthsAgo = new Day(t6m); final DateAxis axis2 = (DateAxis) chart2.getXYPlot().getDomainAxis(); axis2.setRange(sixMonthsAgo.getStart(), today.getEnd()); final ChartPanel chartPanel2 = new ChartPanel(chart2); panel.add(chartPanel2); final JFreeChart chart3 = createChart("Chart 3 : 3 Months", dataset); final SerialDate t3m = SerialDate.addMonths(-3, t); final Day threeMonthsAgo = new Day(t3m); final DateAxis axis3 = (DateAxis) chart3.getXYPlot().getDomainAxis(); axis3.setRange(threeMonthsAgo.getStart(), today.getEnd()); final ChartPanel chartPanel3 = new ChartPanel(chart3); panel.add(chartPanel3); final JFreeChart chart4 = createChart("Chart 4 : 1 Month", dataset); final SerialDate t1m = SerialDate.addMonths(-1, t); final Day oneMonthsAgo = new Day(t1m); final DateAxis axis4 = (DateAxis) chart4.getXYPlot().getDomainAxis(); axis4.setRange(oneMonthsAgo.getStart(), today.getEnd()); final ChartPanel chartPanel4 = new ChartPanel(chart4); panel.add(chartPanel4); setContentPane(panel); }
From source file:com.emental.mindraider.ui.dialogs.AddTripletJDialog.java
/** * Constructor.//w ww .j ava 2s . c o m */ public AddTripletJDialog() { super("Add Triplet"); JPanel framePanel = new JPanel(); framePanel.setLayout(new GridLayout(4, 1)); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(new JLabel(" Predicate: ")); predicateNs = new JTextField(30); predicateNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS); 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.RIGHT)); p.add(new JLabel(" Object: ")); objectNs = new JTextField(30); objectNs.setText(MindRaiderConstants.MR_RDF_PREDICATE_NS); objectNs.selectAll(); p.add(objectNs); p.add(new JLabel("#")); objectLocalName = new JTextField(15); objectLocalName.grabFocus(); objectLocalName.selectAll(); objectLocalName.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { createTriplet(); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); p.add(objectLocalName); framePanel.add(p); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); literalCheckBox = new JCheckBox("literal", false); p.add(literalCheckBox); 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) { AddTripletJDialog.this.dispose(); } }); framePanel.add(p); getContentPane().add(framePanel, BorderLayout.CENTER); // show pack(); Gfx.centerAndShowWindow(this); addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent e) { getObjectLocalName().requestFocusInWindow(); } }); }
From source file:CelsiusConverter.java
public CelsiusConverter() { // Create the frame and container. converterFrame = new JFrame("Convert Celsius to Fahrenheit"); converterPanel = new JPanel(); converterPanel.setLayout(new GridLayout(2, 2)); // Add the widgets. addWidgets();//from w w w .j a v a 2 s. c om // Add the panel to the frame. converterFrame.getContentPane().add(converterPanel, BorderLayout.CENTER); // Exit when the window is closed. converterFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Show the converter. converterFrame.pack(); converterFrame.setVisible(true); }
From source file:FormatTest.java
public FormatTestFrame() { setTitle("FormatTest"); setSize(WIDTH, HEIGHT);// w ww. j a v a 2 s . c o m JPanel buttonPanel = new JPanel(); okButton = new JButton("Ok"); buttonPanel.add(okButton); add(buttonPanel, BorderLayout.SOUTH); mainPanel = new JPanel(); mainPanel.setLayout(new GridLayout(0, 3)); add(mainPanel, BorderLayout.CENTER); JFormattedTextField intField = new JFormattedTextField(NumberFormat.getIntegerInstance()); intField.setValue(new Integer(100)); addRow("Number:", intField); JFormattedTextField intField2 = new JFormattedTextField(NumberFormat.getIntegerInstance()); intField2.setValue(new Integer(100)); intField2.setFocusLostBehavior(JFormattedTextField.COMMIT); addRow("Number (Commit behavior):", intField2); JFormattedTextField intField3 = new JFormattedTextField( new InternationalFormatter(NumberFormat.getIntegerInstance()) { protected DocumentFilter getDocumentFilter() { return filter; } private DocumentFilter filter = new IntFilter(); }); intField3.setValue(new Integer(100)); addRow("Filtered Number", intField3); JFormattedTextField intField4 = new JFormattedTextField(NumberFormat.getIntegerInstance()); intField4.setValue(new Integer(100)); intField4.setInputVerifier(new FormattedTextFieldVerifier()); addRow("Verified Number:", intField4); JFormattedTextField currencyField = new JFormattedTextField(NumberFormat.getCurrencyInstance()); currencyField.setValue(new Double(10)); addRow("Currency:", currencyField); JFormattedTextField dateField = new JFormattedTextField(DateFormat.getDateInstance()); dateField.setValue(new Date()); addRow("Date (default):", dateField); DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT); format.setLenient(false); JFormattedTextField dateField2 = new JFormattedTextField(format); dateField2.setValue(new Date()); addRow("Date (short, not lenient):", dateField2); try { DefaultFormatter formatter = new DefaultFormatter(); formatter.setOverwriteMode(false); JFormattedTextField urlField = new JFormattedTextField(formatter); urlField.setValue(new URL("http://java.sun.com")); addRow("URL:", urlField); } catch (MalformedURLException e) { e.printStackTrace(); } try { MaskFormatter formatter = new MaskFormatter("###-##-####"); formatter.setPlaceholderCharacter('0'); JFormattedTextField ssnField = new JFormattedTextField(formatter); ssnField.setValue("078-05-1120"); addRow("SSN Mask:", ssnField); } catch (ParseException exception) { exception.printStackTrace(); } JFormattedTextField ipField = new JFormattedTextField(new IPAddressFormatter()); ipField.setValue(new byte[] { (byte) 130, 65, 86, 66 }); addRow("IP Address:", ipField); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.ImageUploaderThumbnailerTester_2.java
public ImageUploaderThumbnailerTester_2(String imagePath, CropDataSet cropDataSet) { this.imagePath = imagePath; this.thumbnailer = new ImageUploadThumbnailer(200, 200); setTitle("Cropping edging test"); addWindowListener(new CloseWindowListener()); setLayout(new GridLayout(ROWS, COLUMNS)); for (CropData cropData : cropDataSet.crops()) { add(createImagePanel(cropData)); }/* w w w.jav a 2 s. c o m*/ pack(); setVisible(true); }
From source file:soap.ui.panel.innerCentralPanel.StatsPanel.java
protected void initUI() { if (mIndicatorsName.size() != 0) { defaultAddComponent(new JLabel(resMan.getString("statsChooseIndicator")), SoapGridbagPanel.END); JPanel indicatorsPanel = new JPanel(); indicatorsPanel.setBackground(Color.WHITE); indicatorsPanel.setLayout(new GridLayout(mIndicatorsName.size(), 1)); mCheckBoxTable = new JCheckBox[mIndicatorsName.size()]; CheckBoxListener listener = new CheckBoxListener(); Iterator it = mIndicatorsName.keySet().iterator(); for (int i = 0; i < mIndicatorsName.size(); i++) { String key = (String) it.next(); mCheckBoxTable[i] = new JCheckBox((String) mIndicatorsName.get(key)); mCheckBoxTable[i].setName(key); mCheckBoxTable[i].setPreferredSize(new Dimension(50, 20)); mCheckBoxTable[i].setBackground(Color.WHITE); mCheckBoxTable[i].addItemListener(listener); indicatorsPanel.add(mCheckBoxTable[i]); }// w w w . j a va 2 s. c o m JScrollPane scrollPane = new JScrollPane(indicatorsPanel); scrollPane.setPreferredSize(new Dimension(140, 65)); defaultAddComponent(scrollPane, SoapGridbagPanel.END, 1, 0, new Insets(10, 0, 20, 0)); // add the chart to a panel... mChartPanel.setPreferredSize(new Dimension(580, 330)); defaultAddComponent(new JScrollPane(mChartPanel), SoapGridbagPanel.END); } }
From source file:components.RootLayeredPaneDemo.java
public RootLayeredPaneDemo(JLayeredPane layeredPane) { super(new GridLayout(1, 1)); //Create and load the duke icon. final ImageIcon icon = createImageIcon("images/dukeWaveRed.gif"); //Create and set up the layered pane. this.layeredPane = layeredPane; layeredPane.addMouseMotionListener(this); //This is the origin of the first label added. Point origin = new Point(10, 100); //This is the offset for computing the origin for the next label. int offset = 35; //Add several overlapping, colored labels to the layered pane //using absolute positioning/sizing. for (int i = 0; i < layerStrings.length; i++) { JLabel label = createColoredLabel(layerStrings[i], layerColors[i], origin); layeredPane.add(label, new Integer(layers[i])); origin.x += offset;/*from w w w . jav a 2 s . c o m*/ origin.y += offset; } //Create and add the Duke label to the layered pane. dukeLabel = new JLabel(icon); if (icon != null) { dukeLabel.setBounds(15, 225, icon.getIconWidth(), icon.getIconHeight()); } else { System.err.println("Duke icon not found; using black square instead."); dukeLabel.setBounds(15, 225, 30, 30); dukeLabel.setOpaque(true); dukeLabel.setBackground(Color.BLACK); } layeredPane.add(dukeLabel, new Integer(layers[INITIAL_DUKE_LAYER_INDEX]), 0); //Add control pane to this JPanel. add(createControlPanel()); }
From source file:CelsiusConverter2.java
public CelsiusConverter2() { // Create the frame and container. converterFrame = new JFrame("Convert Celsius to Fahrenheit"); converterPanel = new JPanel(); converterPanel.setLayout(new GridLayout(2, 2)); // Add the widgets. addWidgets();/*from w ww . j a v a 2s.c o m*/ // Add the panel to the frame. converterFrame.getContentPane().add(converterPanel, BorderLayout.CENTER); // Exit when the window is closed. converterFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Show the converter. converterFrame.pack(); converterFrame.setVisible(true); }