List of usage examples for java.awt Panel Panel
public Panel(LayoutManager layout)
From source file:Snippet154.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED); /*/*from w w w .j av a2 s . c o m*/ * Set a Windows specific AWT property that prevents heavyweight * components from erasing their background. Note that this is a global * property and cannot be scoped. It might not be suitable for your * application. */ try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { } /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(composite); Panel panel = new Panel(new BorderLayout()) { public void update(java.awt.Graphics g) { /* Do not erase the background */ paint(g); } }; frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); java.awt.Container contentPane = root.getContentPane(); /* Creating components */ int nrows = 1000, ncolumns = 10; Vector rows = new Vector(); for (int i = 0; i < nrows; i++) { Vector row = new Vector(); for (int j = 0; j < ncolumns; j++) { row.addElement("Item " + i + "-" + j); } rows.addElement(row); } Vector columns = new Vector(); for (int i = 0; i < ncolumns; i++) { columns.addElement("Column " + i); } JTable table = new JTable(rows, columns); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.createDefaultColumnsFromModel(); JScrollPane scrollPane = new JScrollPane(table); contentPane.setLayout(new BorderLayout()); contentPane.add(scrollPane); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet154.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 154"); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED); /*/* ww w .ja v a 2s.co m*/ * Set a Windows specific AWT property that prevents heavyweight * components from erasing their background. Note that this * is a global property and cannot be scoped. It might not be * suitable for your application. */ try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { } /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(composite); Panel panel = new Panel(new BorderLayout()) { @Override public void update(java.awt.Graphics g) { /* Do not erase the background */ paint(g); } }; frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); java.awt.Container contentPane = root.getContentPane(); /* Creating components */ int nrows = 1000, ncolumns = 10; Vector<Vector<String>> rows = new Vector<>(); for (int i = 0; i < nrows; i++) { Vector<String> row = new Vector<>(); for (int j = 0; j < ncolumns; j++) { row.addElement("Item " + i + "-" + j); } rows.addElement(row); } Vector<String> columns = new Vector<>(); for (int i = 0; i < ncolumns; i++) { columns.addElement("Column " + i); } JTable table = new JTable(rows, columns); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.createDefaultColumnsFromModel(); JScrollPane scrollPane = new JScrollPane(table); contentPane.setLayout(new BorderLayout()); contentPane.add(scrollPane); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:EmbedJTableSWTNoFlicker.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED); /*/*from w w w.j a va 2 s .c o m*/ * Set a Windows specific AWT property that prevents heavyweight components * from erasing their background. Note that this is a global property and * cannot be scoped. It might not be suitable for your application. */ try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { } /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(composite); Panel panel = new Panel(new BorderLayout()) { public void update(java.awt.Graphics g) { /* Do not erase the background */ paint(g); } }; frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); java.awt.Container contentPane = root.getContentPane(); /* Creating components */ int nrows = 1000, ncolumns = 10; Vector rows = new Vector(); for (int i = 0; i < nrows; i++) { Vector row = new Vector(); for (int j = 0; j < ncolumns; j++) { row.addElement("Item " + i + "-" + j); } rows.addElement(row); } Vector columns = new Vector(); for (int i = 0; i < ncolumns; i++) { columns.addElement("Column " + i); } JTable table = new JTable(rows, columns); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.createDefaultColumnsFromModel(); JScrollPane scrollPane = new JScrollPane(table); contentPane.setLayout(new BorderLayout()); contentPane.add(scrollPane); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:CardFrame.java
public CardFrame(String title) { setLayout(new BorderLayout(10, 10)); nextCard.addActionListener(this); prevCard.addActionListener(this); firstCard.addActionListener(this); lastCard.addActionListener(this); Panel buttonsPanel = new Panel(new FlowLayout(FlowLayout.CENTER)); buttonsPanel.add(firstCard);//www.j av a 2s. c o m buttonsPanel.add(prevCard); buttonsPanel.add(nextCard); buttonsPanel.add(lastCard); setCardLayout(); add(BorderLayout.CENTER, cardPanel); add(BorderLayout.NORTH, buttonsPanel); }
From source file:com.thoughtworks.go.agent.bootstrapper.osx.MacAboutBox.java
public MacAboutBox() { super(""); setResizable(false);/* w w w.j a v a2s .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:edu.harvard.i2b2.eclipse.plugins.patientMapping.views.PatientMappingView.java
/** * This is a callback that will allow us to create the viewer and initialize * it.//from w ww. j a va 2 s .c om */ @Override public void createPartControl(Composite parent) { log.info("Patient Mapping plugin version 1.7.0"); timelineComposite = parent; if (!(UserInfoBean.getInstance().isRoleInProject("DATA_LDS"))) { new NoAccessComposite(parent, SWT.NONE); return; } //explorer = new MainComposite(parent, false);*/ Composite composite = new Composite(parent, SWT.EMBEDDED); /* Create and setting up frame */ ////for mac fix //if ( System.getProperty("os.name").toLowerCase().startsWith("mac")) //SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame"; Frame runFrame = SWT_AWT.new_Frame(composite); Panel runPanel = new Panel(new BorderLayout()); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println("Error setting native LAF: " + e); } runFrame.add(runPanel); JRootPane runRoot = new JRootPane(); runPanel.add(runRoot); oAwtContainer = runRoot.getContentPane(); runTreePanel = new PatientMappingJPanel(oAwtContainer);//PreviousQueryPanel(this); //runTreePanel.setBackground(Color.BLUE); oAwtContainer.add(runTreePanel); // Setup help context PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, PATIENTMAPPING_VIEW_CONTEXT_ID); addHelpButtonToToolBar(); }
From source file:com.anji.floatingeye.FloatingEyeDisplay.java
private void init(Java2DSurface surface, FloatingEye anEye) { eye = anEye;// w w w. ja v a 2 s .c om // this frame has 3 sections - status, surface canvas, and eye canvas addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { setVisible(false); dispose(); } }); GridLayout mainLayout = new GridLayout(2, 1); mainLayout.setHgap(10); mainLayout.setVgap(10); getContentPane().setLayout(mainLayout); GridLayout topPanelLayout = new GridLayout(2, 1); topPanelLayout.setHgap(10); topPanelLayout.setVgap(10); Panel topPanel = new Panel(topPanelLayout); GridLayout bottomPanelLayout = new GridLayout(1, 2); bottomPanelLayout.setHgap(10); bottomPanelLayout.setVgap(10); Panel bottomPanel = new Panel(bottomPanelLayout); // 1 - status area statusArea = new TextArea("", 1, 1, TextArea.SCROLLBARS_VERTICAL_ONLY); statusArea.setEditable(false); statusArea.setFont(new Font("Dialog", Font.PLAIN, 10)); statusArea.setSize(new Dimension(IMG_WIDTH * 2, IMG_HEIGHT / 2)); // 2 - affinity history chart XYSeriesCollection seriesCollection = new XYSeriesCollection(affinitySeries); JFreeChart chart = ChartFactory.createXYLineChart("affinity history", "step", "affinity", seriesCollection, PlotOrientation.VERTICAL, false, false, false); ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis(); rangeAxis.setAutoRange(false); rangeAxis.setRange(0d, 1d); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(IMG_WIDTH * 2, IMG_HEIGHT / 2)); // 3 - surface canvas surfaceCanvas = new SurfaceCanvas(surface, eye, IMG_WIDTH, IMG_HEIGHT); surfaceCanvas.setBackground(Color.WHITE); // 4 - eye canvas eyeCanvas = new EyeCanvas(eye, IMG_WIDTH, IMG_HEIGHT); eyeCanvas.setBackground(Color.WHITE); topPanel.add(statusArea); topPanel.add(chartPanel); bottomPanel.add(surfaceCanvas); bottomPanel.add(eyeCanvas); getContentPane().add(topPanel); getContentPane().add(bottomPanel); pack(); }
From source file:edu.harvard.i2b2.eclipse.plugins.adminTool.views.AdminToolView.java
/** * This is a callback that will allow us to create the viewer and initialize * it.//from ww w . ja v a 2s . co m */ @Override public void createPartControl(Composite parent) { log.info("Patient Mapping plugin version 1.7.0"); timelineComposite = parent; boolean isManager = false; ArrayList<String> roles = (ArrayList<String>) UserInfoBean.getInstance().getProjectRoles(); for (String param : roles) { if (param.equalsIgnoreCase("manager")) { isManager = true; break; } } if (!(UserInfoBean.getInstance().isRoleInProject("DATA_PROT")) || !isManager) { new NoAccessComposite(parent, SWT.NONE); return; } //explorer = new MainComposite(parent, false);*/ Composite composite = new Composite(parent, SWT.EMBEDDED); /* Create and setting up frame */ ////for mac fix //if ( System.getProperty("os.name").toLowerCase().startsWith("mac")) //SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame"; Frame runFrame = SWT_AWT.new_Frame(composite); Panel runPanel = new Panel(new BorderLayout()); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println("Error setting native LAF: " + e); } runFrame.add(runPanel); JRootPane runRoot = new JRootPane(); runPanel.add(runRoot); oAwtContainer = runRoot.getContentPane(); runTreePanel = new AdminToolJPanel();//PatientMappingJPanel();//PreviousQueryPanel(this); //runTreePanel.setBackground(Color.BLUE); oAwtContainer.add(runTreePanel); // Setup help context PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ADMINTOOL_VIEW_CONTEXT_ID); addHelpButtonToToolBar(); }
From source file:edu.harvard.i2b2.eclipse.plugins.query.views.QueryView.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. co m*/ */ @Override public void createPartControl(Composite parent) { // setup context help PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, QUERY_VIEW_CONTEXT_ID); addHelpButtonToToolBar(); log.info("Query Tool plugin version 1.7.0"); GridLayout topGridLayout = new GridLayout(1, false); topGridLayout.numColumns = 1; topGridLayout.marginWidth = 2; topGridLayout.marginHeight = 2; parent.setLayout(topGridLayout); queryComposite = new Composite(parent, SWT.NONE); queryComposite.setLayout(new FillLayout(SWT.VERTICAL)); GridData gridData2 = new GridData(); gridData2.horizontalAlignment = GridData.FILL; gridData2.verticalAlignment = GridData.FILL; gridData2.grabExcessHorizontalSpace = true; gridData2.grabExcessVerticalSpace = true; queryComposite.setLayoutData(gridData2); Composite rightComp = new Composite(queryComposite, SWT.BORDER | SWT.EMBEDDED | SWT.DragDetect); /* Create and setting up frame */ ////for mac fix //if ( System.getProperty("os.name").toLowerCase().startsWith("mac")) //SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame"; Frame frame = SWT_AWT.new_Frame(rightComp); Panel panel = new Panel(new BorderLayout()); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println("Error setting native LAF: " + e); } frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); oAwtContainer = root.getContentPane(); if (mode_ == 0) { queryToolPanel = new QueryToolInvestigatorPanel(this); } else { queryToolPanel = new QueryToolPanel(); } oAwtContainer.add(queryToolPanel); }
From source file:edu.harvard.i2b2.query.QueryC.java
/** * @param args//from ww w .ja va 2 s .co m */ protected Control createContents(Composite parent) { //log.info("Starting Query Mode"); GridLayout topGridLayout = new GridLayout(1, false); topGridLayout.numColumns = 1; topGridLayout.marginWidth = 2; topGridLayout.marginHeight = 2; setLayout(topGridLayout); Composite queryComposite = new Composite(this, SWT.NONE); queryComposite.setLayout(new FillLayout(SWT.VERTICAL)); GridData gridData2 = new GridData(); gridData2.horizontalAlignment = GridData.FILL; gridData2.verticalAlignment = GridData.FILL; gridData2.grabExcessHorizontalSpace = true; gridData2.grabExcessVerticalSpace = true; queryComposite.setLayoutData(gridData2); // the horizontal sash form SashForm horizontalForm = new SashForm(queryComposite, SWT.HORIZONTAL); horizontalForm.setOrientation(SWT.HORIZONTAL); horizontalForm.setLayout(new GridLayout()); //left sash form SashForm leftVerticalForm = new SashForm(horizontalForm, SWT.VERTICAL); leftVerticalForm.setOrientation(SWT.VERTICAL); leftVerticalForm.setLayout(new GridLayout()); if (bWantStatusLine) { slm.createControl(this, SWT.NULL); } slm.setMessage("i2b2 Explorer Version 2.0"); slm.update(true); // Create the tab folder final TabFolder oTabFolder = new TabFolder(leftVerticalForm, SWT.NONE); // Create each tab and set its text, tool tip text, // image, and control TabItem oTreeTab = new TabItem(oTabFolder, SWT.NONE); oTreeTab.setText("Concept trees"); oTreeTab.setToolTipText("Hierarchically organized patient characteristics"); oTreeTab.setControl(getQueryTabControl(oTabFolder)); //TabItem oFindTab = new TabItem(oTabFolder, SWT.NONE); //oFindTab.setText("Find"); //oFindTab.setToolTipText("Free-form find tool for patient characteristics"); //FindTool find = new FindTool(slm); //oFindTab.setControl(find.getFindTabControl(oTabFolder)); // Select the first tab (index is zero-based) oTabFolder.setSelection(0); // Create the tab folder final TabFolder queryRunFolder = new TabFolder(leftVerticalForm, SWT.NONE); TabItem previousRunTab = new TabItem(queryRunFolder, SWT.NONE); previousRunTab.setText("Patient Sets and Previous Queries"); previousRunTab.setToolTipText("Patient Sets & Previous Queries"); final Composite composite = new Composite(queryRunFolder, SWT.EMBEDDED); previousRunTab.setControl(composite); /* Create and setting up frame */ Frame runFrame = SWT_AWT.new_Frame(composite); Panel runPanel = new Panel(new BorderLayout()); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println("Error setting native LAF: " + e); } runFrame.add(runPanel); JRootPane runRoot = new JRootPane(); runPanel.add(runRoot); oAwtContainer_left = runRoot.getContentPane(); //runTreePanel = new QueryPreviousRunsPanel(this, null); //oAwtContainer_left.add(runTreePanel); // Select the first tab (index is zero-based) queryRunFolder.setSelection(0); final SashForm verticalForm = new SashForm(horizontalForm, SWT.VERTICAL); verticalForm.setOrientation(SWT.VERTICAL); verticalForm.setLayout(null); Composite rightComp = new Composite(verticalForm, SWT.BORDER | SWT.EMBEDDED | SWT.DragDetect); /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(rightComp); Panel panel = new Panel(new BorderLayout()); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println("Error setting native LAF: " + e); } frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); oAwtContainer = root.getContentPane(); if (mode_ == 0) { queryPanel = new QueryPanelInvestigator(this); } else { queryPanel = new QueryPanel(this); } oAwtContainer.add(queryPanel); queryPanel.setSplitBounds(oAwtContainer.getBounds()); if (mode_ == 0) { //bottomC = new ExplorerC(verticalForm, false); verticalForm.setWeights(new int[] { 40, 50 }); } verticalForm.addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { if (mode_ == 0) { int height = verticalForm.getBounds().height; //System.out.println("Height: "+height); if (height > 285) { try { verticalForm.setWeights(new int[] { 285, height - 285 }); } catch (Exception e) { return; } } } } }); horizontalForm.setWeights(new int[] { 20, 70 }); return parent; }