List of usage examples for java.awt Panel setLayout
public void setLayout(LayoutManager mgr)
From source file:RadialLayout.java
/** * Run a demonstration.//from ww w . j a v a 2 s . c o m * * @param args ignored. * * @throws Exception when an error occurs. */ public static void main(final String[] args) throws Exception { final Frame frame = new Frame(); final Panel panel = new Panel(); panel.setLayout(new RadialLayout()); panel.add(new Checkbox("One")); panel.add(new Checkbox("Two")); panel.add(new Checkbox("Three")); panel.add(new Checkbox("Four")); panel.add(new Checkbox("Five")); panel.add(new Checkbox("One")); panel.add(new Checkbox("Two")); panel.add(new Checkbox("Three")); panel.add(new Checkbox("Four")); panel.add(new Checkbox("Five")); frame.add(panel); frame.setSize(300, 500); frame.setVisible(true); }
From source file:ToolbarFrame1.java
public ToolbarFrame1() { super("Toolbar Example (AWT)"); setSize(450, 250);/*from ww w .jav a 2s . c o m*/ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); ActionListener printListener = new ActionListener() { public void actionPerformed(ActionEvent ae) { System.out.println(ae.getActionCommand()); } }; Panel toolbar = new Panel(); toolbar.setLayout(new FlowLayout(FlowLayout.LEFT)); cutButton = new Button("Cut"); cutButton.addActionListener(printListener); toolbar.add(cutButton); copyButton = new Button("Copy"); copyButton.addActionListener(printListener); toolbar.add(copyButton); pasteButton = new Button("Paste"); pasteButton.addActionListener(printListener); toolbar.add(pasteButton); add(toolbar, BorderLayout.NORTH); }
From source file:HBox.java
public HBox() { super("Horizontal Box Test Frame"); setSize(200, 100);//from w ww . j a v a 2 s . com Panel box = new Panel(); // Use BoxLayout.Y_AXIS below if you want a vertical box box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS)); setContentPane(box); for (int i = 0; i < 3; i++) { Button b = new Button("B" + i); box.add(b); } setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); }
From source file:br.upe.ecomp.dosa.controller.chart.FileLineChartManager.java
private Panel createContents(double[] values, boolean logarithmicYAxis, String measurement, int step, File file) {//from ww w . j a va 2 s.co m Panel chartPanel = new Panel(); chartPanel.setLayout(new java.awt.GridLayout(1, 1)); JFreeChart chart = createChart("", "Sample", "Fitness", createSampleDataset(values, measurement, step), false); ImageSaver.saveImage(chart.createBufferedImage(1000, 800), file.getParent(), "graph.png"); ChartPanel jFreeChartPanel = new ChartPanel(chart); chartPanel.add(jFreeChartPanel); return chartPanel; }
From source file:br.upe.ecomp.dosa.controller.chart.FileBoxplotChartManager.java
private Panel createContents(double[][] values, boolean logarithmicYAxis, int step) { Panel chartPanel = new Panel(); chartPanel.setLayout(new java.awt.GridLayout(1, 1)); JFreeChart chart = createChart("", "Iterations", "Fitness", createSampleDataset(values, step), logarithmicYAxis);// w ww. j av a2 s . co m ChartPanel jFreeChartPanel = new ChartPanel(chart); chartPanel.add(jFreeChartPanel); return chartPanel; }
From source file:GUIManagerQuery.java
/*************************************************************************** * Construct the GUIManagerQuery object, constructing the various components * and laying them out on the screen./*from w w w .j a va2s . c om*/ **************************************************************************/ public GUIManagerQuery() { super("GUIManagerQuery"); setLayout(new BorderLayout()); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); versionLabel = new Label("JMF v" + Manager.getVersion()); add(versionLabel, "North"); Panel lower = new Panel(); lower.add(new Label("Content/Protocol")); contentsField = new TextField(32); lower.add(contentsField); add(lower, "South"); results = new TextArea(20, 80); results.setEditable(false); add(results, "Center"); Panel controls = new Panel(); controls.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); hintsButton = new Button("Hints"); gbc.gridx = 0; gbc.gridy = 0; controls.add(hintsButton, gbc); hintsButton.addActionListener(this); playersButton = new Button("Players"); gbc.gridy = 1; controls.add(playersButton, gbc); playersButton.addActionListener(this); processorsButton = new Button("Processors"); gbc.gridy = 2; controls.add(processorsButton, gbc); processorsButton.addActionListener(this); sourcesButton = new Button("DataSources"); gbc.gridy = 3; controls.add(sourcesButton, gbc); sourcesButton.addActionListener(this); add(controls, "East"); }
From source file:FileViewer.java
/** * The real constructor. Create a FileViewer object to display the specified * file from the specified directory/* w ww . j a va 2s . c om*/ */ public FileViewer(String directory, String filename) { super(); // Create the frame // Destroy the window when the user requests it addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); // Create a TextArea to display the contents of the file in textarea = new TextArea("", 24, 80); textarea.setFont(new Font("MonoSpaced", Font.PLAIN, 12)); textarea.setEditable(false); this.add("Center", textarea); // Create a bottom panel to hold a couple of buttons in Panel p = new Panel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 5)); this.add(p, "South"); // Create the buttons and arrange to handle button clicks Font font = new Font("SansSerif", Font.BOLD, 14); Button openfile = new Button("Open File"); Button close = new Button("Close"); openfile.addActionListener(this); openfile.setActionCommand("open"); openfile.setFont(font); close.addActionListener(this); close.setActionCommand("close"); close.setFont(font); p.add(openfile); p.add(close); this.pack(); // Figure out the directory, from filename or current dir, if necessary if (directory == null) { File f; if ((filename != null) && (f = new File(filename)).isAbsolute()) { directory = f.getParent(); filename = f.getName(); } else directory = System.getProperty("user.dir"); } this.directory = directory; // Remember the directory, for FileDialog setFile(directory, filename); // Now load and display the file }
From source file:br.upe.ecomp.dosa.controller.chart.FileLineChartDirectorManager.java
/** * {@inheritDoc}/*from w w w . jav a 2s .com*/ */ // public Panel plot(List<File> files, String measurement, int step, boolean logarithmicYAxis) { // Integer lastIteration = resultsAnalyzer.getLastIteration(files); // double[] data = resultsAnalyzer.getDataMeans(files, measurement, lastIteration, step); // return createContents(data, logarithmicYAxis, measurement, step); // } private Panel createContents(double[] values, boolean logarithmicYAxis, String measurement, int step) { Panel chartPanel = new Panel(); chartPanel.setLayout(new java.awt.GridLayout(1, 1)); JFreeChart chart = createChart("", "Sample", "Fitness", createSampleDataset(values, measurement, step), false); ChartPanel jFreeChartPanel = new ChartPanel(chart); chartPanel.add(jFreeChartPanel); return chartPanel; }
From source file:br.upe.ecomp.dosa.controller.chart.FileLineChartDirectorManager.java
private Panel createContentsChartDirector(double[] values, boolean logarithmicYAxis, String measurement, int step) { Panel chartPanel = new Panel(); chartPanel.setLayout(new java.awt.GridLayout(1, 1)); chartPanel.setBackground(Color.white); // Create the chart and put them in the content pane ChartViewer viewer = new ChartViewer(); this.createChart(viewer, chartPanel, values, step); chartPanel.add(viewer);/*from ww w.ja va 2s . c o m*/ // JFreeChart chart = createChart("", "Sample", "Fitness", createSampleDataset(values, // measurement, step), false); // // ChartPanel jFreeChartPanel = new ChartPanel(chart); // chartPanel.add(jFreeChartPanel); return chartPanel; }
From source file:ExposedInt.java
public void init() { Panel buttonPanel = new PanelWithInsets(0, 0, 0, 0); buttonPanel.setLayout(new GridLayout(3, 2, 5, 5)); buttonPanel.add(new GrayButton(ExposedIntStringTable.increment)); buttonPanel.add(new GrayButton(ExposedIntStringTable.decrement)); buttonPanel.add(minimumButton);//from ww w. j a v a 2 s .com buttonPanel.add(maximumButton); buttonPanel.add(zeroButton); buttonPanel.add(new GrayButton(ExposedIntStringTable.negate)); zeroButton.disable(); binaryField = new Label("00000000000000000000000000000000"); hexField = new Label("00000000"); decimalField = new Label("0"); Font fieldFont = new Font("TimesRoman", Font.PLAIN, 12); binaryField.setFont(fieldFont); hexField.setFont(fieldFont); decimalField.setFont(fieldFont); Panel numberPanel = new Panel(); numberPanel.setBackground(Color.white); numberPanel.setLayout(new GridLayout(3, 1)); Panel binaryPanel = new Panel(); binaryPanel.setLayout(new BorderLayout()); binaryPanel.add("Center", binaryField); numberPanel.add(binaryPanel); Panel hexPanel = new Panel(); hexPanel.setLayout(new BorderLayout()); hexPanel.add("Center", hexField); numberPanel.add(hexPanel); numberPanel.add(decimalField); Panel labelPanel = new Panel(); labelPanel.setBackground(Color.white); labelPanel.setLayout(new GridLayout(3, 1)); Label label = new Label(ExposedIntStringTable.binary, Label.CENTER); Font labelFont = new Font("Helvetica", Font.ITALIC, 11); label.setFont(labelFont); labelPanel.add(label); label = new Label(ExposedIntStringTable.hex, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); label = new Label(ExposedIntStringTable.decimal, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); Panel dataPanel = new Panel(); dataPanel.setLayout(new BorderLayout()); dataPanel.add("West", labelPanel); dataPanel.add("Center", numberPanel); ColoredLabel title = new ColoredLabel(ExposedIntStringTable.title, Label.CENTER, Color.yellow); title.setFont(new Font("Helvetica", Font.BOLD, 12)); setBackground(Color.red); setLayout(new BorderLayout(5, 5)); add("North", title); add("West", buttonPanel); add("Center", dataPanel); }