List of usage examples for javax.swing BoxLayout LINE_AXIS
int LINE_AXIS
To view the source code for javax.swing BoxLayout LINE_AXIS.
Click Source Link
From source file:com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.java
@SuppressWarnings("serial") @Override/* w w w . j a v a 2 s .com*/ public void installComponents(VFSJFileChooser fc) { AbstractVFSFileSystemView fsv = fc.getFileSystemView(); fc.setBorder(new EmptyBorder(12, 12, 11, 11)); fc.setLayout(new BorderLayout(0, 11)); filePane = new VFSFilePane(new MetalVFSFileChooserUIAccessor()); fc.addPropertyChangeListener(filePane); updateUseShellFolder(); // ********************************* // // **** Construct the top panel **** // // ********************************* // // Directory manipulation buttons JPanel topPanel = new JPanel(new BorderLayout(11, 0)); topButtonPanel = new JPanel(); topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS)); topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS); // Add the top panel to the fileChooser fc.add(topPanel, BorderLayout.NORTH); // ComboBox Label lookInLabel = new JLabel(lookInLabelText); topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS); // CurrentDir ComboBox directoryComboBox = new JComboBox() { @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); // Must be small enough to not affect total width. d.width = 150; return d; } }; directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText); directoryComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); lookInLabel.setLabelFor(directoryComboBox); directoryComboBoxModel = createDirectoryComboBoxModel(fc); directoryComboBox.setModel(directoryComboBoxModel); directoryComboBox.addActionListener(directoryComboBoxAction); directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc)); directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT); directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT); directoryComboBox.setMaximumRowCount(8); topPanel.add(directoryComboBox, BorderLayout.CENTER); // Up Button upFolderButton = new JButton(getChangeToParentDirectoryAction()); upFolderButton.setText(null); upFolderButton.setIcon(upFolderIcon); upFolderButton.setToolTipText(upFolderToolTipText); upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, upFolderAccessibleName); upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); upFolderButton.setMargin(shrinkwrap); topButtonPanel.add(upFolderButton); topButtonPanel.add(Box.createRigidArea(hstrut5)); // Home Button FileObject homeDir = fsv.getHomeDirectory(); String toolTipText = homeFolderToolTipText; if (fsv.isRoot(homeDir)) { toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop". } JButton b = new JButton(homeFolderIcon); b.setToolTipText(toolTipText); b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, homeFolderAccessibleName); b.setAlignmentX(JComponent.LEFT_ALIGNMENT); b.setAlignmentY(JComponent.CENTER_ALIGNMENT); b.setMargin(shrinkwrap); b.addActionListener(getGoHomeAction()); topButtonPanel.add(b); topButtonPanel.add(Box.createRigidArea(hstrut5)); // New Directory Button if (!UIManager.getBoolean("FileChooser.readOnly")) { b = new JButton(filePane.getNewFolderAction()); b.setText(null); b.setIcon(newFolderIcon); b.setToolTipText(newFolderToolTipText); b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, newFolderAccessibleName); b.setAlignmentX(JComponent.LEFT_ALIGNMENT); b.setAlignmentY(JComponent.CENTER_ALIGNMENT); b.setMargin(shrinkwrap); } topButtonPanel.add(b); topButtonPanel.add(Box.createRigidArea(hstrut5)); // View button group ButtonGroup viewButtonGroup = new ButtonGroup(); // List Button listViewButton = new JToggleButton(listViewIcon); listViewButton.setToolTipText(listViewButtonToolTipText); listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName); listViewButton.setSelected(true); listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); listViewButton.setMargin(shrinkwrap); listViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_LIST)); topButtonPanel.add(listViewButton); viewButtonGroup.add(listViewButton); // Details Button detailsViewButton = new JToggleButton(detailsViewIcon); detailsViewButton.setToolTipText(detailsViewButtonToolTipText); detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, detailsViewButtonAccessibleName); detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT); detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT); detailsViewButton.setMargin(shrinkwrap); detailsViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_DETAILS)); topButtonPanel.add(detailsViewButton); viewButtonGroup.add(detailsViewButton); filePane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("viewType".equals(e.getPropertyName())) { final int viewType = filePane.getViewType(); if (viewType == VFSFilePane.VIEWTYPE_LIST) { listViewButton.setSelected(true); } else if (viewType == VFSFilePane.VIEWTYPE_DETAILS) { detailsViewButton.setSelected(true); } } } }); // ************************************** // // ******* Add the directory pane ******* // // ************************************** // fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS); JComponent accessory = fc.getAccessory(); if (accessory != null) { getAccessoryPanel().add(accessory); } filePane.setPreferredSize(LIST_PREF_SIZE); fc.add(filePane, BorderLayout.CENTER); // ********************************** // // **** Construct the bottom panel ** // // ********************************** // bottomPanel = getBottomPanel(); bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS)); fc.add(bottomPanel, BorderLayout.SOUTH); // FileName label and textfield JPanel fileNamePanel = new JPanel(); fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS)); bottomPanel.add(fileNamePanel); bottomPanel.add(Box.createRigidArea(vstrut5)); fileNameLabel = new AlignedLabel(); populateFileNameLabel(); fileNamePanel.add(fileNameLabel); fileNameTextField = new JTextField(35) { @Override public Dimension getMaximumSize() { return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height); } }; PopupHandler.installDefaultMouseListener(fileNameTextField); fileNamePanel.add(fileNameTextField); fileNameLabel.setLabelFor(fileNameTextField); fileNameTextField.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { if (!getFileChooser().isMultiSelectionEnabled()) { filePane.clearSelection(); } } }); if (fc.isMultiSelectionEnabled()) { setFileName(fileNameString(fc.getSelectedFileObjects())); } else { setFileName(fileNameString(fc.getSelectedFileObject())); } // Filetype label and combobox JPanel filesOfTypePanel = new JPanel(); filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS)); bottomPanel.add(filesOfTypePanel); AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText); filesOfTypePanel.add(filesOfTypeLabel); filterComboBoxModel = createFilterComboBoxModel(); fc.addPropertyChangeListener(filterComboBoxModel); filterComboBox = new JComboBox(filterComboBoxModel); filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, filesOfTypeLabelText); filesOfTypeLabel.setLabelFor(filterComboBox); filterComboBox.setRenderer(createFilterComboBoxRenderer()); filesOfTypePanel.add(filterComboBox); // buttons getButtonPanel().setLayout(new ButtonAreaLayout()); approveButton = new JButton(getApproveButtonText(fc)); // Note: Metal does not use mnemonics for approve and cancel approveButton.addActionListener(getApproveSelectionAction()); fileNameTextField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { getApproveSelectionAction().actionPerformed(null); } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { getFileChooser().cancelSelection(); } } }); approveButton.setToolTipText(getApproveButtonToolTipText(fc)); getButtonPanel().add(approveButton); cancelButton = new JButton(cancelButtonText); cancelButton.setToolTipText(cancelButtonToolTipText); cancelButton.addActionListener(getCancelSelectionAction()); getButtonPanel().add(cancelButton); if (fc.getControlButtonsAreShown()) { addControlButtons(); } groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel }); }
From source file:com.tascape.qa.th.android.driver.App.java
/** * The method starts a GUI to let an user inspect element tree and take screenshot when the user is interacting * with the app-under-test manually. Please make sure to set timeout long enough for manual interaction. * * @param timeoutMinutes timeout in minutes to fail the manual steps * * @throws Exception if case of error/* w ww.ja va2 s . co m*/ */ public void interactManually(int timeoutMinutes) throws Exception { LOG.info("Start manual UI interaction"); long end = System.currentTimeMillis() + timeoutMinutes * 60000L; AtomicBoolean visible = new AtomicBoolean(true); AtomicBoolean pass = new AtomicBoolean(false); String tName = Thread.currentThread().getName() + "m"; SwingUtilities.invokeLater(() -> { JDialog jd = new JDialog((JFrame) null, "Manual Device UI Interaction - " + device.getProductDetail()); jd.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); JPanel jpContent = new JPanel(new BorderLayout()); jd.setContentPane(jpContent); jpContent.setPreferredSize(new Dimension(1088, 828)); jpContent.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel jpInfo = new JPanel(); jpContent.add(jpInfo, BorderLayout.PAGE_START); jpInfo.setLayout(new BorderLayout()); { JButton jb = new JButton("PASS"); jb.setForeground(Color.green.darker()); jb.setFont(jb.getFont().deriveFont(Font.BOLD)); jpInfo.add(jb, BorderLayout.LINE_START); jb.addActionListener(event -> { pass.set(true); jd.dispose(); visible.set(false); }); } { JButton jb = new JButton("FAIL"); jb.setForeground(Color.red); jb.setFont(jb.getFont().deriveFont(Font.BOLD)); jpInfo.add(jb, BorderLayout.LINE_END); jb.addActionListener(event -> { pass.set(false); jd.dispose(); visible.set(false); }); } JLabel jlTimeout = new JLabel("xxx seconds left", SwingConstants.CENTER); jpInfo.add(jlTimeout, BorderLayout.CENTER); jpInfo.add(jlTimeout, BorderLayout.CENTER); new SwingWorker<Long, Long>() { @Override protected Long doInBackground() throws Exception { while (System.currentTimeMillis() < end) { Thread.sleep(1000); long left = (end - System.currentTimeMillis()) / 1000; this.publish(left); } return 0L; } @Override protected void process(List<Long> chunks) { Long l = chunks.get(chunks.size() - 1); jlTimeout.setText(l + " seconds left"); if (l < 850) { jlTimeout.setForeground(Color.red); } } }.execute(); JPanel jpResponse = new JPanel(new BorderLayout()); JPanel jpProgress = new JPanel(new BorderLayout()); jpResponse.add(jpProgress, BorderLayout.PAGE_START); JTextArea jtaJson = new JTextArea(); jtaJson.setEditable(false); jtaJson.setTabSize(4); Font font = jtaJson.getFont(); jtaJson.setFont(new Font("Courier New", font.getStyle(), font.getSize())); JTree jtView = new JTree(); JTabbedPane jtp = new JTabbedPane(); jtp.add("tree", new JScrollPane(jtView)); jtp.add("json", new JScrollPane(jtaJson)); jpResponse.add(jtp, BorderLayout.CENTER); JPanel jpScreen = new JPanel(); jpScreen.setMinimumSize(new Dimension(200, 200)); jpScreen.setLayout(new BoxLayout(jpScreen, BoxLayout.PAGE_AXIS)); JScrollPane jsp1 = new JScrollPane(jpScreen); jpResponse.add(jsp1, BorderLayout.LINE_START); JPanel jpJs = new JPanel(new BorderLayout()); JTextArea jtaJs = new JTextArea(); jpJs.add(new JScrollPane(jtaJs), BorderLayout.CENTER); JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jpResponse, jpJs); jSplitPane.setResizeWeight(0.88); jpContent.add(jSplitPane, BorderLayout.CENTER); JPanel jpLog = new JPanel(); jpLog.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); jpLog.setLayout(new BoxLayout(jpLog, BoxLayout.LINE_AXIS)); JCheckBox jcbTap = new JCheckBox("Enable Click", null, false); jpLog.add(jcbTap); jpLog.add(Box.createHorizontalStrut(8)); JButton jbLogUi = new JButton("Log Screen"); jpResponse.add(jpLog, BorderLayout.PAGE_END); { jpLog.add(jbLogUi); jbLogUi.addActionListener((ActionEvent event) -> { jtaJson.setText("waiting for screenshot..."); Thread t = new Thread(tName) { @Override public void run() { LOG.debug("\n\n"); try { WindowHierarchy wh = device.loadWindowHierarchy(); jtView.setModel(getModel(wh)); jtaJson.setText(""); jtaJson.append(wh.root.toJson().toString(2)); jtaJson.append("\n"); File png = device.takeDeviceScreenshot(); BufferedImage image = ImageIO.read(png); int w = device.getDisplayWidth(); int h = device.getDisplayHeight(); BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = resizedImg.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2.drawImage(image, 0, 0, w, h, null); g2.dispose(); JLabel jLabel = new JLabel(new ImageIcon(resizedImg)); jpScreen.removeAll(); jsp1.setPreferredSize(new Dimension(w + 30, h)); jpScreen.add(jLabel); jLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { LOG.debug("clicked at {},{}", e.getPoint().getX(), e.getPoint().getY()); if (jcbTap.isSelected()) { device.click(e.getPoint().x, e.getPoint().y); device.waitForIdle(); jbLogUi.doClick(); } } }); } catch (Exception ex) { LOG.error("Cannot log screen", ex); jtaJson.append("Cannot log screen"); } jtaJson.append("\n\n\n"); LOG.debug("\n\n"); jd.setSize(jd.getBounds().width + 1, jd.getBounds().height + 1); jd.setSize(jd.getBounds().width - 1, jd.getBounds().height - 1); } }; t.start(); }); } jpLog.add(Box.createHorizontalStrut(38)); { JButton jbLogMsg = new JButton("Log Message"); jpLog.add(jbLogMsg); JTextField jtMsg = new JTextField(10); jpLog.add(jtMsg); jtMsg.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent pE) { } @Override public void focusGained(final FocusEvent pE) { jtMsg.selectAll(); } }); jtMsg.addKeyListener(new KeyAdapter() { @Override public void keyPressed(java.awt.event.KeyEvent e) { if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) { jbLogMsg.doClick(); } } }); jbLogMsg.addActionListener(event -> { Thread t = new Thread(tName) { @Override public void run() { String msg = jtMsg.getText(); if (StringUtils.isNotBlank(msg)) { LOG.info("{}", msg); jtMsg.selectAll(); } } }; t.start(); try { t.join(); } catch (InterruptedException ex) { LOG.error("Cannot take screenshot", ex); } jtMsg.requestFocus(); }); } jpLog.add(Box.createHorizontalStrut(38)); { JButton jbClear = new JButton("Clear"); jpLog.add(jbClear); jbClear.addActionListener(event -> { jtaJson.setText(""); }); } JPanel jpAction = new JPanel(); jpContent.add(jpAction, BorderLayout.PAGE_END); jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS)); jpJs.add(jpAction, BorderLayout.PAGE_END); jd.pack(); jd.setVisible(true); jd.setLocationRelativeTo(null); jbLogUi.doClick(); }); while (visible.get()) { if (System.currentTimeMillis() > end) { LOG.error("Manual UI interaction timeout"); break; } Thread.sleep(500); } if (pass.get()) { LOG.info("Manual UI Interaction returns PASS"); } else { Assert.fail("Manual UI Interaction returns FAIL"); } }
From source file:net.sf.dsig.DSApplet.java
private void initSwing() { try {//from ww w. ja v a 2 s .co m UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { logger.warn("UIManager.setLookAndFeel() failed", e); } JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS)); panel.setBackground(Color.decode(backgroundColor)); add(panel); boolean lockPrinted = false; if (formId != null) { Icon lockIcon = new ImageIcon(getClass().getResource("/icons/lock.png")); lockPrinted = true; JButton button = new JButton("Sign", lockIcon); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { available.acquireUninterruptibly(); try { signInternal(formId, null); } catch (Exception ex) { logger.error("Internal sign failed", e); } finally { available.release(); } } }); panel.add(button); } Icon infoIcon = new ImageIcon(getClass().getResource(lockPrinted ? "/icons/info.png" : "/icons/lock.png")); JLabel infoLabel = new JLabel(infoIcon); infoLabel.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { JOptionPane.showMessageDialog(null, printInfoMessage()); } public void mouseEntered(MouseEvent e) { /* NOOP */ } public void mouseExited(MouseEvent e) { /* NOOP */ } public void mousePressed(MouseEvent e) { /* NOOP */ } public void mouseReleased(MouseEvent e) { /* NOOP */ } }); panel.add(infoLabel); }
From source file:view.ResultsPanel.java
public void displayFrame(final List<ElementaryMode> modes, final List<Integer> indices) { this.removeAll(); DefaultTableModel model = (DefaultTableModel) modeTable.getModel(); while (model.getRowCount() > 0) { model.removeRow(0);//from w ww .j av a2 s . co m } if (modes.size() > 0) { setTable(0, modes); } JLabel nbMod = new JLabel(modes.size() + " mode(s) found"); toolbar = new JToolBar(); // set elements in the toolbar toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.LINE_AXIS)); toolbar.add(nbMod); toolbar.setFloatable(false); Object[] comboElements = new Object[modes.size()]; for (int i = 0; i < modes.size(); i++) { comboElements[i] = "mode " + indices.get(i); } modesCombo = new JComboBox(comboElements); if (modesCombo.getActionListeners().length > 0) { modesCombo.removeActionListener(modesCombo.getActionListeners()[0]); } modesCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setTable(modesCombo.getSelectedIndex(), modes); } }); if (modes.size() > 0) { toolbar.add(modesCombo); } modesCombo.setMaximumSize(new Dimension(100, 30)); //we put the right size for le comboBox int sizeMax = String.valueOf(modes.size()).length(); String stringMax = "mode "; for (int i = 0; i < sizeMax; i++) { stringMax += "X"; } modesCombo.setPrototypeDisplayValue(stringMax); if (download.getActionListeners().length > 0) { download.removeActionListener(download.getActionListeners()[0]); } download.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Thread thread = new DownloadContentThread(modes, controler, command, log.getText()); thread.start(); } }); if (histoButton.getActionListeners().length > 0) { histoButton.removeActionListener(histoButton.getActionListeners()[0]); } histoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { showHistogram(modes); } }); toolbar.add(histoButton); toolbar.add(filterButton); toolbar.add(download); toolbar.add(scriptButton); if (!isAttached) { toolbar.add(addToProject); } else { toolbar.add(removeFromProject); } toolbar.add(Box.createHorizontalGlue()); toolbar.add(searchField); toolbar.add(new JLabel(Var.iconsearch)); JPanel logPanel = new JPanel(new BorderLayout()); logPanel.add(new JLabel("Generetad log", JLabel.CENTER), BorderLayout.PAGE_START); logPanel.add(new JScrollPane(log), BorderLayout.CENTER); this.setLayout(new BorderLayout()); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(modeTable), logPanel); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(500); add(toolbar, BorderLayout.PAGE_START); this.add(splitPane, BorderLayout.CENTER); this.revalidate(); this.repaint(); }
From source file:gg.pistol.sweeper.gui.component.DecoratedPanel.java
/** * Helper factory method for creating a horizontal box layout {@link JPanel} that takes into account the locale. * * @return the created panel//from w w w . jav a 2 s .co m */ protected JPanel createHorizontalPanel() { JPanel panel = new JPanel(); panel.setComponentOrientation(ComponentOrientation.getOrientation(i18n.getLocale())); panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS)); return panel; }
From source file:com.moteiv.trawler.Trawler.java
public Trawler(String[] args) { init(args);/*from w ww.j a v a 2s. co m*/ // Install a different look and feel; specifically, the Windows look and feel try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); //"com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (InstantiationException e) { } catch (ClassNotFoundException e) { } catch (UnsupportedLookAndFeelException e) { } catch (IllegalAccessException e) { } jf = new JFrame("Trawler"); jf.setJMenuBar(getMainMenuBar()); g = new SparseGraph(); layout = new FRLayout(g); indexer = Indexer.newIndexer(g, 0); // layout.initialize(new Dimension(100, 100)); mif = new MoteInterface(g, Trawler.GROUPID, layout); uartDetect = new UartDetect(mif.getMoteIF()); Thread th = new Thread(uartDetect); th.start(); pr = new myPluggableRenderer(); vv = new VisualizationViewer(layout, pr); vv.init(); vv.setPickSupport(new ShapePickSupport()); vv.setBackground(Color.white); vv.setToolTipListener(new NodeTips(vv)); myVertexShapeFunction vsf = new myVertexShapeFunction(uartDetect); pr.setVertexShapeFunction(vsf); pr.setVertexIconFunction(vsf);//new myVertexShapeFunction()); m_vs = new VertexLabel(); java.awt.Font f = new java.awt.Font("Arial", Font.PLAIN, 12); pr.setEdgeFontFunction(new ConstantEdgeFontFunction(f)); pr.setVertexStringer(m_vs); m_es = new myEdgeLabel(); pr.setEdgeStringer(m_es); ((AbstractEdgeShapeFunction) pr.getEdgeShapeFunction()).setControlOffsetIncrement(-50.f); // pr.setVertexColorFunction(new myVertexColorFunction(Color.RED.darker().darker(), Color.RED, 500l)); pr.setEdgeStrokeFunction(new EdgeWeightStrokeFunction()); pr.setEdgeLabelClosenessFunction(new ConstantDirectionalEdgeValue(0.5, 0.5)); pr.setEdgePaintFunction(new myEdgeColorFunction()); scrollPane = new GraphZoomScrollPane(vv); jf.getContentPane().setLayout(new BoxLayout(jf.getContentPane(), BoxLayout.LINE_AXIS)); JTabbedPane pane = new JTabbedPane(); pane.addTab("Network Topology", scrollPane); pane.addTab("Sensor readings", createOscopePanel(mif.getMoteIF(), "ADC Readings", -33, -456, 300, 4100, "Time (seconds)", "ADC counts")); pane.addTab("Link Quality", createOscopePanel(mif.getMoteIF(), "LinkQualityPanel", -33, -15, 300, 135, "Time (seconds)", "Link Quality Indicator")); ImageIcon trawlerIcon = new ImageIcon(Trawler.class.getResource("images/trawler-icon.gif")); Image imageTrawler = trawlerIcon.getImage(); jf.getContentPane().add(pane); controlBoxFrame = new JFrame("Vizualization Control"); controlBoxFrame.getContentPane().add(getControls()); controlBoxFrame.setIconImage(imageTrawler); controlBoxFrame.pack(); // jf.getContentPane().add(getControls()); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); layout.initialize(vv.getSize()); layout.resize(vv.getSize()); layout.update(); loadPrefs(); GraphIO.loadGraph(g, layout, mif, Trawler.NODEFILE); // need this mouse model to keep the mouse clicks // aligned with the nodes DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); gm.setMode(ModalGraphMouse.Mode.PICKING); vv.setGraphMouse(gm); jf.setIconImage(imageTrawler); jf.pack(); jf.show(); controlBoxFrame.setVisible(true); timer = new Timer(); timer.schedule(new UpdateTask(), 500, 500); }
From source file:com.dbschools.quickquiz.client.giver.MainWindow.java
/** This method is called from within the constructor to * initialize the form.// w w w.j a va2 s . c o m * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; pnlPlayers = new javax.swing.JPanel(); pnlChat = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); txtChatLine = new javax.swing.JTextField(); btnSendChatLine = new javax.swing.JButton(); chkChatEnabled = new javax.swing.JCheckBox(); pnlMessages = new javax.swing.JPanel(); scpMessages = new javax.swing.JScrollPane(); lstMessages = new javax.swing.JList(); pnlQA = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); countdownMeter = new com.dbschools.gui.CountdownMeter(); pnlButtons = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); txtTimeLimit = new javax.swing.JFormattedTextField(); btnSendQuestion = new javax.swing.JButton(); pnlAward = new javax.swing.JPanel(); btnAwardPoints = new javax.swing.JButton(); sprPoints = new javax.swing.JSpinner(); cbxQuestions = new javax.swing.JComboBox(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); mnuReset = new javax.swing.JMenuItem(); jMenuItem1 = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); mnuLoad = new javax.swing.JMenuItem(); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } }); getContentPane().setLayout(new java.awt.GridBagLayout()); java.util.ResourceBundle bundle = java.util.ResourceBundle .getBundle("com/dbschools/quickquiz/client/giver/Bundle"); // NOI18N pnlPlayers.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("takers"))); // NOI18N pnlPlayers.setPreferredSize(new java.awt.Dimension(600, 250)); pnlPlayers.setRequestFocusEnabled(false); pnlPlayers.setLayout(new javax.swing.BoxLayout(pnlPlayers, javax.swing.BoxLayout.LINE_AXIS)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 0.6; gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2); getContentPane().add(pnlPlayers, gridBagConstraints); pnlChat.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("chat"))); // NOI18N pnlChat.setLayout(new java.awt.GridBagLayout()); jLabel4.setDisplayedMnemonic('m'); jLabel4.setLabelFor(txtChatLine); jLabel4.setText(bundle.getString("chatMessage")); // NOI18N pnlChat.add(jLabel4, new java.awt.GridBagConstraints()); txtChatLine.setColumns(40); java.util.ResourceBundle bundle1 = java.util.ResourceBundle.getBundle("quickquiz"); // NOI18N txtChatLine.setToolTipText(bundle1.getString("tttChatMessage")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 2); pnlChat.add(txtChatLine, gridBagConstraints); btnSendChatLine.setText(bundle.getString("sendChatLine")); // NOI18N btnSendChatLine.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSendChatLineActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 2); pnlChat.add(btnSendChatLine, gridBagConstraints); chkChatEnabled.setSelected(true); chkChatEnabled.setText("Enabled"); chkChatEnabled.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { chatEnable(evt); } }); pnlChat.add(chkChatEnabled, new java.awt.GridBagConstraints()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2); getContentPane().add(pnlChat, gridBagConstraints); pnlMessages.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("messages"))); // NOI18N pnlMessages.setLayout(new javax.swing.BoxLayout(pnlMessages, javax.swing.BoxLayout.LINE_AXIS)); lstMessages.setFont(new java.awt.Font("SansSerif", 0, 10)); lstMessages.setModel(new MessagesListModel()); lstMessages.setFocusable(false); lstMessages.setRequestFocusEnabled(false); scpMessages.setViewportView(lstMessages); pnlMessages.add(scpMessages); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weighty = 0.4; gridBagConstraints.insets = new java.awt.Insets(5, 2, 0, 2); getContentPane().add(pnlMessages, gridBagConstraints); pnlQA.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("qa"))); // NOI18N pnlQA.setLayout(new java.awt.GridBagLayout()); jLabel2.setDisplayedMnemonic('q'); jLabel2.setLabelFor(cbxQuestions); jLabel2.setText(bundle.getString("question")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); pnlQA.add(jLabel2, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); pnlQA.add(countdownMeter, gridBagConstraints); pnlButtons.setLayout(new javax.swing.BoxLayout(pnlButtons, javax.swing.BoxLayout.LINE_AXIS)); jLabel3.setDisplayedMnemonic('l'); jLabel3.setLabelFor(txtTimeLimit); jLabel3.setText(bundle.getString("timeLimit")); // NOI18N jPanel2.add(jLabel3); txtTimeLimit.setColumns(3); txtTimeLimit.setToolTipText(bundle1.getString("tttTimeLimit")); // NOI18N txtTimeLimit.setValue(new Integer(20)); jPanel2.add(txtTimeLimit); btnSendQuestion.setMnemonic('s'); btnSendQuestion.setText(bundle.getString("sendQuestion")); // NOI18N btnSendQuestion.setToolTipText(bundle1.getString("tttSendQuestion")); // NOI18N btnSendQuestion.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSendQuestionActionPerformed(evt); } }); jPanel2.add(btnSendQuestion); pnlButtons.add(jPanel2); btnAwardPoints.setMnemonic('a'); btnAwardPoints.setText(bundle.getString("winnerButton")); // NOI18N btnAwardPoints.setToolTipText(bundle.getString("tttAssignWinner")); // NOI18N btnAwardPoints.setEnabled(false); btnAwardPoints.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAwardPointsActionPerformed(evt); } }); pnlAward.add(btnAwardPoints); sprPoints.setToolTipText(bundle.getString("tttWinnerPoints")); // NOI18N sprPoints.setPreferredSize(new java.awt.Dimension(50, 24)); pnlAward.add(sprPoints); pnlButtons.add(pnlAward); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; pnlQA.add(pnlButtons, gridBagConstraints); cbxQuestions.setEditable(true); cbxQuestions.setMaximumRowCount(100); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 2.0; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); pnlQA.add(cbxQuestions, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); getContentPane().add(pnlQA, gridBagConstraints); jMenu1.setText(bundle.getString("quiz")); // NOI18N mnuReset.setText(bundle.getString("resetButton")); // NOI18N mnuReset.setToolTipText(bundle.getString("tttResetButton")); // NOI18N mnuReset.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuResetActionPerformed(evt); } }); jMenu1.add(mnuReset); jMenuItem1.setText("Add Simulated Takers"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addSimulatedTakers(evt); } }); jMenu1.add(jMenuItem1); jMenuBar1.add(jMenu1); jMenu2.setText(bundle.getString("questions")); // NOI18N mnuLoad.setText(bundle.getString("load")); // NOI18N mnuLoad.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuLoadActionPerformed(evt); } }); jMenu2.add(mnuLoad); jMenuBar1.add(jMenu2); setJMenuBar(jMenuBar1); pack(); }
From source file:io.github.jeremgamer.editor.panels.GeneralSettings.java
public GeneralSettings() { this.setBorder(BorderFactory.createTitledBorder("")); JPanel namePanel = new JPanel(); JLabel nameLabel = new JLabel("Nom :"); namePanel.add(nameLabel);//ww w . ja v a2s . c o m name.setPreferredSize(new Dimension(220, 30)); namePanel.add(name); CaretListener caretUpdateName = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); gs.set("name", text.getText()); } }; name.addCaretListener(caretUpdateName); this.add(namePanel); adress.setEditable(false); CaretListener caretUpdateAdress = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); gs.set("adress", text.getText()); } }; adress.addCaretListener(caretUpdateAdress); JPanel subTypePanel = new JPanel(); JLabel typeLabel = new JLabel("Type :"); subTypePanel.add(typeLabel); type.setPreferredSize(new Dimension(220, 30)); type.addItem("Minecraft classique"); type.addItem("Minecraft personnalis"); if (new File("projects/" + Editor.getProjectName() + "/data.zip").exists()) { type.setSelectedIndex(1); browse.setEnabled(true); browse.setText("Supprimer l'import"); } else { browse.setEnabled(false); } type.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); if (combo.getSelectedIndex() == 1) { browse.setEnabled(true); adress.setEnabled(true); adress.setEditable(true); } else { browse.setEnabled(false); adress.setEnabled(false); adress.setEditable(false); } gs.set("type", combo.getSelectedIndex()); } }); subTypePanel.add(type); JPanel typePanel = new JPanel(); typePanel.setLayout(new BoxLayout(typePanel, BoxLayout.PAGE_AXIS)); typePanel.add(subTypePanel); JPanel browsePanel = new JPanel(); browsePanel.add(browse); JPanel adressPanel = new JPanel(); adressPanel.setLayout(new BoxLayout(adressPanel, BoxLayout.PAGE_AXIS)); JLabel adressLabel = new JLabel("Adresse de tlchargement :"); adressPanel.setPreferredSize(new Dimension(0, 47)); adress.setPreferredSize(new Dimension(0, 30)); adressPanel.add(adressLabel); adressPanel.add(adress); typePanel.add(adressPanel); this.add(typePanel); closeOnStart.setSelected(true); closeOnStart.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (closeOnStart.isSelected()) { gs.set("close", true); } else { gs.set("close", false); } } }); this.add(closeOnStart); JPanel look = new JPanel(); look.setBorder(BorderFactory.createTitledBorder("Apparence")); look.setPreferredSize(new Dimension(290, 340)); JPanel colors = new JPanel(); cDark.setSelected(true); bg.add(cLight); bg.add(cDark); colors.add(cLight); colors.add(cDark); cLight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { gs.set("color", 0); } }); cDark.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { gs.set("color", 1); } }); look.add(colors); JPanel checks = new JPanel(); checks.setLayout(new BoxLayout(checks, BoxLayout.PAGE_AXIS)); borders.setSelected(true); borders.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (borders.isSelected()) { gs.set("borders", true); } else { gs.set("borders", false); } } }); resize.setSelected(true); resize.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (resize.isSelected()) { gs.set("resizable", true); } else { gs.set("resizable", false); } } }); alwaysOnTop.setSelected(false); alwaysOnTop.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (alwaysOnTop.isSelected()) { gs.set("top", true); } else { gs.set("top", false); } } }); checks.add(borders); checks.add(resize); checks.add(alwaysOnTop); checks.setPreferredSize(new Dimension(270, 60)); JPanel size = new JPanel(); width.setPreferredSize(new Dimension(57, 30)); widthMin.setPreferredSize(new Dimension(57, 30)); widthMax.setPreferredSize(new Dimension(57, 30)); height.setPreferredSize(new Dimension(57, 30)); heightMin.setPreferredSize(new Dimension(57, 30)); heightMax.setPreferredSize(new Dimension(57, 30)); JPanel widthPanel = new JPanel(); widthPanel.setPreferredSize(new Dimension(130, 150)); widthPanel.setBorder(BorderFactory.createTitledBorder("Largeur")); widthPanel.setLayout(new BoxLayout(widthPanel, BoxLayout.PAGE_AXIS)); JPanel widthPanelBase = new JPanel(); widthPanelBase.add(new JLabel("Base :")); widthPanelBase.add(width); JPanel widthPanelMin = new JPanel(); widthPanelMin.add(new JLabel("Min :")); widthPanelMin.add(Box.createRigidArea(new Dimension(5, 1))); widthPanelMin.add(widthMin); JPanel widthPanelMax = new JPanel(); widthPanelMax.add(new JLabel("Max :")); widthPanelMax.add(Box.createRigidArea(new Dimension(3, 1))); widthPanelMax.add(widthMax); widthPanel.add(widthPanelBase); widthPanel.add(widthPanelMin); widthPanel.add(widthPanelMax); JPanel heightPanel = new JPanel(); heightPanel.setPreferredSize(new Dimension(130, 150)); heightPanel.setBorder(BorderFactory.createTitledBorder("Hauteur")); heightPanel.setLayout(new BoxLayout(heightPanel, BoxLayout.PAGE_AXIS)); JPanel heightPanelBase = new JPanel(); heightPanelBase.add(new JLabel("Base :")); heightPanelBase.add(height); JPanel heightPanelMin = new JPanel(); heightPanelMin.add(new JLabel("Min :")); heightPanelMin.add(Box.createRigidArea(new Dimension(5, 1))); heightPanelMin.add(heightMin); JPanel heightPanelMax = new JPanel(); heightPanelMax.add(new JLabel("Max :")); heightPanelMax.add(Box.createRigidArea(new Dimension(3, 1))); heightPanelMax.add(heightMax); heightPanel.add(heightPanelBase); heightPanel.add(heightPanelMin); heightPanel.add(heightPanelMax); size.add(widthPanel); size.add(heightPanel); width.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); gs.set("width", spinner.getValue()); } }); widthMin.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); gs.set("widthMin", spinner.getValue()); } }); widthMax.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); ; gs.set("widthMax", spinner.getValue()); } }); height.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); gs.set("height", spinner.getValue()); } }); heightMin.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); gs.set("heightMin", spinner.getValue()); } }); heightMax.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); ; gs.set("heightMax", spinner.getValue()); } }); look.add(checks); look.add(size); JPanel bottom = new JPanel(); bottom.setLayout(new BoxLayout(bottom, BoxLayout.LINE_AXIS)); JButton music = new JButton("Ajouter de la musique"); music.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new MusicFrame((JFrame) SwingUtilities.windowForComponent(adress), gs); } }); bottom.add(music); JButton icons = new JButton("Icnes"); icons.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new IconFrame((JFrame) SwingUtilities.windowForComponent(adress)); } }); bottom.add(icons); look.add(bottom); this.add(look); load(); }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java
private void createPlotInWindow(String name) { MetricsPlot plot = null;/*from w w w .java 2 s. c o m*/ if (name.equals("Available Attributes")) { plot = new MetricsPlot(name, Simulator.getCurrentTime(), INTERVAL, PLOT_WIDTH, PLOT_HEIGHT, VisualizationType.Attribute); } else if (name.equals("Online Peers") || name.equals("Memory Usage")) { plot = new MetricsPlot(name, Simulator.getCurrentTime(), INTERVAL, PLOT_WIDTH, PLOT_HEIGHT, VisualizationType.State); } else { plot = new MetricsPlot(name, Simulator.getCurrentTime(), INTERVAL, PLOT_WIDTH, PLOT_HEIGHT, VisualizationType.Metric); } if (graphix.getComponentCount() == 0) { JPanel temp = new JPanel(); temp.setLayout(new BoxLayout(temp, BoxLayout.LINE_AXIS)); temp.add(plot.getPlotPanel()); graphix.add(temp); } else if (((JPanel) graphix.getComponent(graphix.getComponentCount() - 1)).getComponentCount() % maxPlotsPerRow == 0) { JPanel temp = new JPanel(); temp.setLayout(new BoxLayout(temp, BoxLayout.LINE_AXIS)); temp.add(plot.getPlotPanel()); graphix.add(temp); } else { int c = graphix.getComponentCount(); JPanel temp = (JPanel) graphix.getComponent(c - 1); temp.add(plot.getPlotPanel()); graphix.add(temp); } displayedMetrics.put(name, plot); }
From source file:com.haulmont.cuba.desktop.App.java
protected JComponent createBottomPane() { JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createLineBorder(Color.gray)); panel.setPreferredSize(new Dimension(0, 20)); ServerSelector serverSelector = AppBeans.get(ServerSelector.NAME); String url = serverSelector.getUrl(serverSelector.initContext()); if (url == null) url = "?"; final JLabel connectionStateLab = new JLabel( messages.formatMainMessage("statusBar.connected", getUserFriendlyConnectionUrl(url))); panel.add(connectionStateLab, BorderLayout.WEST); JPanel rightPanel = new JPanel(); BoxLayout rightLayout = new BoxLayout(rightPanel, BoxLayout.LINE_AXIS); rightPanel.setLayout(rightLayout);/*from ww w .j a v a 2s.co m*/ UserSession session = connection.getSession(); JLabel userInfoLabel = new JLabel(); String userInfo = messages.formatMainMessage("statusBar.user", session.getUser().getName(), session.getUser().getLogin()); userInfoLabel.setText(userInfo); rightPanel.add(userInfoLabel); JLabel timeZoneLabel = null; if (session.getTimeZone() != null) { timeZoneLabel = new JLabel(); String timeZone = messages.formatMainMessage("statusBar.timeZone", AppBeans.get(TimeZones.class).getDisplayNameShort(session.getTimeZone())); timeZoneLabel.setText(timeZone); rightPanel.add(Box.createRigidArea(new Dimension(5, 0))); rightPanel.add(timeZoneLabel); } panel.add(rightPanel, BorderLayout.EAST); if (isTestMode()) { panel.setName("bottomPane"); userInfoLabel.setName("userInfoLabel"); if (timeZoneLabel != null) timeZoneLabel.setName("timeZoneLabel"); connectionStateLab.setName("connectionStateLab"); } return panel; }