List of usage examples for java.awt BorderLayout EAST
String EAST
To view the source code for java.awt BorderLayout EAST.
Click Source Link
From source file:com.floreantpos.ui.views.SwitchboardView.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.final DataUpdateInfo *//*from www.j a v a 2 s. com*/ // <editor-fold defaultstate="collapsed" desc=" Generated Code // <editor-fold defaultstate="collapsed" // desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { setLayout(new java.awt.BorderLayout(10, 10)); javax.swing.JPanel centerPanel = new javax.swing.JPanel(new java.awt.BorderLayout(5, 5)); javax.swing.JPanel ticketsAndActivityPanel = new javax.swing.JPanel(new java.awt.BorderLayout(5, 5)); ticketsListPanelBorder = BorderFactory.createTitledBorder(null, POSConstants.OPEN_TICKETS_AND_ACTIVITY, TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION); ticketsAndActivityPanel.setBorder(new CompoundBorder(ticketsListPanelBorder, new EmptyBorder(2, 2, 2, 2))); ticketsAndActivityPanel.add(ticketList, java.awt.BorderLayout.CENTER); JPanel activityPanel = createActivityPanel(); ticketsAndActivityPanel.add(activityPanel, java.awt.BorderLayout.SOUTH); btnAssignDriver.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doAssignDriver(); } }); btnCloseOrder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doCloseOrder(); } }); centerPanel.add(ticketsAndActivityPanel, java.awt.BorderLayout.CENTER); JPanel rightPanel = new JPanel(new BorderLayout(20, 20)); TitledBorder titledBorder2 = BorderFactory.createTitledBorder(null, "-", TitledBorder.CENTER, //$NON-NLS-1$ TitledBorder.DEFAULT_POSITION); rightPanel.setBorder(new CompoundBorder(titledBorder2, new EmptyBorder(2, 2, 6, 2))); orderPanel = new JPanel(new MigLayout("ins 2 2 0 2, fill, hidemode 3, flowy", "fill, grow", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ rendererOrderPanel(); rightPanel.add(orderPanel); rightPanel.setMinimumSize(PosUIManager.getSize(120, 0)); centerPanel.add(rightPanel, java.awt.BorderLayout.EAST); add(centerPanel, java.awt.BorderLayout.CENTER); }
From source file:net.aepik.alasca.gui.ldap.SchemaObjectEditorFrame.java
/** * Build frame.//from ww w .ja v a 2 s .c om */ private void build() { setTitle("Proprits de l'objet " + objetSchema.getId()); setSize(700, 400); setResizable(false); setLocationRelativeTo(mainFrame); if (mainFrame != null) setIconImage(mainFrame.getIconImage()); // - Panel bouton du bas - JPanel boutonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); boutonsPanel.add(boutonOk); boutonsPanel.add(boutonAnnuler); // - Description - JTextArea textAreaValues = new JTextArea("Vous pouvez apporter des modifications sur les paramtres" + " de cet objet d'identifiant " + objetSchema.getId() + ". Les" + " modifications apportes des paramtres non-cochs ne" + " seront pas prises en compte."); textAreaValues.setEditable(false); textAreaValues.setLineWrap(true); textAreaValues.setWrapStyleWord(true); textAreaValues.setFont((new JLabel()).getFont()); textAreaValues.setBorder(BorderFactory.createEmptyBorder(7, 8, 7, 8)); textAreaValues.setBackground((new JLabel()).getBackground()); // - La table des valeurs - // Correction : Tri alphabtique des valeurs Enumeration<String> k = values.keys(); String[] keys = new String[values.size()]; for (int i = 0; i < keys.length; i++) keys[i] = k.nextElement(); Arrays.sort(keys); JPanel colonne1 = new JPanel(new GridLayout(keys.length, 1)); JPanel colonne2 = new JPanel(new GridLayout(keys.length, 1)); // Enumeration<JComponent> l = labels.elements(); // Enumeration<JComponent> v = values.elements(); // Enumeration<String> k = values.keys(); // JPanel colonne1 = new JPanel( new GridLayout( values.size(), 1 ) ); // JPanel colonne2 = new JPanel( new GridLayout( values.size(), 1 ) ); for (int i = 0; keys != null && i < keys.length; i++) { // while( l.hasMoreElements() && v.hasMoreElements() && k.hasMoreElements() ) { String key = keys[i]; JComponent label = labels.get(key); JComponent value = values.get(key); JCheckBox checkbox = valuesPresent.get(key); // String key = k.nextElement(); // JComponent label = l.nextElement(); // JComponent value = v.nextElement(); // JCheckBox checkbox = valuesPresent.get( key ); if (!value.isEnabled() && value instanceof JTextField) { //value.setEnabled( true ); JButton b = new JButton("..."); b.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 5, 0, 0, Color.white), b.getBorder())); b.addActionListener(new SchemaValueEditorLauncher(b, (JTextField) value, objetSchema, key)); JPanel tmp = new JPanel(new BorderLayout()); tmp.add(value, BorderLayout.CENTER); tmp.add(b, BorderLayout.EAST); tmp.setOpaque(false); value = tmp; } JPanel panelTmp1 = new JPanel(new BorderLayout()); panelTmp1.add(checkbox, BorderLayout.WEST); panelTmp1.add(label, BorderLayout.CENTER); panelTmp1.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 3)); colonne1.add(panelTmp1); JPanel panelTmp2 = new JPanel(new BorderLayout()); panelTmp2.add(value, BorderLayout.CENTER); panelTmp2.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3)); colonne2.add(panelTmp2); checkbox.setOpaque(false); label.setOpaque(false); value.setOpaque(false); panelTmp1.setOpaque(false); panelTmp2.setOpaque(false); } JPanel tablePanel = new JPanel(new BorderLayout()); tablePanel.add(colonne1, BorderLayout.WEST); tablePanel.add(colonne2, BorderLayout.EAST); tablePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); colonne1.setOpaque(false); colonne2.setOpaque(false); tablePanel.setOpaque(false); JPanel tablePanelContainer = new JPanel(new BorderLayout()); tablePanelContainer.add(tablePanel, BorderLayout.NORTH); tablePanelContainer.setBackground(Color.white); JList tmpForBorderList = new JList(); JScrollPane tmpForBorderScroller = new JScrollPane(tmpForBorderList); JScrollPane tableScroller = new JScrollPane(tablePanelContainer); //tableScroller.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); tableScroller.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 6, 1, 6), BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(" Listes des paramtres "), BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5), tmpForBorderScroller.getBorder())))); // - Organisation gnrale - JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(textAreaValues, BorderLayout.NORTH); mainPanel.add(tableScroller, BorderLayout.CENTER); JPanel mainPanelContainer = new JPanel(new BorderLayout()); mainPanelContainer.add(mainPanel, BorderLayout.CENTER); mainPanelContainer.add(boutonsPanel, BorderLayout.SOUTH); mainPanelContainer.setBorder(BorderFactory.createEmptyBorder(2, 1, 1, 1)); getContentPane().add(mainPanelContainer); // - Listeners - addWindowListener(this); boutonOk.addActionListener(this); boutonAnnuler.addActionListener(this); }
From source file:com.eviware.soapui.support.SoapUIVersionUpdate.java
protected JPanel buildToolbar(JDialog dialog) { JPanel toolbarPanel = new JPanel(new BorderLayout()); JPanel leftBtns = new JPanel(); leftBtns.add(new JButton((new IgnoreUpdateAction(dialog)))); leftBtns.add(new JButton(new RemindLaterAction(dialog))); JButton createToolbarButton = new JButton( new OpenDownloadUrlAction("Download latest version", getDownloadLinkCore(), dialog)); JPanel rightBtn = new JPanel(); rightBtn.add(createToolbarButton);/*www . j a va 2 s .c o m*/ toolbarPanel.add(leftBtns, BorderLayout.WEST); toolbarPanel.add(rightBtn, BorderLayout.EAST); return toolbarPanel; }
From source file:org.onesun.sdi.swing.app.views.DataServicesView.java
private void createControls() { copyDataButton.addActionListener(new ActionListener() { @Override/*from w ww . j a v a 2 s .co m*/ public void actionPerformed(ActionEvent e) { datasetModel = new DatasetModel(); final Metadata origMetadata = AppCommonsUI.PREVIEW_DATASET_MODEL.getMetadata(); Metadata metadata = new Metadata(); // copy metadata for (String key : origMetadata.keySet()) { metadata.put(key, origMetadata.get(key)); } final List<Map<String, String>> origData = AppCommonsUI.PREVIEW_DATASET_MODEL.getData(); List<Map<String, String>> data = new ArrayList<Map<String, String>>(); // copy data for (Map<String, String> datum : origData) { Map<String, String> record = new TreeMap<String, String>(); for (String key : datum.keySet()) { record.put(key, datum.get(key)); } data.add(record); } datasetModel.setMetadata(metadata); datasetModel.setData(data); dataTable.setModel(datasetModel); rowCountLabel.setText( "Rows: " + datasetModel.getRowCount() + ", Columns: " + datasetModel.getColumnCount()); JTableUtils.packColumns(dataTable, 2); rowCountLabel.invalidate(); dataTable.invalidate(); dataTable.validate(); scrollPane.invalidate(); } }); JPanel panel = new JPanel(new BorderLayout(5, 5)); panel.add(new JLabel("Enrichment Services"), BorderLayout.NORTH); dataServicesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); dataServicesList.setListData(DataServicesFactory.getServiceNames()); dataServicesList.setPreferredSize(new Dimension(400, 300)); JScrollPane listScrollPane = new JScrollPane(dataServicesList); panel.add(listScrollPane, BorderLayout.CENTER); containerPanel.add(panel); panel = new JPanel(new BorderLayout(5, 5)); JPanel labelAndControlPanel = new JPanel(new BorderLayout(5, 5)); labelAndControlPanel.add(new JLabel("Columns to be enriched"), BorderLayout.CENTER); JPanel controlPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5)); JButton selectButton = new JButton(AppIcons.getIcon("select")); controlPanel.add(selectButton); selectButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean columnsAvailable = false; if (datasetModel != null) { Metadata metadata = datasetModel.getMetadata(); if (metadata != null) { columnsAvailable = true; int size = metadata.keySet().size(); String[] values = new String[size]; int index = 0; for (String key : metadata.keySet()) { values[index] = key; index++; } metadataSelectionDialog.setValues(values); } } if (columnsAvailable == true) { metadataSelectionDialog.setVisible(true); } else { JOptionPane.showMessageDialog(rootPanel, AppMessages.ERROR_NO_METADATA); return; } } }); JButton clearButton = new JButton(AppIcons.getIcon("clear")); clearButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectedColumnList.setListData(new String[] {}); selectedColumnList.invalidate(); } }); controlPanel.add(clearButton); labelAndControlPanel.add(controlPanel, BorderLayout.EAST); panel.add(labelAndControlPanel, BorderLayout.NORTH); selectedColumnList.setPreferredSize(new Dimension(400, 300)); listScrollPane = new JScrollPane(selectedColumnList); panel.add(listScrollPane, BorderLayout.CENTER); containerPanel.add(panel); executeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (AppCommons.TASKLET.getConnectionProperties() == null) { JOptionPane.showMessageDialog(rootPanel, AppMessages.INFORMATION_CHOOSE_A_CONNECTION); return; } if (AppCommonsUI.PREVIEW_DATASET_MODEL == null || AppCommonsUI.PREVIEW_DATASET_MODEL.getRowCount() <= 0) { JOptionPane.showMessageDialog(rootPanel, AppMessages.ERROR_NO_DATA_TO_ENTRICH); return; } List<String> selectedServiceNames = dataServicesList.getSelectedValuesList(); if ((selectedServiceNames != null && selectedServiceNames.size() == 0) || (selectedColumnNames.length == 0)) { JOptionPane.showMessageDialog(rootPanel, AppMessages.ERROR_MISSING_DATA_SERVICE_AND_COLUMNS); return; } DefaultCusor.startWaitCursor(rootPanel); List<Map<String, String>> data = datasetModel.getData(); Metadata metadata = datasetModel.getMetadata(); for (String name : selectedServiceNames) { DataService service = DataServicesFactory.getDataService(name); if (service instanceof TextAnalysisService) { TextAnalysisService taService = (TextAnalysisService) service; List<Object> objects = new ArrayList<Object>(); for (Map<String, String> datum : data) { objects.add(datum); } taService.setData(objects); taService.setMetadata(metadata); taService.setColumns(selectedColumnNames); taService.execute(); } } rowCountLabel.setText("Rows: " + data.size() + ", Columns: " + metadata.size()); rowCountLabel.invalidate(); datasetModel = new DatasetModel(); datasetModel.setMetadata(metadata); datasetModel.setData(data); datasetModel.fireTableStructureChanged(); datasetModel.fireTableDataChanged(); dataTable.setModel(datasetModel); JTableUtils.packColumns(dataTable, 2); dataTable.invalidate(); dataTable.validate(); scrollPane.invalidate(); DefaultCusor.stopWaitCursor(rootPanel); } }); computeMetricsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (datasetModel == null || datasetModel.getRowCount() == 0) { JOptionPane.showMessageDialog(rootPanel, AppMessages.ERROR_NO_DATA); return; } List<Map<String, String>> data = datasetModel.getData(); int upsetCount = 0; int happyCount = 0; int negativeCount = 0; int positiveCount = 0; for (Map<String, String> datum : data) { for (String k : datum.keySet()) { if (k.compareTo("uclassify_sentiment") == 0) { String text = datum.get(k); String[] tokens = text.replace("{", "").replace("}", "").split(", "); for (String token : tokens) { String[] nvp = token.split("="); Double score = Double.parseDouble(nvp[1]); if (nvp[0].compareToIgnoreCase("negative") == 0 && score > 50.0) { negativeCount++; } if (nvp[0].compareToIgnoreCase("positive") == 0 && score >= 50.0) { positiveCount++; } } } else if (k.compareTo("uclassify_mood") == 0) { String text = datum.get(k); String[] tokens = text.replace("{", "").replace("}", "").split(", "); for (String token : tokens) { String[] nvp = token.split("="); Double score = Double.parseDouble(nvp[1]); if (nvp[0].compareToIgnoreCase("upset") == 0 && score > 50.0) { upsetCount++; } if (nvp[0].compareToIgnoreCase("happy") == 0 && score >= 50.0) { happyCount++; } } } } } DefaultPieDataset moodDataset = new DefaultPieDataset(); moodDataset.setValue("upset", upsetCount); moodDataset.setValue("happy", happyCount); DefaultPieDataset sentimentDataset = new DefaultPieDataset(); sentimentDataset.setValue("negative", negativeCount); sentimentDataset.setValue("positive", positiveCount); JFreeChart moodChart = ChartFactory.createPieChart("How is mood?", moodDataset, true, true, true); JFreeChart sentimentChart = ChartFactory.createPieChart("How is sentiment?", sentimentDataset, true, true, true); ChartDialog cd = new ChartDialog(AppCommonsUI.MAIN_WINDOW, moodChart, sentimentChart); cd.setSize(new Dimension(900, 500)); cd.setVisible(true); } }); }
From source file:de.tbuchloh.kiskis.gui.dialogs.SecuredElementCreationDlg.java
private JPanel createButtonGroup() { final JPanel main = new JPanel(new GridLayout(TYPES.length, 1, 5, 5)); main.setBorder(BorderFactory.createEmptyBorder(15, 50, 5, 150)); _bg = new ButtonGroup(); _buttons = new JRadioButton[TYPES.length]; final String lastSelected = P.get(K_LAST_CREATED_SECURED_ELEMENT, NetAccount.class.getName()); LOG.debug("Last created class: " + lastSelected); for (int i = 0; i < TYPES.length; ++i) { _buttons[i] = new JRadioButton(TYPES[i]._label); final Class c = TYPES[i]._clazz; if (c.getName().equals(lastSelected)) { _buttons[i].setSelected(true); }//from w w w . j a v a 2 s . c o m _bg.add(_buttons[i]); Component comp = _buttons[i]; if (c == GenericAccount.class) { final JPanel p = new JPanel(new BorderLayout(10, 0)); p.add(comp); p.add(_templates, BorderLayout.EAST); _templates.addItemListener(new RadioItemListener(_buttons[i])); comp.setEnabled(_templates.isEnabled()); comp = p; } main.add(comp); } return main; }
From source file:org.stanwood.nwn2.gui.MainWindow.java
private void createComponents(JPanel panel1) { BorderLayout layout = new BorderLayout(5, 5); panel1.setLayout(layout);//from w w w . jav a 2 s . co m JLabel lblList = new JLabel("Neverwinter Nights 2 GUI XML files:"); panel1.add(lblList, BorderLayout.NORTH); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(5, 5)); guiFileListModel = new DefaultListModel(); guiFileList = new JList(guiFileListModel); guiFileList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateEnabledState(); } }); JScrollPane pane = new JScrollPane(guiFileList); JPanel buttonPanel1 = new JPanel(); buttonPanel1.setLayout(new BorderLayout()); panel.add(buttonPanel1, BorderLayout.EAST); JPanel buttonPanel2 = new JPanel(); buttonPanel1.add(buttonPanel2, BorderLayout.NORTH); buttonPanel2.setLayout(new GridLayout(4, 1, 5, 5)); JButton cmdAdd = new JButton( IconManager.getInstance().getIcon(IconManager.SIZE_22, IconManager.ICON_LIST_ADD)); cmdAdd.setToolTipText("Add a XML GUI file to the list"); cmdAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addNewGUIFile(); } }); buttonPanel2.add(cmdAdd); cmdRemove = new JButton( IconManager.getInstance().getIcon(IconManager.SIZE_22, IconManager.ICON_LIST_REMOVE)); cmdRemove.setToolTipText("Remove the selected XML GUI file from the list"); cmdRemove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { guiFileListModel.remove(guiFileList.getSelectedIndex()); updateEnabledState(); saveChanges(); } }); buttonPanel2.add(cmdRemove); cmdDisplay = new JButton( IconManager.getInstance().getIcon(IconManager.SIZE_22, IconManager.ICON_LIST_VIEW)); cmdDisplay.setToolTipText("Render the selected XML GUI file"); cmdDisplay.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { displayGUIFile(); } }); buttonPanel2.add(cmdDisplay); cmdEdit = new JButton( IconManager.getInstance().getIcon(IconManager.SIZE_22, IconManager.ICON_ACCESSORIES_TEXT_EDITOR)); cmdEdit.setToolTipText("Open the selected XML GUI file in a editor"); cmdEdit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { File guiFile = getSelectedFile(); try { Desktop.getDesktop().edit(guiFile); } catch (IOException e1) { JOptionPane.showMessageDialog(MainWindow.this, e1.getMessage(), "NWN2GUI Error", JOptionPane.ERROR_MESSAGE); log.error(e1.getMessage(), e1); } catch (UnsupportedOperationException e1) { //TODO add support for other platforms JOptionPane.showMessageDialog(MainWindow.this, "Unable to find the systems default editor", "NWN2GUI Error", JOptionPane.ERROR_MESSAGE); } } }); buttonPanel2.add(cmdEdit); panel.add(pane, BorderLayout.CENTER); panel1.add(panel, BorderLayout.CENTER); }
From source file:pl.kotcrab.arget.gui.MainWindow.java
private void createAndShowGUI() { setTitle(App.APP_NAME);// w w w .j av a 2s . co m setBounds(100, 100, 800, 700); setMinimumSize(new Dimension(500, 250)); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setIconImage(App.loadImage("/data/icon/icon.png")); sessionWindowManager = new SessionWindowManager(this); if (profile.mainWindowBounds != null && GraphicsUtils.isRectangleDisplayableOnScreen(profile.mainWindowBounds)) setBounds(profile.mainWindowBounds); createMenuBars(); contactsPanel = new ContactsPanel(profile, this); statusPane = new JTextPane(); statusPane.setBorder(new EmptyBorder(1, 3, 2, 0)); statusPane.setContentType("text/html"); statusPane.setBackground(null); statusPane.setHighlighter(null); statusPane.setEditable(false); statusPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true); statusPane.setFont(new Font("Tahoma", Font.PLAIN, 13)); statusPane.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { String desc = e.getDescription(); if (desc.startsWith("version-mismatch")) { desc = desc.substring(desc.indexOf("://") + 3); String[] versionInfo = desc.split("!"); new VersionMismatchDialog(MainWindow.instance, versionInfo[0], Integer.valueOf(versionInfo[1])); } } } }); JPanel bottomPanel = new JPanel(new BorderLayout(0, 0)); getContentPane().add(bottomPanel, BorderLayout.SOUTH); scrollLockToggle = new WebToggleButton(); scrollLockToggle.setToolTipText("Scroll lock"); scrollLockToggle.setRolloverDecoratedOnly(true); scrollLockToggle.setDrawFocus(false); scrollLockToggle.setIcon(App.loadImageIcon("/data/scrolllock.png")); scrollLockToggle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { postScrollLockUpdate(); } }); bottomPanel.add(statusPane); bottomPanel.add(scrollLockToggle, BorderLayout.EAST); splitPane = new JSplitPane(); splitPane.setBorder(new BottomSplitPaneBorder()); splitPane.setResizeWeight(0); splitPane.setContinuousLayout(true); splitPane.setOneTouchExpandable(true); getContentPane().add(splitPane, BorderLayout.CENTER); homePanel = new HomePanel(profile.fileName); logPanel = new LoggerPanel(); errorStatusPanel = new ErrorStatusPanel(); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.add(contactsPanel, BorderLayout.CENTER); leftPanel.add(errorStatusPanel, BorderLayout.SOUTH); splitPane.setLeftComponent(leftPanel); splitPane.setRightComponent(null); setCenterScreenTo(homePanel); addWindowFocusListener(new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { instance.validate(); instance.revalidate(); instance.repaint(); getCenterScreen().onShow(); } @Override public void windowLostFocus(WindowEvent e) { getCenterScreen().onHide(); } }); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { ExitCleaner.forceExit(); } }); setVisible(true); }
From source file:JavaXWin.java
public WindowWatcher(JDesktopPane desktop) { m_desktop = desktop;/*www . j av a 2 s.c om*/ setOpaque(true); m_northResizer = new NorthResizeEdge(this); m_southResizer = new SouthResizeEdge(this); m_eastResizer = new EastResizeEdge(this); m_westResizer = new WestResizeEdge(this); setLayout(new BorderLayout()); add(m_northResizer, BorderLayout.NORTH); add(m_southResizer, BorderLayout.SOUTH); add(m_eastResizer, BorderLayout.EAST); add(m_westResizer, BorderLayout.WEST); MouseInputAdapter ma = new MouseInputAdapter() { public void mousePressed(MouseEvent e) { m_XDifference = e.getX(); m_YDifference = e.getY(); } public void mouseDragged(MouseEvent e) { int vx = 0; int vy = 0; if (m_desktop.getParent() instanceof JViewport) { vx = ((JViewport) m_desktop.getParent()).getViewPosition().x; vy = ((JViewport) m_desktop.getParent()).getViewPosition().y; } int w = m_desktop.getParent().getWidth(); int h = m_desktop.getParent().getHeight(); int x = getX(); int y = getY(); int ex = e.getX(); int ey = e.getY(); if ((ey + y > vy && ey + y < h + vy) && (ex + x > vx && ex + x < w + vx)) { setLocation(ex - m_XDifference + x, ey - m_YDifference + y); } else if (!(ey + y > vy && ey + y < h + vy) && (ex + x > vx && ex + x < w + vx)) { if (!(ey + y > vy) && ey + y < h + vy) setLocation(ex - m_XDifference + x, vy - m_YDifference); else if (ey + y > vy && !(ey + y < h + vy)) setLocation(ex - m_XDifference + x, (h + vy) - m_YDifference); } else if ((ey + y > vy && ey + y < h + vy) && !(ex + x > vx && ex + x < w + vx)) { if (!(ex + x > vx) && ex + x < w + vx) setLocation(vx - m_XDifference, ey - m_YDifference + y); else if (ex + x > vx && !(ex + x < w)) setLocation((w + vx) - m_XDifference, ey - m_YDifference + y); } else if (!(ey + y > vy) && ey + y < h + vy && !(ex + x > vx) && ex + x < w + vx) setLocation(vx - m_XDifference, vy - m_YDifference); else if (!(ey + y > vy) && ey + y < h + vy && ex + x > vx && !(ex + x < w + vx)) setLocation((w + vx) - m_XDifference, vy - m_YDifference); else if (ey + y > vy && !(ey + y < h + vy) && !(ex + x > vx) && ex + x < w + vx) setLocation(vx - m_XDifference, (h + vy) - m_YDifference); else if (ey + y > vy && !(ey + y < h + vy) && ex + x > vx && !(ex + x < w + vx)) setLocation((w + vx) - m_XDifference, (h + vy) - m_YDifference); } public void mouseEntered(MouseEvent e) { setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); } public void mouseExited(MouseEvent e) { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }; addMouseListener(ma); addMouseMotionListener(ma); }
From source file:savant.util.swing.TrackChooser.java
private void initLayout() { this.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); //FILLER/*from w w w . ja va2 s. c om*/ //LEFT LABEL JLabel leftLabel = new JLabel("All Tracks"); leftLabel.setFont(new Font(null, Font.BOLD, 12)); c.gridx = 0; c.gridy = 0; c.insets = new Insets(5, 5, 5, 5); add(leftLabel, c); // RIGHT LABEL JLabel rightLabel = new JLabel("Selected Tracks"); rightLabel.setFont(new Font(null, Font.BOLD, 12)); c.gridx = 2; c.gridwidth = GridBagConstraints.REMAINDER; add(rightLabel, c); //LEFT LIST leftList = new JList(); JScrollPane leftScroll = new JScrollPane(); leftScroll.setViewportView(leftList); leftScroll.setMinimumSize(new Dimension(450, 300)); leftScroll.setPreferredSize(new Dimension(450, 300)); c.weightx = 1.0; c.weighty = 1.0; c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.gridheight = 4; add(leftScroll, c); //RIGHT LIST rightList = new JList(); JScrollPane rightScroll = new JScrollPane(); rightScroll.setViewportView(rightList); rightScroll.setMinimumSize(new Dimension(450, 300)); rightScroll.setPreferredSize(new Dimension(450, 300)); c.gridx = 2; c.gridwidth = GridBagConstraints.REMAINDER; this.add(rightScroll, c); // MOVE RIGHT c.weightx = 0.0; c.weighty = 0.5; c.gridx = 1; c.gridy = 1; c.gridwidth = 1; c.gridheight = 1; add(createMoveRight(), c); // MOVE LEFT c.gridy = 2; add(createMoveLeft(), c); // ALL RIGHT c.gridy = 3; add(createAllRight(), c); //ALL LEFT c.gridy = 4; this.add(createAllLeft(), c); //FILTER c.gridx = 0; c.gridy = 5; add(createFilterPanel(), c); //AUTO SELECT ALL c.gridx = 2; add(createSelectAllCheck(), c); //SEPARATOR JSeparator separator1 = new JSeparator(SwingConstants.HORIZONTAL); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = GridBagConstraints.RELATIVE; c.weightx = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; add(separator1, c); if (selectBase) { //SELECT BASE PANEL JPanel selectBasePanel = new JPanel(new BorderLayout()); c.gridwidth = 2; add(selectBasePanel, c); //SELECT BASE LABEL JLabel selectBaseLabel = new JLabel("(Optional) Select Base: "); selectBasePanel.add(selectBaseLabel, BorderLayout.WEST); //SELECT BASE FIELD selectBaseField = new JTextField(); selectBasePanel.add(selectBaseField, BorderLayout.CENTER); //SELECT BASE EXAMPLE JLabel selectBaseExample = new JLabel(" ex. 123,456,789"); selectBasePanel.add(selectBaseExample, BorderLayout.EAST); //SEPARATOR JSeparator separator2 = new JSeparator(SwingConstants.HORIZONTAL); c.gridwidth = GridBagConstraints.REMAINDER; add(separator2, c); } JPanel okCancelPanel = new JPanel(new BorderLayout()); c.anchor = GridBagConstraints.EAST; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; c.fill = GridBagConstraints.NONE; add(okCancelPanel, c); //OK okCancelPanel.add(createOKButton(), BorderLayout.CENTER); //CANCEL okCancelPanel.add(createCancelButton(), BorderLayout.EAST); pack(); }
From source file:org.rdv.ui.ExportDialog.java
private void initComponents(List<String> channels, List<String> fileFormats) { channelModel = new DefaultListModel(); for (int i = 0; i < channels.size(); i++) { String channelName = (String) channels.get(i); Channel channel = RBNBController.getInstance().getChannel(channelName); String mime = channel.getMetadata("mime"); if (mime.equals("application/octet-stream")) { channelModel.addElement(new ExportChannel(channelName)); }//from www. j a v a 2 s . co m } JPanel container = new JPanel(); setContentPane(container); InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = container.getActionMap(); container.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weighty = 0; c.gridwidth = 1; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; JLabel headerLabel = new JLabel("Select the time range and data channels to export."); headerLabel.setBackground(Color.white); headerLabel.setOpaque(true); headerLabel.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray), BorderFactory.createEmptyBorder(10, 10, 10, 10))); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 0, 0, 0); container.add(headerLabel, c); JPanel timeButtonPanel = new JPanel(); timeButtonPanel.setLayout(new BorderLayout()); MouseListener hoverMouseListener = new MouseAdapter() { public void mouseEntered(MouseEvent e) { e.getComponent().setForeground(Color.red); } public void mouseExited(MouseEvent e) { e.getComponent().setForeground(Color.blue); } }; startTimeButton = new JButton(); startTimeButton.setBorder(null); startTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); startTimeButton.setForeground(Color.blue); startTimeButton.addMouseListener(hoverMouseListener); startTimeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { double startTime = DateTimeDialog.showDialog(ExportDialog.this, timeSlider.getStart(), timeSlider.getMinimum(), timeSlider.getEnd()); if (startTime >= 0) { timeSlider.setStart(startTime); } } }); timeButtonPanel.add(startTimeButton, BorderLayout.WEST); durationLabel = new JLabel(); durationLabel.setHorizontalAlignment(JLabel.CENTER); timeButtonPanel.add(durationLabel, BorderLayout.CENTER); endTimeButton = new JButton(); endTimeButton.setBorder(null); endTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); endTimeButton.setForeground(Color.blue); endTimeButton.addMouseListener(hoverMouseListener); endTimeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { double endTime = DateTimeDialog.showDialog(ExportDialog.this, timeSlider.getEnd(), timeSlider.getStart(), timeSlider.getMaximum()); if (endTime >= 0) { timeSlider.setEnd(endTime); } } }); timeButtonPanel.add(endTimeButton, BorderLayout.EAST); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(10, 10, 10, 10); container.add(timeButtonPanel, c); timeSlider = new TimeSlider(); timeSlider.setValueChangeable(false); timeSlider.setValueVisible(false); timeSlider.addTimeAdjustmentListener(new TimeAdjustmentListener() { public void timeChanged(TimeEvent event) { } public void rangeChanged(TimeEvent event) { updateTimeRangeLabel(); } public void boundsChanged(TimeEvent event) { } }); updateTimeRangeLabel(); updateTimeBounds(); List<EventMarker> markers = RBNBController.getInstance().getMarkerManager().getMarkers(); for (EventMarker marker : markers) { timeSlider.addMarker(marker); } c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(timeSlider, c); JLabel numericHeaderLabel = new JLabel("Data Channels:"); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 3; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(numericHeaderLabel, c); numericChannelList = new JList(channelModel); numericChannelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); numericChannelList.setCellRenderer(new CheckListRenderer()); numericChannelList.setVisibleRowCount(10); numericChannelList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { int index = numericChannelList.locationToIndex(e.getPoint()); ExportChannel item = (ExportChannel) numericChannelList.getModel().getElementAt(index); item.setSelected(!item.isSelected()); Rectangle rect = numericChannelList.getCellBounds(index, index); numericChannelList.repaint(rect); checkSelectedChannels(); updateTimeBounds(); } }); JScrollPane scrollPane = new JScrollPane(numericChannelList); c.fill = GridBagConstraints.BOTH; c.weightx = 0; c.weighty = 1; c.gridx = 0; c.gridy = 4; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(scrollPane, c); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.weighty = 0; c.gridx = 0; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 10, 10, 5); container.add(new JLabel("Data file: "), c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 1; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; dataFileTextField = new JTextField(20); c.insets = new java.awt.Insets(0, 0, 10, 5); container.add(dataFileTextField, c); dataFileTextField .setText(UIUtilities.getCurrentDirectory().getAbsolutePath() + File.separator + "data.dat"); dataFileButton = new JButton("Browse"); dataFileButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { File selectedFile = new File(dataFileTextField.getText()); selectedFile = UIUtilities.getFile("OK", "Select export file", selectedFile); if (selectedFile != null) { dataFileTextField.setText(selectedFile.getAbsolutePath()); } } }); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.gridx = 2; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 0, 10, 10); container.add(dataFileButton, c); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.gridx = 0; c.gridy = 6; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 10, 10, 5); container.add(new JLabel("File format: "), c); fileFormatComboBox = new JComboBox(fileFormats.toArray()); fileFormatComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { fileFormatUpdated(); } }); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 1; c.gridy = 6; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 0, 10, 10); container.add(fileFormatComboBox, c); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); Action exportAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = -5356258138620428023L; public void actionPerformed(ActionEvent e) { ok(); } }; exportAction.putValue(Action.NAME, "Export"); inputMap.put(KeyStroke.getKeyStroke("ENTER"), "export"); actionMap.put("export", exportAction); exportButton = new JButton(exportAction); panel.add(exportButton); Action cancelAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = -5868609501314154642L; public void actionPerformed(ActionEvent e) { cancel(); } }; cancelAction.putValue(Action.NAME, "Cancel"); inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel"); actionMap.put("cancel", cancelAction); cancelButton = new JButton(cancelAction); panel.add(cancelButton); c.fill = GridBagConstraints.NONE; c.weightx = 0.5; c.gridx = 0; c.gridy = 7; c.gridwidth = GridBagConstraints.REMAINDER; ; c.anchor = GridBagConstraints.LINE_END; c.insets = new java.awt.Insets(0, 0, 10, 5); container.add(panel, c); pack(); if (getWidth() < 600) { setSize(600, getHeight()); } dataFileTextField.requestFocusInWindow(); setLocationByPlatform(true); }