List of usage examples for java.awt Panel add
public Component add(Component comp)
From source file:edu.harvard.i2b2.query.ui.QueryC.java
/** * @param args/*from ww w . ja v a2 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 1.6.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) { queryToolPanel = new QueryToolInvestigatorPanel(this); } else { queryToolPanel = new QueryToolPanel(this); } oAwtContainer.add(queryToolPanel); queryToolPanel.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; }
From source file:edu.harvard.i2b2.previousquery.QueryC.java
/** * @param args/*www . j a v a 2 s . c o 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; }
From source file:ExposedFloat.java
public void init() { Panel buttonPanel = new PanelWithInsets(0, 0, 0, 0); buttonPanel.setLayout(new GridLayout(6, 2, 5, 5)); buttonPanel.add(maximumButton); buttonPanel.add(minimumButton);//from w w w. j a va2 s .c o m buttonPanel.add(positiveInfinityButton); buttonPanel.add(negativeInfinityButton); buttonPanel.add(piButton); buttonPanel.add(notANumberButton); buttonPanel.add(new Button(multByZeroButtonString)); buttonPanel.add(new Button(changeSignButtonString)); buttonPanel.add(new Button(doubleButtonString)); buttonPanel.add(new Button(halveButtonString)); buttonPanel.add(new RepeaterButton(incrementButtonString)); buttonPanel.add(new RepeaterButton(decrementButtonString)); binaryField = new Label("00000000000000000000000000000000"); signField = new Label("0"); exponentField = new Label("00000000"); mantissaField = new Label("000000000000000000000000"); hexField = new Label("00000000"); base2Field = new Label("0"); base10Field = new Label("0"); Font fieldFont = new Font("TimesRoman", Font.PLAIN, 12); binaryField.setFont(fieldFont); signField.setFont(fieldFont); exponentField.setFont(fieldFont); mantissaField.setFont(fieldFont); hexField.setFont(fieldFont); base2Field.setFont(fieldFont); base10Field.setFont(fieldFont); Panel numberPanel = new Panel(); numberPanel.setBackground(Color.white); numberPanel.setLayout(new GridLayout(7, 1)); numberPanel.add(signField); numberPanel.add(exponentField); numberPanel.add(mantissaField); 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(base2Field); numberPanel.add(base10Field); Panel labelPanel = new Panel(); labelPanel.setBackground(Color.white); labelPanel.setLayout(new GridLayout(7, 1)); Font labelFont = new Font("Helvetica", Font.ITALIC, 11); Label label = new Label(signString, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); label = new Label(exponentString, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); label = new Label(mantissaString, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); label = new Label(binaryString, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); label = new Label(hexString, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); label = new Label(base2String, Label.CENTER); label.setFont(labelFont); labelPanel.add(label); label = new Label(base10String, 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(titleString, Label.CENTER, Color.cyan); title.setFont(new Font("Helvetica", Font.BOLD, 12)); setBackground(Color.green); setLayout(new BorderLayout(5, 5)); add("North", title); add("West", buttonPanel); add("Center", dataPanel); }
From source file:Unicode.java
/** Construct the object including its GUI */ public Unicode() { super("Unicode"); Container cp = getContentPane(); // Used both for Buttons and Menus ResourceBundle b = ResourceBundle.getBundle("UnicodeWidgets"); JButton quitButton, nextButton, prevButton; Panel p = new Panel(); // Make a grid, add one for labels. p.setLayout(new GridLayout(ROWS + 1, COLUMNS + 1)); DecimalFormat df2d = new DecimalFormat("00"); // Add first row, just column labels. p.add(new JLabel("")); for (int i = 0; i < COLUMNS; i++) p.add(new JLabel(Integer.toString(i, 16), JLabel.CENTER)); // Add subsequent rows, each with an offset label for (int i = 0; i < ROWS; i++) { JLabel l = new JLabel("0000"); // room for max, i.e. \uFFFF p.add(l);/*from w w w. java 2 s .co m*/ rowLabs[i] = l; for (int j = 0; j < COLUMNS; j++) { JLabel pb = new JLabel(" "); buttons[j][i] = pb; p.add(pb); } } // ActionListeners for jumping around; used by buttons and menus ActionListener firster = new ActionListener() { public void actionPerformed(ActionEvent e) { gotoPage(startNum = 0); } }; ActionListener previouser = new ActionListener() { public void actionPerformed(ActionEvent e) { if (startNum > 0) gotoPage(startNum -= QUADSIZE); } }; ActionListener nexter = new ActionListener() { public void actionPerformed(ActionEvent e) { if (startNum < 65535) gotoPage(startNum += QUADSIZE); } }; ActionListener laster = new ActionListener() { public void actionPerformed(ActionEvent e) { gotoPage(65536 - QUADSIZE); } }; cp.add(BorderLayout.NORTH, p); fontName = new JLabel("Default font", JLabel.CENTER); cp.add(BorderLayout.CENTER, fontName); Panel q = new Panel(); cp.add(BorderLayout.SOUTH, q); q.add(prevButton = mkButton(b, "page.prev")); prevButton.addActionListener(previouser); q.add(nextButton = mkButton(b, "page.next")); nextButton.addActionListener(nexter); q.add(quitButton = mkButton(b, "exit")); quitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); dispose(); System.exit(0); } }); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { setVisible(false); dispose(); System.exit(0); } }); MenuItem mi; // used in various spots MenuBar mb = new MenuBar(); setMenuBar(mb); String titlebar; try { titlebar = b.getString("program" + ".title"); } catch (MissingResourceException e) { titlebar = "Unicode Demo"; } setTitle(titlebar); ActionListener fontSelector = new ActionListener() { public void actionPerformed(ActionEvent e) { String font = e.getActionCommand(); mySetFont(font, FONTSIZE); } }; Menu fontMenu = mkMenu(b, "font"); // String[] fontList = Toolkit.getDefaultToolkit().getFontList(); String[] fontList = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); for (int i = 0; i < fontList.length; i++) { fontMenu.add(mi = new MenuItem(fontList[i])); mi.addActionListener(fontSelector); } mb.add(fontMenu); gotoPageUI = new GoToPage("Unicode Page"); centre(gotoPageUI); Menu vm = mkMenu(b, "page"); vm.add(mi = mkMenuItem(b, "page", "first")); mi.addActionListener(firster); vm.add(mi = mkMenuItem(b, "page", "prev")); mi.addActionListener(previouser); vm.add(mi = mkMenuItem(b, "page", "next")); mi.addActionListener(nexter); vm.add(mi = mkMenuItem(b, "page", "last")); mi.addActionListener(laster); vm.add(mi = mkMenuItem(b, "page", "goto")); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Unicode.this.gotoPageUI.setVisible(true); } }); mb.add(vm); Menu hm = mkMenu(b, "help"); hm.add(mi = mkMenuItem(b, "help", "about")); mb.setHelpMenu(hm); // needed for portability (Motif, etc.). pack(); // After packing the Frame, centre it on the screen. centre(this); // start at a known place mySetFont(fontList[0], FONTSIZE); gotoPage(startNum); }
From source file:FileViewer.java
/** * The real constructor. Create a FileViewer object to display the specified * file from the specified directory// w w w.j ava 2s . co m */ 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:HiResCoordTest.java
protected void addCanvas3D(Canvas3D c3d) { setLayout(new BorderLayout()); Panel controlPanel = new Panel(); controlPanel.add(c3d); Button button = null;/* w w w . j av a2 s. c o m*/ button = new Button("Sun"); button.addActionListener(this); controlPanel.add(button); button = new Button("Earth"); button.addActionListener(this); controlPanel.add(button); button = new Button("House"); button.addActionListener(this); controlPanel.add(button); add(controlPanel, BorderLayout.SOUTH); add(c3d, BorderLayout.CENTER); doLayout(); }
From source file:Presentation.MainWindow.java
/** Ajout la fentre des valeurs de temprature et d'humidit en temps rel */ public void showLiveValues(float temperature, float humidite, boolean condense) { Panel panel = new Panel(); Label labelTemp = new Label("Temprature du frigo : " + temperature + " C"); Label labelOutdoorTemp = new Label( "Temprature extrieure : " + Singleton.getInstance().getMock().getOutdoorTemp() + " C"); Label labelHumid = new Label("Humidit l'intrieur du frigo : " + humidite + " %"); Label condensation = new Label("Alerte de condensation"); condensation.setForeground(Color.red); // addCondensation(); panel.setLayout(new FlowLayout()); panel.add(labelTemp); panel.add(labelOutdoorTemp);/*from w w w . ja v a 2s. c om*/ panel.add(labelHumid); if (condense) panel.add(condensation); else { panel.add(condensation); condensation.hide(); } // panel.add(cLabel); this.tPanel = panel; mPanel.add(panel); show(); }
From source file:Align_Projections.java
public void run(String arg) { if (instance != null) { instance.toFront();//from ww w. j a va2s. c o m return; } instance = this; addKeyListener(IJ.getInstance()); if (sourceStackImp == null) { sourceStackImp = WindowManager.getCurrentImage(); if (sourceStackImp != null) { centerPixel = 0.5 * (sourceStackImp.getWidth() - 1); } else { centerPixel = 50; // completely arbitrary } } setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); Panel valuesPanel = new Panel(); valuesPanel.setLayout(new GridLayout(6, 2)); Label centerPixelLabel = new Label("Center Pixel"); valuesPanel.add(centerPixelLabel); centerPixelText = new TextField(IJ.d2s(centerPixel, 1), 15); valuesPanel.add(centerPixelText); Label detectorAngleLabel = new Label("Detector Angle"); valuesPanel.add(detectorAngleLabel); detectorAngleText = new TextField(IJ.d2s(0, 4), 15); valuesPanel.add(detectorAngleText); Label horizontalBorderLabel = new Label("Horizontal Border"); valuesPanel.add(horizontalBorderLabel); horizontalBorderText = new TextField("0", 15); valuesPanel.add(horizontalBorderText); Label topBorderLabel = new Label("Top Border"); valuesPanel.add(topBorderLabel); topBorderText = new TextField("0", 15); valuesPanel.add(topBorderText); Label bottomBorderLabel = new Label("Bottom Border"); valuesPanel.add(bottomBorderLabel); bottomBorderText = new TextField("0", 15); valuesPanel.add(bottomBorderText); Label crossCorrelationLabel = new Label("Cross-Correlation"); valuesPanel.add(crossCorrelationLabel); crossCorrelationText = new Label("-"); valuesPanel.add(crossCorrelationText); this.add(valuesPanel); updateButton = addButton("Update"); optimizeButton = addButton("Optimize"); applyButton = addButton("Apply to stack and save"); resetButton = addButton("Reset"); pack(); GUI.center(this); show(); }
From source file:TexCoordTest.java
protected void addCanvas3D(Canvas3D c3d) { setLayout(new BorderLayout()); add(c3d, BorderLayout.CENTER); Panel controlPanel = new Panel(); // creates some GUI components so we can modify the // scene and texure coordinate generation at runtime Button eyeButton = new Button("EYE_LINEAR"); eyeButton.addActionListener(this); controlPanel.add(eyeButton); Button objectButton = new Button("OBJECT_LINEAR"); objectButton.addActionListener(this); controlPanel.add(objectButton);/* w w w . ja va2s . c o m*/ Button sphereButton = new Button("SPHERE_MAP"); sphereButton.addActionListener(this); controlPanel.add(sphereButton); Button rotateButton = new Button("Rotate"); rotateButton.addActionListener(this); controlPanel.add(rotateButton); Button translateButton = new Button("Translate"); translateButton.addActionListener(this); controlPanel.add(translateButton); add(controlPanel, BorderLayout.SOUTH); doLayout(); }
From source file:jotp.java
public void init() { setBackground(Color.white);//w w w. j a v a2s.c om setLayout(new GridLayout(6, 1)); Panel panel1 = new Panel(); add(panel1); Font titlefont = new Font("TimesRoman", Font.BOLD, 14); panel1.setFont(titlefont); panel1.add(new Label(String.valueOf(version) + ": The Java OTP (aka S/Key) calculator!")); Panel panel2 = new Panel(); panel2.setLayout(new FlowLayout()); add(panel2); panel2.add(new Label("Challenge (e.g. \"55 latour1\"):")); chaltf = new TextField(24); panel2.add(chaltf); Panel panel3 = new Panel(); panel3.setLayout(new FlowLayout()); add(panel3); panel3.add(new Label("Secret Password:")); pwtf = new TextField(24); pwtf.setEchoCharacter('*'); panel3.add(pwtf); Panel panel4 = new Panel(); panel4.setLayout(new FlowLayout()); add(panel4); panel4.add(new Button(String.valueOf(md4label))); panel4.add(new Button(String.valueOf(md5label))); Panel panel6 = new Panel(); panel6.setLayout(new FlowLayout()); add(panel6); panel6.add(new Label("One-Time Password:", Label.LEFT)); otptf = new TextField(40); panel6.add(otptf); Panel panel7 = new Panel(); add(panel7); panel7.add(new Label("jotp by Harry Mantakos, " + "http://www.cs.umd.edu/~harry/jotp")); }