List of usage examples for javax.swing BoxLayout BoxLayout
@ConstructorProperties({ "target", "axis" }) public BoxLayout(Container target, int axis)
From source file:common.AbstractGUI.java
protected void createLogPanel() { logPanel = new JPanel(); logPanel.setLayout(new BoxLayout(logPanel, BoxLayout.Y_AXIS)); logTextArea = new JTextArea(33, 30); logTextArea.setEditable(false);// w w w .j a va2s. c o m logTextArea.setAutoscrolls(true); logTextArea.setFont(new Font("Courier New", Font.PLAIN, 11)); logTextArea.setBackground(Color.DARK_GRAY); logTextArea.setForeground(Color.GREEN); logTextArea.addMouseListener(logTextAreaMouseListener); scrollPane = new JScrollPane(logTextArea); Box horizontalLayout = Box.createHorizontalBox(); filterTxt = new JTextField(); filterBtn = new JButton("Filter"); filterBtn.addActionListener(filterActionListner); filterTxt.setMaximumSize(new Dimension(250, 30)); horizontalLayout.add(filterTxt); horizontalLayout.add(filterBtn); logPanel.add(horizontalLayout); logPanel.add(scrollPane); tabbedPane.addTab("Log", logPanel); }
From source file:es.emergya.ui.gis.popups.GPSDialog.java
public GPSDialog(Recurso r) { super();/*w w w.j a v a2s. com*/ setAlwaysOnTop(true); setResizable(false); iconTransparente = LogicConstants.getIcon("48x48_transparente"); iconEnviando = LogicConstants.getIcon("anim_actualizando"); target = r; setDefaultCloseOperation(DISPOSE_ON_CLOSE); setPreferredSize(new Dimension(400, 150)); setTitle(i18n.getString("window.gps.titleBar") + " " + target.getIdentificador()); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } JPanel base = new JPanel(); base.setBackground(Color.WHITE); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); // Icono del titulo JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); final JLabel titleLabel = new JLabel(i18n.getString("window.gps.title"), LogicConstants.getIcon("tittleventana_icon_actualizargps"), JLabel.LEFT); titleLabel.setFont(LogicConstants.deriveBoldFont(12f)); title.add(titleLabel); title.setOpaque(false); base.add(title); // Area para mensajes JPanel notificationArea = new JPanel(); notificationArea.setOpaque(false); notification = new JLabel("PLACEHOLDER"); notification.setForeground(Color.WHITE); notificationArea.add(notification); base.add(notificationArea); JPanel buttons = new JPanel(); buttons.setOpaque(false); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); actualizar = new JButton(i18n.getString("window.gps.button.actualizar"), LogicConstants.getIcon("ventanacontextual_button_solicitargps")); actualizar.addActionListener(this); buttons.add(actualizar); buttons.add(Box.createHorizontalGlue()); progressIcon = new JLabel(iconTransparente); buttons.add(progressIcon); buttons.add(Box.createHorizontalGlue()); JButton cancel = new JButton(i18n.getString("Buttons.cancel"), LogicConstants.getIcon("button_cancel")); cancel.addActionListener(this); buttons.add(cancel); base.add(buttons); getContentPane().add(base); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) x = ((parentSize.width - mySize.width) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > mySize.height) y = ((parentSize.height - mySize.height) / 2) + topLeft.y; else y = topLeft.y; setLocation(x, y); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent arg0) { deleteErrorMessage(); } @Override public void windowClosed(WindowEvent arg0) { deleteErrorMessage(); } @Override public void windowClosing(WindowEvent arg0) { deleteErrorMessage(); } private void deleteErrorMessage() { SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { if (last_bandejaSalida != null) { MessageGenerator.remove(last_bandejaSalida.getId()); } return null; } @Override protected void done() { super.done(); GPSDialog.this.progressIcon.setIcon(iconTransparente); GPSDialog.this.progressIcon.repaint(); last_bandejaSalida = null; GPSDialog.this.notification.setText(""); GPSDialog.this.notification.repaint(); } }; sw.execute(); } }); }
From source file:InternalFrameEventDemo.java
protected void createDisplayWindow() { JButton b1 = new JButton("Show internal frame"); b1.setActionCommand(SHOW);//from w w w . jav a 2s. c o m b1.addActionListener(this); JButton b2 = new JButton("Clear event info"); b2.setActionCommand(CLEAR); b2.addActionListener(this); display = new JTextArea(3, 30); display.setEditable(false); JScrollPane textScroller = new JScrollPane(display); // Have to supply a preferred size, or else the scroll // area will try to stay as large as the text area. textScroller.setPreferredSize(new Dimension(200, 75)); textScroller.setMinimumSize(new Dimension(10, 10)); displayWindow = new JInternalFrame("Event Watcher", true, // resizable false, // not closable false, // not maximizable true); // iconifiable JPanel contentPane = new JPanel(); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); b1.setAlignmentX(CENTER_ALIGNMENT); contentPane.add(b1); contentPane.add(Box.createRigidArea(new Dimension(0, 5))); contentPane.add(textScroller); contentPane.add(Box.createRigidArea(new Dimension(0, 5))); b2.setAlignmentX(CENTER_ALIGNMENT); contentPane.add(b2); displayWindow.setContentPane(contentPane); displayWindow.pack(); displayWindow.setVisible(true); }
From source file:events.TableListSelectionDemo.java
public TableListSelectionDemo() { super(new BorderLayout()); String[] columnNames = { "French", "Spanish", "Italian" }; String[][] tableData = { { "un", "uno", "uno" }, { "deux", "dos", "due" }, { "trois", "tres", "tre" }, { "quatre", "cuatro", "quattro" }, { "cinq", "cinco", "cinque" }, { "six", "seis", "sei" }, { "sept", "siete", "sette" } }; table = new JTable(tableData, columnNames); listSelectionModel = table.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); table.setSelectionModel(listSelectionModel); JScrollPane tablePane = new JScrollPane(table); //Build control area (use default FlowLayout). JPanel controlPane = new JPanel(); String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" }; final JComboBox comboBox = new JComboBox(modes); comboBox.setSelectedIndex(2);// w w w.j a v a 2 s .c om comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newMode = (String) comboBox.getSelectedItem(); if (newMode.equals("SINGLE_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } else { listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } output.append("----------" + "Mode: " + newMode + "----------" + newline); } }); controlPane.add(new JLabel("Selection mode:")); controlPane.add(comboBox); //Build output area. output = new JTextArea(1, 10); output.setEditable(false); JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); //Do the layout. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS)); JPanel listContainer = new JPanel(new GridLayout(1, 1)); JPanel tableContainer = new JPanel(new GridLayout(1, 1)); tableContainer.setBorder(BorderFactory.createTitledBorder("Table")); tableContainer.add(tablePane); tablePane.setPreferredSize(new Dimension(420, 130)); topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); topHalf.add(listContainer); topHalf.add(tableContainer); topHalf.setMinimumSize(new Dimension(250, 50)); topHalf.setPreferredSize(new Dimension(200, 110)); splitPane.add(topHalf); JPanel bottomHalf = new JPanel(new BorderLayout()); bottomHalf.add(controlPane, BorderLayout.PAGE_START); bottomHalf.add(outputPane, BorderLayout.CENTER); //XXX: next line needed if bottomHalf is a scroll pane: //bottomHalf.setMinimumSize(new Dimension(400, 50)); bottomHalf.setPreferredSize(new Dimension(450, 110)); splitPane.add(bottomHalf); }
From source file:com.intel.stl.ui.common.view.DistributionPiePanel.java
public void setLabels(String[] itemNames, ImageIcon[] icons, int labelColumns) { if (icons.length != itemNames.length) { throw new IllegalArgumentException( "Inconsistent number of items. " + " itemNames=" + itemNames.length + " icons=" + icons.length); }//w w w. ja va2 s. c o m labels = new JLabel[icons.length]; for (int i = 0; i < icons.length; i++) { labels[i] = new JLabel(itemNames[i], icons[i], JLabel.LEFT); } int rows = 1; if (labelColumns <= 0) { labelPanel.setLayout(new FlowLayout()); for (JLabel label : labels) { labelPanel.add(label); } } else { BoxLayout layout = new BoxLayout(labelPanel, BoxLayout.X_AXIS); labelPanel.setLayout(layout); JPanel[] columns = new JPanel[labelColumns]; for (int i = 0; i < columns.length; i++) { labelPanel.add(Box.createHorizontalGlue()); columns[i] = new JPanel(); columns[i].setOpaque(false); columns[i].setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3)); BoxLayout cLayout = new BoxLayout(columns[i], BoxLayout.Y_AXIS); columns[i].setLayout(cLayout); labelPanel.add(columns[i]); } labelPanel.add(Box.createHorizontalGlue()); rows = (int) Math.ceil((double) labels.length / labelColumns); int index = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < labelColumns; j++) { columns[i].add(index < labels.length ? labels[index] : Box.createGlue()); index += 1; } } } }
From source file:de.biomedical_imaging.ij.plot.HistogramPlotter.java
public HistogramPlotter(String title, String xlabel, double[][] data, int numberOfParticles, int meanTrackLength, IDatasetCreator datacreator) { super(title); this.title = title; this.xlabel = xlabel; this.numberOfParticles = numberOfParticles; this.meanTrackLength = meanTrackLength; IntervalXYDataset xydataset = datacreator.create(data); boolean isbarplot = (datacreator instanceof BarplotDataset); txt = new JLabel(); Font f = new Font("Verdana", Font.PLAIN, 12); txt.setFont(f);/*from w ww.j av a 2s. c o m*/ JFreeChart chart = createChart(xydataset, isbarplot); ChartPanel chartPanel = new ChartPanel(chart); txt.setText(formatSettingsString()); main = new JPanel(); main.setPreferredSize(new java.awt.Dimension(500, 350)); main.add(chartPanel); main.add(txt); setContentPane(main); setLayout(new BoxLayout(main, BoxLayout.Y_AXIS)); pack(); setVisible(true); JMenuItem savebutton = ((JMenuItem) chartPanel.getPopupMenu().getComponent(3)); chartPanel.getPopupMenu().remove(3); // Remove Save button //ActionListener al = savebutton.getActionListeners()[0]; savebutton = new JMenuItem("Save as png"); //savebutton.removeActionListener(al); savebutton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub try { JFileChooser saveFile = new JFileChooser(); saveFile.setAcceptAllFileFilterUsed(false); saveFile.addChoosableFileFilter(new FileNameExtensionFilter("Images", "png")); int userSelection = saveFile.showSaveDialog(main); if (userSelection == JFileChooser.APPROVE_OPTION) { BufferedImage bi = ScreenImage.createImage(main); File fileToSave = saveFile.getSelectedFile(); String filename = fileToSave.getName(); int i = filename.lastIndexOf('.'); String suffix = filename.substring(i + 1); String path = fileToSave.getAbsolutePath(); if (!(suffix.equals("png"))) { path += ".png"; } ScreenImage.writeImage(bi, path); } } catch (IOException e) { // TODO Auto-generated catch block IJ.log("" + e.getMessage()); } } }); chartPanel.getPopupMenu().insert(savebutton, 3); }
From source file:com.employee.scheduler.nurserostering.swingui.NurseRosteringPanel.java
private void createEmployeeListPanel() { employeeListPanel = new JPanel(); employeeListPanel.setLayout(new BoxLayout(employeeListPanel, BoxLayout.Y_AXIS)); unassignedPanel = new EmployeePanel(this, Collections.<ShiftDate>emptyList(), Collections.<Shift>emptyList(), null); employeeListPanel.add(unassignedPanel); employeeToPanelMap = new LinkedHashMap<Employee, EmployeePanel>(); employeeToPanelMap.put(null, unassignedPanel); }
From source file:executor.TesterMainGUIMode.java
public TesterMainGUIMode(IStrategy strategy) { this.strategy = strategy; setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); this.showChartFrame(); }
From source file:coreferenceresolver.gui.MarkupGUI.java
public MarkupGUI() throws IOException { highlightPainters = new ArrayList<>(); for (int i = 0; i < COLORS.length; ++i) { DefaultHighlighter.DefaultHighlightPainter highlightPainter = new DefaultHighlighter.DefaultHighlightPainter( COLORS[i]);/*from ww w .j a v a 2s . com*/ highlightPainters.add(highlightPainter); } defaulPath = FileUtils.readFileToString(new File(".\\src\\coreferenceresolver\\gui\\defaultpath")); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(new BorderLayout()); this.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize()); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); //create menu items JMenuItem importMenuItem = new JMenuItem("Import"); JMenuItem exportMenuItem = new JMenuItem("Export"); fileMenu.add(importMenuItem); fileMenu.add(exportMenuItem); menuBar.add(fileMenu); this.setJMenuBar(menuBar); ScrollablePanel mainPanel = new ScrollablePanel(); mainPanel.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.NONE); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); //IMPORT BUTTON importMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // MarkupGUI.reviewElements.clear(); // MarkupGUI.markupReviews.clear(); JFileChooser markupFileChooser = new JFileChooser(defaulPath); markupFileChooser.setDialogTitle("Choose your markup file"); markupFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { final JDialog d = new JDialog(); JPanel p1 = new JPanel(new GridBagLayout()); p1.add(new JLabel("Please Wait..."), new GridBagConstraints()); d.getContentPane().add(p1); d.setSize(100, 100); d.setLocationRelativeTo(null); d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); d.setModal(true); SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() { protected Void doInBackground() throws IOException, BadLocationException { readMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath()); for (int i = 0; i < markupReviews.size(); ++i) { mainPanel.add(newReviewPanel(markupReviews.get(i), i)); } return null; } protected void done() { MarkupGUI.this.revalidate(); d.dispose(); } }; worker.execute(); d.setVisible(true); } else { return; } } }); //EXPORT BUTTON: GET NEW VALUE (REF, TYPE) OF NPs exportMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser markupFileChooser = new JFileChooser(defaulPath); markupFileChooser.setDialogTitle("Choose where your markup file saved"); markupFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (markupFileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { final JDialog d = new JDialog(); JPanel p1 = new JPanel(new GridBagLayout()); p1.add(new JLabel("Please Wait..."), new GridBagConstraints()); d.getContentPane().add(p1); d.setSize(100, 100); d.setLocationRelativeTo(null); d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); d.setModal(true); SwingWorker<?, ?> worker = new SwingWorker<Void, Void>() { protected Void doInBackground() throws IOException { for (Review review : markupReviews) { generateNPsRef(review); } int i = 0; for (ReviewElement reviewElement : reviewElements) { int j = 0; for (Element element : reviewElement.elements) { String newType = element.typeSpinner.getValue().toString(); if (newType.equals("Object")) { markupReviews.get(i).getNounPhrases().get(j).setType(0); } else if (newType.equals("Attribute")) { markupReviews.get(i).getNounPhrases().get(j).setType(3); } else if (newType.equals("Other")) { markupReviews.get(i).getNounPhrases().get(j).setType(1); } else if (newType.equals("Candidate")) { markupReviews.get(i).getNounPhrases().get(j).setType(2); } ++j; } ++i; } initMarkupFile(markupFileChooser.getSelectedFile().getAbsolutePath() + File.separator + "markup.out.txt"); return null; } protected void done() { d.dispose(); try { Desktop.getDesktop() .open(new File(markupFileChooser.getSelectedFile().getAbsolutePath())); } catch (IOException ex) { Logger.getLogger(MarkupGUI.class.getName()).log(Level.SEVERE, null, ex); } } }; worker.execute(); d.setVisible(true); } else { return; } } }); JScrollPane scrollMainPane = new JScrollPane(mainPanel); scrollMainPane.getVerticalScrollBar().setUnitIncrement(16); scrollMainPane.setPreferredSize(new Dimension(this.getWidth(), this.getHeight())); scrollMainPane.setSize(this.getWidth(), this.getHeight()); this.setResizable(false); this.add(scrollMainPane, BorderLayout.CENTER); this.setExtendedState(JFrame.MAXIMIZED_BOTH); this.pack(); }
From source file:SimpleDateFormatDemo.java
public SimpleDateFormatDemo() { today = new Date(); availableLocales = new LocaleGroup(); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); patternLabel1.setAlignmentX(Component.LEFT_ALIGNMENT); patternLabel2.setAlignmentX(Component.LEFT_ALIGNMENT); JComboBox patternList = new JComboBox(patternExamples); patternList.setSelectedIndex(0);//from w w w . j av a2 s . c o m patternList.setEditable(true); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); PatternListener patternListener = new PatternListener(); patternList.addActionListener(patternListener); // Set up the UI for selecting a locale. JLabel localeLabel = new JLabel("Select a Locale from the list:"); localeLabel.setAlignmentX(Component.LEFT_ALIGNMENT); JComboBox localeList = new JComboBox(availableLocales.getStrings()); localeList.setSelectedIndex(0); localeList.setAlignmentX(Component.LEFT_ALIGNMENT); LocaleListener localeListener = new LocaleListener(); localeList.addActionListener(localeListener); // Create the UI for displaying result JLabel resultLabel = new JLabel("Current Date and Time", JLabel.LEFT); resultLabel.setAlignmentX(Component.LEFT_ALIGNMENT); result = new JLabel(" "); result.setForeground(Color.black); result.setAlignmentX(Component.LEFT_ALIGNMENT); result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.Y_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternPanel.add(patternList); JPanel localePanel = new JPanel(); localePanel.setLayout(new BoxLayout(localePanel, BoxLayout.Y_AXIS)); localePanel.add(localeLabel); localePanel.add(localeList); JPanel resultPanel = new JPanel(); resultPanel.setLayout(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); patternPanel.setAlignmentX(Component.CENTER_ALIGNMENT); localePanel.setAlignmentX(Component.CENTER_ALIGNMENT); resultPanel.setAlignmentX(Component.CENTER_ALIGNMENT); add(patternPanel); add(Box.createVerticalStrut(10)); add(localePanel); add(Box.createVerticalStrut(10)); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); }