List of usage examples for java.awt Panel Panel
public Panel()
From source file:FileViewer.java
/** * The real constructor. Create a FileViewer object to display the specified * file from the specified directory/* www .j av a2 s.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:br.upe.ecomp.dosa.controller.chart.FileLineChartDirectorManager.java
/** * {@inheritDoc}/*from ww w . ja va2 s. c o m*/ */ // 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:CardLayDemo1.java
public void init() { panel = new Panel(); cardlay = new CardLayout(); b1 = new Button("Next"); b1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (++cardno >= NCARDS) cardno = 0;//from w ww. j av a 2s . c o m cardlay.show(panel, labels[cardno]); } }); labels[0] = "Card One"; labels[1] = "Card Two"; labels[2] = "Card Three"; labels[3] = "Card Four"; panel.setLayout(cardlay); for (int i = 0; i < NCARDS; i++) panel.add(labels[i], new Label(labels[i])); cardlay.show(panel, labels[0]); setLayout(new BorderLayout()); add("Center", panel); add("South", b1); }
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);//ww w . ja v a 2 s . c o m ChartPanel jFreeChartPanel = new ChartPanel(chart); chartPanel.add(jFreeChartPanel); return chartPanel; }
From source file:jotp.java
public void init() { setBackground(Color.white);// w ww.ja v a 2 s .co m 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")); }
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. j a v a2s. c o 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: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);/*w w w .ja v a 2s. co m*/ panel.add(labelOutdoorTemp); 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: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. c o m 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); }
From source file:FileLister.java
/** * Constructor: create the GUI, and list the initial directory. *///from w w w .j av a 2s . c o m public FileLister(String directory, FilenameFilter filter) { super("File Lister"); // Create the window this.filter = filter; // Save the filter, if any // Destroy the window when the user requests it addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); list = new List(12, false); // Set up the list list.setFont(new Font("MonoSpaced", Font.PLAIN, 14)); list.addActionListener(this); list.addItemListener(this); details = new TextField(); // Set up the details area details.setFont(new Font("MonoSpaced", Font.PLAIN, 12)); details.setEditable(false); buttons = new Panel(); // Set up the button box buttons.setLayout(new FlowLayout(FlowLayout.RIGHT, 15, 5)); buttons.setFont(new Font("SansSerif", Font.BOLD, 14)); up = new Button("Up a Directory"); // Set up the two buttons close = new Button("Close"); up.addActionListener(this); close.addActionListener(this); buttons.add(up); // Add buttons to button box buttons.add(close); this.add(list, "Center"); // Add stuff to the window this.add(details, "North"); this.add(buttons, "South"); this.setSize(500, 350); listDirectory(directory); // And now list initial directory. }
From source file:BouncingBall.java
public BouncingBall() { setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); add("Center", c); c.addKeyListener(this); timer = new Timer(100, this); //timer.start(); Panel p = new Panel(); p.add(go);//from ww w . j a va 2s. co m add("North", p); go.addActionListener(this); go.addKeyListener(this); // Create a simple scene and attach it to the virtual universe BranchGroup scene = createSceneGraph(); SimpleUniverse u = new SimpleUniverse(c); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(scene); }