List of usage examples for java.awt Frame setBackground
@Override public void setBackground(Color bgColor)
From source file:SystemFileTree.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); RGB color = shell.getBackground().getRGB(); Label separator1 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); Label locationLb = new Label(shell, SWT.NONE); locationLb.setText("Location:"); Composite locationComp = new Composite(shell, SWT.EMBEDDED); Label separator2 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); final Composite comp = new Composite(shell, SWT.NONE); final Tree fileTree = new Tree(comp, SWT.SINGLE | SWT.BORDER); Sash sash = new Sash(comp, SWT.VERTICAL); Composite tableComp = new Composite(comp, SWT.EMBEDDED); Label separator3 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); Composite statusComp = new Composite(shell, SWT.EMBEDDED); java.awt.Frame locationFrame = SWT_AWT.new_Frame(locationComp); final java.awt.TextField locationText = new java.awt.TextField(); locationFrame.add(locationText);//from w w w. jav a 2s. c om java.awt.Frame statusFrame = SWT_AWT.new_Frame(statusComp); statusFrame.setBackground(new java.awt.Color(color.red, color.green, color.blue)); final java.awt.Label statusLabel = new java.awt.Label(); statusFrame.add(statusLabel); statusLabel.setText("Select a file"); sash.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { if (e.detail == SWT.DRAG) return; GridData data = (GridData) fileTree.getLayoutData(); Rectangle trim = fileTree.computeTrim(0, 0, 0, 0); data.widthHint = e.x - trim.width; comp.layout(); } }); File[] roots = File.listRoots(); for (int i = 0; i < roots.length; i++) { File file = roots[i]; TreeItem treeItem = new TreeItem(fileTree, SWT.NONE); treeItem.setText(file.getAbsolutePath()); treeItem.setData(file); new TreeItem(treeItem, SWT.NONE); } fileTree.addListener(SWT.Expand, new Listener() { public void handleEvent(Event e) { TreeItem item = (TreeItem) e.item; if (item == null) return; if (item.getItemCount() == 1) { TreeItem firstItem = item.getItems()[0]; if (firstItem.getData() != null) return; firstItem.dispose(); } else { return; } File root = (File) item.getData(); File[] files = root.listFiles(); if (files == null) return; for (int i = 0; i < files.length; i++) { File file = files[i]; if (file.isDirectory()) { TreeItem treeItem = new TreeItem(item, SWT.NONE); treeItem.setText(file.getName()); treeItem.setData(file); new TreeItem(treeItem, SWT.NONE); } } } }); fileTree.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { TreeItem item = (TreeItem) e.item; if (item == null) return; final File root = (File) item.getData(); statusLabel.setText(root.getAbsolutePath()); locationText.setText(root.getAbsolutePath()); } }); GridLayout layout = new GridLayout(4, false); layout.marginWidth = layout.marginHeight = 0; layout.horizontalSpacing = layout.verticalSpacing = 1; shell.setLayout(layout); GridData data; data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; separator1.setLayoutData(data); data = new GridData(); data.horizontalSpan = 1; data.horizontalIndent = 10; locationLb.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; data.heightHint = locationText.getPreferredSize().height; locationComp.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 1; data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; separator2.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 4; comp.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; separator3.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; data.heightHint = statusLabel.getPreferredSize().height; statusComp.setLayoutData(data); layout = new GridLayout(3, false); layout.marginWidth = layout.marginHeight = 0; layout.horizontalSpacing = layout.verticalSpacing = 1; comp.setLayout(layout); data = new GridData(GridData.FILL_VERTICAL); data.widthHint = 200; fileTree.setLayoutData(data); data = new GridData(GridData.FILL_VERTICAL); sash.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); tableComp.setLayoutData(data); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet135.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("SWT and Swing/AWT Example"); Listener exitListener = e -> {//from w ww.j av a2s. c om MessageBox dialog = new MessageBox(shell, SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION); dialog.setText("Question"); dialog.setMessage("Exit?"); if (e.type == SWT.Close) e.doit = false; if (dialog.open() != SWT.OK) return; shell.dispose(); }; Listener aboutListener = e -> { final Shell s = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); s.setText("About"); GridLayout layout = new GridLayout(1, false); layout.verticalSpacing = 20; layout.marginHeight = layout.marginWidth = 10; s.setLayout(layout); Label label = new Label(s, SWT.NONE); label.setText("SWT and AWT Example."); Button button = new Button(s, SWT.PUSH); button.setText("OK"); GridData data = new GridData(); data.horizontalAlignment = GridData.CENTER; button.setLayoutData(data); button.addListener(SWT.Selection, event -> s.dispose()); s.pack(); Rectangle parentBounds = shell.getBounds(); Rectangle bounds = s.getBounds(); int x = parentBounds.x + (parentBounds.width - bounds.width) / 2; int y = parentBounds.y + (parentBounds.height - bounds.height) / 2; s.setLocation(x, y); s.open(); while (!s.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }; shell.addListener(SWT.Close, exitListener); Menu mb = new Menu(shell, SWT.BAR); MenuItem fileItem = new MenuItem(mb, SWT.CASCADE); fileItem.setText("&File"); Menu fileMenu = new Menu(shell, SWT.DROP_DOWN); fileItem.setMenu(fileMenu); MenuItem exitItem = new MenuItem(fileMenu, SWT.PUSH); exitItem.setText("&Exit\tCtrl+X"); exitItem.setAccelerator(SWT.CONTROL + 'X'); exitItem.addListener(SWT.Selection, exitListener); MenuItem aboutItem = new MenuItem(fileMenu, SWT.PUSH); aboutItem.setText("&About\tCtrl+A"); aboutItem.setAccelerator(SWT.CONTROL + 'A'); aboutItem.addListener(SWT.Selection, aboutListener); shell.setMenuBar(mb); RGB color = shell.getBackground().getRGB(); Label separator1 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); Label locationLb = new Label(shell, SWT.NONE); locationLb.setText("Location:"); Composite locationComp = new Composite(shell, SWT.EMBEDDED); ToolBar toolBar = new ToolBar(shell, SWT.FLAT); ToolItem exitToolItem = new ToolItem(toolBar, SWT.PUSH); exitToolItem.setText("&Exit"); exitToolItem.addListener(SWT.Selection, exitListener); ToolItem aboutToolItem = new ToolItem(toolBar, SWT.PUSH); aboutToolItem.setText("&About"); aboutToolItem.addListener(SWT.Selection, aboutListener); Label separator2 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); final Composite comp = new Composite(shell, SWT.NONE); final Tree fileTree = new Tree(comp, SWT.SINGLE | SWT.BORDER); Sash sash = new Sash(comp, SWT.VERTICAL); Composite tableComp = new Composite(comp, SWT.EMBEDDED); Label separator3 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); Composite statusComp = new Composite(shell, SWT.EMBEDDED); java.awt.Frame locationFrame = SWT_AWT.new_Frame(locationComp); final java.awt.TextField locationText = new java.awt.TextField(); locationFrame.add(locationText); java.awt.Frame fileTableFrame = SWT_AWT.new_Frame(tableComp); java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout()); fileTableFrame.add(panel); final JTable fileTable = new JTable(new FileTableModel(null)); fileTable.setDoubleBuffered(true); fileTable.setShowGrid(false); fileTable.createDefaultColumnsFromModel(); JScrollPane scrollPane = new JScrollPane(fileTable); panel.add(scrollPane); java.awt.Frame statusFrame = SWT_AWT.new_Frame(statusComp); statusFrame.setBackground(new java.awt.Color(color.red, color.green, color.blue)); final java.awt.Label statusLabel = new java.awt.Label(); statusFrame.add(statusLabel); statusLabel.setText("Select a file"); sash.addListener(SWT.Selection, e -> { if (e.detail == SWT.DRAG) return; GridData data = (GridData) fileTree.getLayoutData(); Rectangle trim = fileTree.computeTrim(0, 0, 0, 0); data.widthHint = e.x - trim.width; comp.layout(); }); File[] roots = File.listRoots(); for (int i = 0; i < roots.length; i++) { File file = roots[i]; TreeItem treeItem = new TreeItem(fileTree, SWT.NONE); treeItem.setText(file.getAbsolutePath()); treeItem.setData(file); new TreeItem(treeItem, SWT.NONE); } fileTree.addListener(SWT.Expand, e -> { TreeItem item = (TreeItem) e.item; if (item == null) return; if (item.getItemCount() == 1) { TreeItem firstItem = item.getItems()[0]; if (firstItem.getData() != null) return; firstItem.dispose(); } else { return; } File root = (File) item.getData(); File[] files = root.listFiles(); if (files == null) return; for (int i = 0; i < files.length; i++) { File file = files[i]; if (file.isDirectory()) { TreeItem treeItem = new TreeItem(item, SWT.NONE); treeItem.setText(file.getName()); treeItem.setData(file); new TreeItem(treeItem, SWT.NONE); } } }); fileTree.addListener(SWT.Selection, e -> { TreeItem item = (TreeItem) e.item; if (item == null) return; final File root = (File) item.getData(); EventQueue.invokeLater(() -> { statusLabel.setText(root.getAbsolutePath()); locationText.setText(root.getAbsolutePath()); fileTable.setModel(new FileTableModel(root.listFiles())); }); }); GridLayout layout = new GridLayout(4, false); layout.marginWidth = layout.marginHeight = 0; layout.horizontalSpacing = layout.verticalSpacing = 1; shell.setLayout(layout); GridData data; data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; separator1.setLayoutData(data); data = new GridData(); data.horizontalSpan = 1; data.horizontalIndent = 10; locationLb.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; data.heightHint = locationText.getPreferredSize().height; locationComp.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 1; toolBar.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; separator2.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 4; comp.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; separator3.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; data.heightHint = statusLabel.getPreferredSize().height; statusComp.setLayoutData(data); layout = new GridLayout(3, false); layout.marginWidth = layout.marginHeight = 0; layout.horizontalSpacing = layout.verticalSpacing = 1; comp.setLayout(layout); data = new GridData(GridData.FILL_VERTICAL); data.widthHint = 200; fileTree.setLayoutData(data); data = new GridData(GridData.FILL_VERTICAL); sash.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); tableComp.setLayoutData(data); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:Snippet135.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("SWT and Swing/AWT Example"); Listener exitListener = new Listener() { public void handleEvent(Event e) { MessageBox dialog = new MessageBox(shell, SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION); dialog.setText("Question"); dialog.setMessage("Exit?"); if (e.type == SWT.Close) e.doit = false;/* w w w. jav a 2 s . com*/ if (dialog.open() != SWT.OK) return; shell.dispose(); } }; Listener aboutListener = new Listener() { public void handleEvent(Event e) { final Shell s = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); s.setText("About"); GridLayout layout = new GridLayout(1, false); layout.verticalSpacing = 20; layout.marginHeight = layout.marginWidth = 10; s.setLayout(layout); Label label = new Label(s, SWT.NONE); label.setText("SWT and AWT Example."); Button button = new Button(s, SWT.PUSH); button.setText("OK"); GridData data = new GridData(); data.horizontalAlignment = GridData.CENTER; button.setLayoutData(data); button.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { s.dispose(); } }); s.pack(); Rectangle parentBounds = shell.getBounds(); Rectangle bounds = s.getBounds(); int x = parentBounds.x + (parentBounds.width - bounds.width) / 2; int y = parentBounds.y + (parentBounds.height - bounds.height) / 2; s.setLocation(x, y); s.open(); while (!s.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } }; shell.addListener(SWT.Close, exitListener); Menu mb = new Menu(shell, SWT.BAR); MenuItem fileItem = new MenuItem(mb, SWT.CASCADE); fileItem.setText("&File"); Menu fileMenu = new Menu(shell, SWT.DROP_DOWN); fileItem.setMenu(fileMenu); MenuItem exitItem = new MenuItem(fileMenu, SWT.PUSH); exitItem.setText("&Exit\tCtrl+X"); exitItem.setAccelerator(SWT.CONTROL + 'X'); exitItem.addListener(SWT.Selection, exitListener); MenuItem aboutItem = new MenuItem(fileMenu, SWT.PUSH); aboutItem.setText("&About\tCtrl+A"); aboutItem.setAccelerator(SWT.CONTROL + 'A'); aboutItem.addListener(SWT.Selection, aboutListener); shell.setMenuBar(mb); RGB color = shell.getBackground().getRGB(); Label separator1 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); Label locationLb = new Label(shell, SWT.NONE); locationLb.setText("Location:"); Composite locationComp = new Composite(shell, SWT.EMBEDDED); ToolBar toolBar = new ToolBar(shell, SWT.FLAT); ToolItem exitToolItem = new ToolItem(toolBar, SWT.PUSH); exitToolItem.setText("&Exit"); exitToolItem.addListener(SWT.Selection, exitListener); ToolItem aboutToolItem = new ToolItem(toolBar, SWT.PUSH); aboutToolItem.setText("&About"); aboutToolItem.addListener(SWT.Selection, aboutListener); Label separator2 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); final Composite comp = new Composite(shell, SWT.NONE); final Tree fileTree = new Tree(comp, SWT.SINGLE | SWT.BORDER); Sash sash = new Sash(comp, SWT.VERTICAL); Composite tableComp = new Composite(comp, SWT.EMBEDDED); Label separator3 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); Composite statusComp = new Composite(shell, SWT.EMBEDDED); java.awt.Frame locationFrame = SWT_AWT.new_Frame(locationComp); final java.awt.TextField locationText = new java.awt.TextField(); locationFrame.add(locationText); java.awt.Frame fileTableFrame = SWT_AWT.new_Frame(tableComp); java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout()); fileTableFrame.add(panel); final JTable fileTable = new JTable(new FileTableModel(null)); fileTable.setDoubleBuffered(true); fileTable.setShowGrid(false); fileTable.createDefaultColumnsFromModel(); JScrollPane scrollPane = new JScrollPane(fileTable); panel.add(scrollPane); java.awt.Frame statusFrame = SWT_AWT.new_Frame(statusComp); statusFrame.setBackground(new java.awt.Color(color.red, color.green, color.blue)); final java.awt.Label statusLabel = new java.awt.Label(); statusFrame.add(statusLabel); statusLabel.setText("Select a file"); sash.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { if (e.detail == SWT.DRAG) return; GridData data = (GridData) fileTree.getLayoutData(); Rectangle trim = fileTree.computeTrim(0, 0, 0, 0); data.widthHint = e.x - trim.width; comp.layout(); } }); File[] roots = File.listRoots(); for (int i = 0; i < roots.length; i++) { File file = roots[i]; TreeItem treeItem = new TreeItem(fileTree, SWT.NONE); treeItem.setText(file.getAbsolutePath()); treeItem.setData(file); new TreeItem(treeItem, SWT.NONE); } fileTree.addListener(SWT.Expand, new Listener() { public void handleEvent(Event e) { TreeItem item = (TreeItem) e.item; if (item == null) return; if (item.getItemCount() == 1) { TreeItem firstItem = item.getItems()[0]; if (firstItem.getData() != null) return; firstItem.dispose(); } else { return; } File root = (File) item.getData(); File[] files = root.listFiles(); if (files == null) return; for (int i = 0; i < files.length; i++) { File file = files[i]; if (file.isDirectory()) { TreeItem treeItem = new TreeItem(item, SWT.NONE); treeItem.setText(file.getName()); treeItem.setData(file); new TreeItem(treeItem, SWT.NONE); } } } }); fileTree.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { TreeItem item = (TreeItem) e.item; if (item == null) return; final File root = (File) item.getData(); EventQueue.invokeLater(new Runnable() { public void run() { statusLabel.setText(root.getAbsolutePath()); locationText.setText(root.getAbsolutePath()); fileTable.setModel(new FileTableModel(root.listFiles())); } }); } }); GridLayout layout = new GridLayout(4, false); layout.marginWidth = layout.marginHeight = 0; layout.horizontalSpacing = layout.verticalSpacing = 1; shell.setLayout(layout); GridData data; data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; separator1.setLayoutData(data); data = new GridData(); data.horizontalSpan = 1; data.horizontalIndent = 10; locationLb.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; data.heightHint = locationText.getPreferredSize().height; locationComp.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 1; toolBar.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; separator2.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 4; comp.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; separator3.setLayoutData(data); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 4; data.heightHint = statusLabel.getPreferredSize().height; statusComp.setLayoutData(data); layout = new GridLayout(3, false); layout.marginWidth = layout.marginHeight = 0; layout.horizontalSpacing = layout.verticalSpacing = 1; comp.setLayout(layout); data = new GridData(GridData.FILL_VERTICAL); data.widthHint = 200; fileTree.setLayoutData(data); data = new GridData(GridData.FILL_VERTICAL); sash.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); tableComp.setLayoutData(data); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.qsos.radar.GenerateRadar.java
/** * This class creates a composite in which the radar char will be * implemented// ww w .j ava 2s. c o m * * @param parent * Composite where the chart will be seen * @param Categories * String[] that contains the name of the elements [4 min and 7 max] the user has chosen to visualize * @param Scores * Double[] that contains the average score of each category * @return Control * */ public static Control createChart(Composite parent, String[] Categories, double[] Scores) { Composite Charcomposite = new Composite(parent, SWT.EMBEDDED); Charcomposite.setLayout(new FillLayout()); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // for (int i = 0; i < CatNumber; i++) { dataset.addValue(Scores[i], getTitle(), Categories[i]); } String BackGroundMire = null; //Configuration of the spiderwebplot SpiderWebPlot plot = new SpiderWebPlot(); plot.setDataset(dataset); plot.setMaxValue(JQConst.RADAR_MAX_VALUE); plot.setSeriesPaint(JQConst.RADAR_SERIES_PAINT); plot.setAxisLabelGap(JQConst.RADAR_AXIS_LABEL_GAP); plot.setHeadPercent(JQConst.RADAR_HEAD_PERCENT); plot.setInteriorGap(JQConst.RADAR_INTERIOR_GAP); plot.setWebFilled(true); //The backgroundpicture used as a spiderweb is chosen according to the //number of categories selected switch (CatNumber) { case 4: BackGroundMire = JQConst.RADAR_SPIDERWEB_4; break; case 5: BackGroundMire = JQConst.RADAR_SPIDERWEB_5; break; case 6: BackGroundMire = JQConst.RADAR_SPIDERWEB_6; break; case 7: BackGroundMire = JQConst.RADAR_SPIDERWEB_7; break; } javax.swing.ImageIcon icon = new javax.swing.ImageIcon(BackGroundMire); plot.setBackgroundImage(icon.getImage()); //chart creation JFreeChart chart = new JFreeChart(plot); //Here the background color from the shell is taken in order to match AWT and SWT backgrounds Color backgroundColor = parent.getBackground(); //JFreechart doesn't support SWT so we create an AWT Frame that will depend on Charcomposite java.awt.Frame chartPanel = SWT_AWT.new_Frame(Charcomposite); chartPanel.setLayout(new java.awt.GridLayout()); ChartPanel jfreeChartPanel = new ChartPanel(chart); chartPanel.setBackground(new java.awt.Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue())); chartPanel.add(jfreeChartPanel); chartPanel.pack(); return parent; }
From source file:joachimeichborn.geotag.ui.parts.PicturesView.java
private void initializeDetailsSection(final Composite aParent) { final Composite details = new Composite(aParent, SWT.BORDER); details.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); details.setLayout(new GridLayout(3, false)); preview = new ImageIcon(); previewLabel = new JLabel(preview); previewContainer = new Composite(details, SWT.EMBEDDED); final GridData thumbnailGridData = new GridData(); thumbnailGridData.verticalSpan = 7;// ww w . ja v a2s . c o m thumbnailGridData.heightHint = 160; thumbnailGridData.widthHint = 160; previewContainer.setLayoutData(thumbnailGridData); final Frame frame = SWT_AWT.new_Frame(previewContainer); frame.add(previewLabel); final Color color = details.getBackground(); frame.setBackground(new java.awt.Color(color.getGreen(), color.getGreen(), color.getBlue())); color.dispose(); new Label(details, SWT.NONE).setText("Name: "); nameLabel = new Label(details, SWT.NONE); nameLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); new Label(details, SWT.NONE).setText("Path: "); pathLabel = new Label(details, SWT.NONE); pathLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); new Label(details, SWT.NONE).setText("Location name: "); locationNameLabel = new Label(details, SWT.NONE); locationNameLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); new Label(details, SWT.NONE).setText("City: "); cityLabel = new Label(details, SWT.NONE); cityLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); new Label(details, SWT.NONE).setText("Sublocation: "); sublocationLabel = new Label(details, SWT.NONE); sublocationLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); new Label(details, SWT.NONE).setText("Provice: "); provinceLabel = new Label(details, SWT.NONE); provinceLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); new Label(details, SWT.NONE).setText("Country: "); countryLabel = new Label(details, SWT.NONE); countryLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); }
From source file:gov.redhawk.statistics.ui.views.StatisticsView.java
/** * This is a callback that will allow us to create the viewer and initialize it. *//*from w w w.j a v a 2 s. com*/ @Override public void createPartControl(Composite comp) { parent = comp; parent.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(1).create()); // Custom Action for the View's Menu CustomAction customAction = new CustomAction() { @Override public void run() { SettingsDialog dialog = new SettingsDialog(parent.getShell(), datalist.length, curIndex, numBars); dialog.create(); if (dialog.open() == Window.OK) { numBars = dialog.getNumBars(); curIndex = dialog.getSelectedIndex(); refreshJob.schedule(); } } }; customAction.setText("Settings"); getViewSite().getActionBars().getMenuManager().add(customAction); // creation of chart composite and selection of associated options Composite chartComposite = new Composite(parent, SWT.EMBEDDED); chartComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); chart = ChartFactory.createXYBarChart(null, null, false, null, dataSet, PlotOrientation.VERTICAL, false, true, false); org.eclipse.swt.graphics.Color backgroundColor = chartComposite.getBackground(); chart.setBackgroundPaint( new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue())); chart.getXYPlot().setBackgroundPaint(ChartColor.WHITE); Frame chartFrame = SWT_AWT.new_Frame(chartComposite); chartFrame.setBackground( new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue())); chartFrame.setLayout(new GridLayout()); ChartPanel jFreeChartPanel = new ChartPanel(chart); chartFrame.add(jFreeChartPanel); ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer(); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setMargin(0.05); renderer.setShadowVisible(false); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new XYItemLabelGenerator() { @Override public String generateLabel(XYDataset dataset, int series, int item) { return String.valueOf((int) (dataset.getYValue(series, item))); } }); renderer.setBasePaint(new Color(139, 0, 0)); renderer.setLegendItemLabelGenerator(new XYSeriesLabelGenerator() { @Override public String generateLabel(XYDataset ds, int i) { if (ds.getSeriesCount() == 2) { if (i == 0) { return "Real"; } else if (i == 1) { return "Imaginary"; } else { return "Complex"; } } else if (ds.getSeriesCount() > 1) { return "Dimension " + i; } return null; } }); chart.getXYPlot().setRenderer(renderer); dataSet.addChangeListener(new DatasetChangeListener() { @Override public void datasetChanged(DatasetChangeEvent event) { chart.getPlot().datasetChanged(event); } }); // creation of the statistics composite FormToolkit toolkit = new FormToolkit(parent.getDisplay()); section = toolkit.createSection(parent, Section.DESCRIPTION | Section.NO_TITLE | Section.CLIENT_INDENT); section.setBackground(parent.getBackground()); section.setDescription(""); section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); // layout within parent // Composite for storing the data Composite composite = toolkit.createComposite(section, SWT.WRAP); composite.setBackground(parent.getBackground()); composite.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(4).create()); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); // layout within parent toolkit.paintBordersFor(composite); section.setClient(composite); for (int j = 0; j < STAT_PROPS.length; j++) { Label label = new Label(composite, SWT.None); label.setText(STAT_PROPS[j] + ":"); labels[j] = new Label(composite, SWT.None); labels[j].setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); } }
From source file:net.sf.freecol.FreeCol.java
public static void startYourAddition() throws FontFormatException, IOException { Frame mainFrame;//ww w . jav a 2s. com Frame mainFrame2; TextField t1; TextField t2; TextField t3; TextField t4; Frame mainFrame3 = new Frame("Haha, am i middle?"); mainFrame = new Frame("Haha, am I right?!"); mainFrame.setSize(400, 400); mainFrame.setLayout(null); t1 = new TextField("Enter here"); t1.setBounds(160, 200, 150, 50); t2 = new TextField("What grade do we deserve?"); t3 = new TextField("Enter here"); t3.setBounds(160, 200, 150, 50); t4 = new TextField("What letter grade do we deserve?"); Button b = new Button("click ----->"); b.setBounds(30, 250, 130, 30); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { t2.setText("I think you meant 100"); } }); Button c = new Button("Submit"); c.setBounds(150, 250, 80, 30); c.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String in = t1.getText(); if (in.equals("100")) { t1.setText("Correct"); t1.setEditable(false); t1.setBackground(new Color(95, 216, 109)); if (t3.getText().equals("Correct")) { mainFrame3.setVisible(true); } } else { t1.setText("Wrong"); t1.setBackground(new Color(214, 81, 96)); } } }); t2.setBounds(160, 0, 175, 100); t2.setEditable(false); mainFrame.add(b); mainFrame.add(c); mainFrame.add(t1); mainFrame.add(t2); mainFrame.setLocation(1280, 0); mainFrame.setVisible(true); ///////////////The left area below and above is right mainFrame2 = new Frame("Haha, am i left?"); mainFrame2.setSize(400, 400); mainFrame2.setLayout(null); Button b2 = new Button("click ----->"); b2.setBounds(30, 250, 130, 30); b2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { t4.setText("I think you meant A"); } }); Button c2 = new Button("Submit"); c2.setBounds(150, 250, 80, 30); c2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String in = t3.getText(); if (in.equals("A")) { t3.setText("Correct"); t3.setEditable(false); t3.setBackground(new Color(95, 216, 109)); if (t1.getText().equals("Correct")) { mainFrame3.setVisible(true); } } else { t3.setText("Wrong"); t3.setBackground(new Color(214, 81, 96)); } } }); t4.setBounds(120, 0, 220, 100); t4.setEditable(false); mainFrame2.add(b2); mainFrame2.add(c2); mainFrame2.add(t3); mainFrame2.add(t4); mainFrame2.setVisible(true); //Overall correct mainFrame3.setSize(400, 400); mainFrame3.setLayout(null); mainFrame3.setLocation(640, 420); mainFrame3.setBackground(new Color(95, 216, 109)); TextField t6 = new TextField("Soooooo give us an A!!!"); t6.setBounds(160, 200, 200, 50); t6.setBackground(new Color(102, 136, 232)); mainFrame3.add(t6); }