public GalaxyViewer(Settings settings, boolean animatorFrame) throws Exception { super("Stars GalaxyViewer"); this.settings = settings; this.animatorFrame = animatorFrame; if (settings.gameName.equals("")) throw new Exception("GameName not defined in settings."); setDefaultCloseOperation(EXIT_ON_CLOSE); File dir = new File(settings.directory); File map = new File(dir, settings.getGameName() + ".MAP"); if (map.exists() == false) { File f = new File(dir.getParentFile(), settings.getGameName() + ".MAP"); if (f.exists()) map = f; else { String error = "Could not find " + map.getAbsolutePath() + "\n"; error += "Export this file from Stars! (Only needs to be done one time pr game)"; throw new Exception(error); } } Vector<File> mFiles = new Vector<File>(); Vector<File> hFiles = new Vector<File>(); for (File f : dir.listFiles()) { if (f.getName().toUpperCase().endsWith("MAP")) continue; if (f.getName().toUpperCase().endsWith("HST")) continue; if (f.getName().toUpperCase().startsWith(settings.getGameName() + ".M")) mFiles.addElement(f); else if (f.getName().toUpperCase().startsWith(settings.getGameName() + ".H")) hFiles.addElement(f); } if (mFiles.size() == 0) throw new Exception("No M-files found matching game name."); if (hFiles.size() == 0) throw new Exception("No H-files found matching game name."); parseMapFile(map); Vector<File> files = new Vector<File>(); files.addAll(mFiles); files.addAll(hFiles); p = new Parser(files); calculateColors(); // UI: JPanel cp = (JPanel) getContentPane(); cp.setLayout(new BorderLayout()); cp.add(universe, BorderLayout.CENTER); JPanel south = createPanel(0, hw, new JLabel("Search: "), search, names, zoom, colorize); search.setPreferredSize(new Dimension(100, -1)); cp.add(south, BorderLayout.SOUTH); hw.addActionListener(this); names.addActionListener(this); zoom.addChangeListener(this); search.addKeyListener(this); colorize.addActionListener(this); setSize(800, 600); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); setLocation((screen.width - getWidth()) / 2, (screen.height - getHeight()) / 2); setVisible(animatorFrame == false); if (animatorFrame) names.setSelected(false); }
/** Show the filter dialog */ public void showDialog() { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); include_panel = new ServiceFilterPanel("Include messages based on target service:", filter_include_list); exclude_panel = new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list); status_box = new JCheckBox("Filter messages based on status:"); status_box.addActionListener(this); status_active = new JRadioButton("Active messages only"); status_active.setSelected(true); status_active.setEnabled(false); status_complete = new JRadioButton("Complete messages only"); status_complete.setEnabled(false); status_group = new ButtonGroup(); status_group.add(status_active); status_group.add(status_complete); if (filter_active || filter_complete) { status_box.setSelected(true); status_active.setEnabled(true); status_complete.setEnabled(true); if (filter_complete) { status_complete.setSelected(true); } } status_options = new JPanel(); status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS)); status_options.add(status_active); status_options.add(status_complete); status_options.setBorder(indent_border); status_panel = new JPanel(); status_panel.setLayout(new BorderLayout()); status_panel.add(status_box, BorderLayout.NORTH); status_panel.add(status_options, BorderLayout.CENTER); status_panel.setBorder(empty_border); ok_button = new JButton("Ok"); ok_button.addActionListener(this); cancel_button = new JButton("Cancel"); cancel_button.addActionListener(this); buttons = new JPanel(); buttons.setLayout(new FlowLayout()); buttons.add(ok_button); buttons.add(cancel_button); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(include_panel); panel.add(exclude_panel); panel.add(status_panel); panel.add(buttons); dialog = new JDialog(); dialog.setTitle("SOAP Monitor Filter"); dialog.setContentPane(panel); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setModal(true); dialog.pack(); Dimension d = dialog.getToolkit().getScreenSize(); dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2); ok_pressed = false; dialog.show(); }
/** Constructor */ public ServiceFilterPanel(String text, Vector list) { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); service_box = new JCheckBox(text); service_box.addActionListener(this); service_data = new Vector(); if (list != null) { service_box.setSelected(true); service_data = (Vector) list.clone(); } service_list = new JList(service_data); service_list.setBorder(new EtchedBorder()); service_list.setVisibleRowCount(5); service_list.addListSelectionListener(this); service_list.setEnabled(service_box.isSelected()); service_scroll = new JScrollPane(service_list); service_scroll.setBorder(new EtchedBorder()); remove_service_button = new JButton("Remove"); remove_service_button.addActionListener(this); remove_service_button.setEnabled(false); remove_service_panel = new JPanel(); remove_service_panel.setLayout(new FlowLayout()); remove_service_panel.add(remove_service_button); service_area = new JPanel(); service_area.setLayout(new BorderLayout()); service_area.add(service_scroll, BorderLayout.CENTER); service_area.add(remove_service_panel, BorderLayout.EAST); service_area.setBorder(indent_border); add_service_field = new JTextField(); add_service_field.addActionListener(this); add_service_field.getDocument().addDocumentListener(this); add_service_field.setEnabled(service_box.isSelected()); add_service_button = new JButton("Add"); add_service_button.addActionListener(this); add_service_button.setEnabled(false); add_service_panel = new JPanel(); add_service_panel.setLayout(new BorderLayout()); JPanel dummy = new JPanel(); dummy.setBorder(empty_border); add_service_panel.add(dummy, BorderLayout.WEST); add_service_panel.add(add_service_button, BorderLayout.EAST); add_service_area = new JPanel(); add_service_area.setLayout(new BorderLayout()); add_service_area.add(add_service_field, BorderLayout.CENTER); add_service_area.add(add_service_panel, BorderLayout.EAST); add_service_area.setBorder(indent_border); setLayout(new BorderLayout()); add(service_box, BorderLayout.NORTH); add(service_area, BorderLayout.CENTER); add(add_service_area, BorderLayout.SOUTH); setBorder(empty_border); }
public GLDemo() { super(VNMRFrame.getVNMRFrame(), "Jogl Demo", false); DisplayOptions.addChangeListener(this); contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); gradientPanel = createGradientPanel(); contentPane.add(gradientPanel, BorderLayout.CENTER); checkBox = new JCheckBox("Transparent", true); checkBox.setActionCommand("transparancy"); checkBox.addActionListener(this); optionsPan = new JPanel(); optionsPan.setLayout(new SimpleH2Layout(SimpleH2Layout.LEFT, 5, 0, true, false)); optionsPan.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); optionsPan.add(checkBox); runButton = new JToggleButton("Run"); runButton.setActionCommand("run"); runButton.setSelected(false); runButton.addActionListener(this); optionsPan.add(runButton); getContentPane().add(optionsPan, BorderLayout.SOUTH); setSize(300, 300); setLocation(300, 300); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { // Run this on another thread than the AWT event queue to // make sure the call to Animator.stop() completes before // exiting new Thread( new Runnable() { public void run() { stop(); } }) .start(); } }); setVisible(false); }
public TableModelDemo() { try { // Load the JDBC driver Class.forName("com.mysql.jdbc.Driver"); Class.forName("oracle.jdbc.driver.OracleDriver"); System.out.println("Driver loaded"); // Create a row set rowSet = new CachedRowSetImpl(); // Set RowSet properties // rowSet.setUrl("jdbc:mysql://localhost/javabook"); rowSet.setUrl("jdbc:oracle:thin:@liang.armstrong.edu:1521:orcl"); rowSet.setUsername("scott"); rowSet.setPassword("tiger"); rowSet.setCommand("select * from StateCapital"); rowSet.setConcurrency(ResultSet.CONCUR_UPDATABLE); rowSet.execute(); tableModel.setRowSet(rowSet); rowSet.addRowSetListener(tableModel); } catch (Exception ex) { ex.printStackTrace(); } JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayout(2, 2)); panel1.add(jbtAddRow); panel1.add(jbtAddColumn); panel1.add(jbtDeleteRow); panel1.add(jbtDeleteColumn); JPanel panel2 = new JPanel(); panel2.add(jbtSave); panel2.add(jbtClear); panel2.add(jbtRestore); JPanel panel3 = new JPanel(); panel3.setLayout(new BorderLayout(5, 0)); panel3.add(new JLabel("Selection Mode"), BorderLayout.WEST); panel3.add(jcboSelectionMode, BorderLayout.CENTER); JPanel panel4 = new JPanel(); panel4.setLayout(new FlowLayout(FlowLayout.LEFT)); panel4.add(jchkRowSelectionAllowed); panel4.add(jchkColumnSelectionAllowed); JPanel panel5 = new JPanel(); panel5.setLayout(new GridLayout(2, 1)); panel5.add(panel3); panel5.add(panel4); JPanel panel6 = new JPanel(); panel6.setLayout(new BorderLayout()); panel6.add(panel1, BorderLayout.SOUTH); panel6.add(panel2, BorderLayout.CENTER); add(panel5, BorderLayout.NORTH); add(new JScrollPane(jTable1), BorderLayout.CENTER); add(panel6, BorderLayout.SOUTH); // Initialize table selection mode jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jbtAddRow.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { rowSet.absolute(2); rowSet.moveToInsertRow(); rowSet.updateString("state", "Georia"); rowSet.updateString("capital", "Atlanta"); rowSet.insertRow(); ((CachedRowSetImpl) rowSet).acceptChanges(); rowSet.moveToCurrentRow(); } catch (Exception ex) { ex.printStackTrace(); } // if (jTable1.getSelectedRow() >= 0) // tableModel.insertRow(jTable1.getSelectedRow(), // new java.util.Vector()); // else // tableModel.addRow(new java.util.Vector()); } }); jbtAddColumn.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // String name = JOptionPane.showInputDialog("New Column Name"); // tableModel.addColumn(name, new java.util.Vector()); } }); jbtDeleteRow.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (jTable1.getSelectedRow() >= 0) { try { rowSet.absolute(jTable1.getSelectedRow() + 1); rowSet.deleteRow(); ((CachedRowSetImpl) rowSet).acceptChanges(); } catch (Exception ex) { ex.printStackTrace(); } } } }); jbtDeleteColumn.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (jTable1.getSelectedColumn() >= 0) { TableColumnModel columnModel = jTable1.getColumnModel(); TableColumn tableColumn = columnModel.getColumn(jTable1.getSelectedColumn()); columnModel.removeColumn(tableColumn); } } }); jbtSave.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("tablemodel.dat")); // out.writeObject(tableModel.getDataVector()); out.writeObject(getColumnNames()); out.close(); } catch (Exception ex) { ex.printStackTrace(); } } }); jbtClear.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // tableModel.setRowCount(0); } }); jbtRestore.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { ObjectInputStream in = new ObjectInputStream(new FileInputStream("tablemodel.dat")); Vector rowData = (Vector) in.readObject(); Vector columnNames = (Vector) in.readObject(); // tableModel.setDataVector(rowData, columnNames); in.close(); } catch (Exception ex) { ex.printStackTrace(); } } }); jchkRowSelectionAllowed.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { jTable1.setRowSelectionAllowed(jchkRowSelectionAllowed.isSelected()); } }); jchkColumnSelectionAllowed.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { jTable1.setColumnSelectionAllowed(jchkColumnSelectionAllowed.isSelected()); } }); jcboSelectionMode.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String selectedItem = (String) jcboSelectionMode.getSelectedItem(); if (selectedItem.equals("SINGLE_SELECTION")) jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); else if (selectedItem.equals("SINGLE_INTERVAL_SELECTION")) jTable1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); else if (selectedItem.equals("MULTIPLE_INTERVAL_SELECTION")) jTable1.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } }); }
public Viewer() { leveldbStore.setMultiSelectionEnabled(false); leveldbStore.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); putButton.setEnabled(false); key.setEnabled(false); value.setEnabled(false); findField.setEnabled(false); deleteButton.setEnabled(false); saveButton.setEnabled(false); putType.setEnabled(false); putType.setEditable(false); signedBox.setEnabled(false); openButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (openButton.isEnabled()) { openButton.setEnabled(false); new Thread() { public void run() { if (leveldbStore.showOpenDialog(pane) == JFileChooser.APPROVE_OPTION) { File select = leveldbStore.getSelectedFile(); if (select.isDirectory()) { new OpenLevelDBDialog(Viewer.this, select); openDatabase(select); dbPathField.setText(select.getAbsolutePath()); } else { JOptionPane.showMessageDialog( pane, "The selecting item must be a directory", "Unable to load database", JOptionPane.WARNING_MESSAGE); } } else { openButton.setEnabled(true); } } }.start(); } } }); deleteButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dataList.getSelectedValue() != null) { delete(dataList.getSelectedValue().key); } openDatabase(leveldbStore.getSelectedFile()); } }); putButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { put( ((PutType) putType.getSelectedItem()).getBytes(key.getText()), ((PutType) putType.getSelectedItem()).getBytes(value.getText())); openDatabase(leveldbStore.getSelectedFile()); } }); findField.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); findField .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { openDatabase(leveldbStore.getSelectedFile()); } @Override public void removeUpdate(DocumentEvent e) { openDatabase(leveldbStore.getSelectedFile()); } @Override public void changedUpdate(DocumentEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); findField .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); hexKey .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { update(hexKey); } @Override public void removeUpdate(DocumentEvent e) { update(hexKey); } @Override public void changedUpdate(DocumentEvent e) { update(hexKey); } }); hexKey .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { update(hexKey); } }); stringKey .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { update(stringKey); } @Override public void removeUpdate(DocumentEvent e) { update(stringKey); } @Override public void changedUpdate(DocumentEvent e) { update(stringKey); } }); stringKey .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { update(stringKey); } }); hexValue .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { update(hexValue); } @Override public void removeUpdate(DocumentEvent e) { update(hexValue); } @Override public void changedUpdate(DocumentEvent e) { update(hexValue); } }); hexValue .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { update(hexValue); } }); stringValue .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { update(stringValue); } @Override public void removeUpdate(DocumentEvent e) { update(stringValue); } @Override public void changedUpdate(DocumentEvent e) { update(stringValue); } }); stringValue .getDocument() .addUndoableEditListener( new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { update(stringValue); } }); saveButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); openDatabase(leveldbStore.getSelectedFile()); } }); dataList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dataList.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { DBItem item = dataList.getSelectedValue(); if (item != null) { hexValue.setText(cutToLine(LevelDBViewer.toHexString(item.value), 64)); stringValue.setText(cutToLine(new String(item.value), 64)); hexKey.setText(cutToLine(LevelDBViewer.toHexString(item.key), 64)); stringKey.setText(cutToLine(new String(item.key), 64)); lengthLabel.setText(String.valueOf(item.value.length + item.key.length)); keyLength.setText(String.valueOf(item.key.length)); valueLength.setText(String.valueOf(item.value.length)); } } }); signedBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { LevelDBViewer.DEFAULT_SINGED = signedBox.isSelected(); int i = dataList.getSelectedIndex(); dataList.clearSelection(); dataList.updateUI(); dataList.setSelectedIndex(i); update(hexKey); update(hexValue); } }); for (PutType t : PutType.values()) { putType.addItem(t); } putType.setSelectedItem(PutType.STRING); putType.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); putType.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openDatabase(leveldbStore.getSelectedFile()); } }); dialog.setLocationByPlatform(true); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setContentPane(pane); dialog.setTitle("LevelDB Viewer By Marcus (https://github.com/SuperMarcus)"); dialog.getRootPane().setDefaultButton(openButton); dialog.pack(); dialog.setVisible(true); }
/** Draw the contents of the dialog. */ private void drawDialog() { JPanel oCenterPanel = new JPanel(); GridBagLayout gb = new GridBagLayout(); GridBagConstraints gc = new GridBagConstraints(); gc.anchor = GridBagConstraints.WEST; oCenterPanel.setLayout(gb); gc.insets = new Insets(5, 5, 5, 5); int y = 0; cbIncludeKeywords = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importKeywordData")); //$NON-NLS-1$ cbIncludeKeywords.setSelected(true); cbIncludeKeywords.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeKeywords, gc); oCenterPanel.add(cbIncludeKeywords); cbIncludePlayList = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importPlayListData")); //$NON-NLS-1$ cbIncludePlayList.setSelected(true); cbIncludePlayList.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludePlayList, gc); oCenterPanel.add(cbIncludePlayList); cbIncludeURLs = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importURLData")); //$NON-NLS-1$ cbIncludeURLs.setSelected(true); cbIncludeURLs.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeURLs, gc); oCenterPanel.add(cbIncludeURLs); cbIncludeAttendees = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importAttendeeData")); //$NON-NLS-1$ cbIncludeAttendees.setSelected(true); cbIncludeAttendees.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeAttendees, gc); oCenterPanel.add(cbIncludeAttendees); cbIncludeChats = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.imortChatData")); //$NON-NLS-1$ cbIncludeChats.setSelected(true); cbIncludeChats.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeChats, gc); oCenterPanel.add(cbIncludeChats); cbIncludeWhiteboard = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importWhiteBoardData")); //$NON-NLS-1$ cbIncludeWhiteboard.setSelected(true); cbIncludeWhiteboard.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeWhiteboard, gc); oCenterPanel.add(cbIncludeWhiteboard); cbIncludeAnnotations = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importAnnotationData")); //$NON-NLS-1$ cbIncludeAnnotations.setSelected(true); cbIncludeAnnotations.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeAnnotations, gc); oCenterPanel.add(cbIncludeAnnotations); cbIncludeFileData = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importFileData")); //$NON-NLS-1$ cbIncludeFileData.setSelected(true); cbIncludeFileData.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeFileData, gc); oCenterPanel.add(cbIncludeFileData); cbIncludeVotes = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importVotingData")); //$NON-NLS-1$ cbIncludeVotes.setSelected(true); cbIncludeVotes.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbIncludeVotes, gc); oCenterPanel.add(cbIncludeVotes); // Add spacer label JLabel spacer = new JLabel(" "); // $NON-NLS-1$ gc.gridy = y; y++; gb.setConstraints(spacer, gc); oCenterPanel.add(spacer); // flag to mark seen/unseen on import cbMarkSeen = new JCheckBox( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.markSeen")); //$NON-NLS-1$ cbMarkSeen.setSelected(true); cbMarkSeen.addActionListener(this); gc.gridy = y; y++; gb.setConstraints(cbMarkSeen, gc); oCenterPanel.add(cbMarkSeen); // Add spacer label spacer = new JLabel(" "); // $NON-NLS-1$ gc.gridy = y; y++; gb.setConstraints(spacer, gc); oCenterPanel.add(spacer); gc.gridwidth = 1; UIButtonPanel oButtonPanel = new UIButtonPanel(); pbImport = new UIButton( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importMainButton")); //$NON-NLS-1$ pbImport.setMnemonic( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.importMainButtonMnemonic") .charAt(0)); pbImport.addActionListener(this); getRootPane().setDefaultButton(pbImport); oButtonPanel.addButton(pbImport); pbClose = new UIButton( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.cancelButton")); //$NON-NLS-1$ pbClose.setMnemonic( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.cancelButtonMnemonic") .charAt(0)); pbClose.addActionListener(this); oButtonPanel.addButton(pbClose); pbHelp = new UIButton( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.helpButton")); //$NON-NLS-1$ pbHelp.setMnemonic( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UIImportFlashMeetingXMLDialog.helpButtonMnemonic") .charAt(0)); ProjectCompendium.APP.mainHB.enableHelpOnButton( pbHelp, "io.import_flashmeeting_xml", ProjectCompendium.APP.mainHS); // $NON-NLS-1$ oButtonPanel.addHelpButton(pbHelp); // other initializations oContentPane.setLayout(new BorderLayout()); oContentPane.add(oCenterPanel, BorderLayout.CENTER); oContentPane.add(oButtonPanel, BorderLayout.SOUTH); pack(); setResizable(false); return; }
public DownloadPictures(ArrayList<CardDownloadData> cards) { this.cards = cards; bar = new JProgressBar(this); JPanel p0 = new JPanel(); p0.setLayout(new BoxLayout(p0, BoxLayout.Y_AXIS)); p0.add(Box.createVerticalStrut(5)); jLabel1 = new JLabel(); jLabel1.setText("Please select server:"); jLabel1.setAlignmentX(Component.LEFT_ALIGNMENT); p0.add(jLabel1); p0.add(Box.createVerticalStrut(5)); ComboBoxModel jComboBox1Model = new DefaultComboBoxModel( new String[] { "magiccards.info", "wizards.com", "mtgimage.com (HQ)" /*, "mtgathering.ru HQ", "mtgathering.ru MQ", "mtgathering.ru LQ"*/ }); jComboBox1 = new JComboBox(); cardImageSource = MagicCardsImageSource.getInstance(); jComboBox1.setModel(jComboBox1Model); jComboBox1.setAlignmentX(Component.LEFT_ALIGNMENT); jComboBox1.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); switch (cb.getSelectedIndex()) { case 0: cardImageSource = MagicCardsImageSource.getInstance(); break; case 1: cardImageSource = WizardCardsImageSource.getInstance(); break; case 2: cardImageSource = MtgImageSource.getInstance(); break; } int count = DownloadPictures.this.cards.size(); float mb = (count * cardImageSource.getAverageSize()) / 1024; bar.setString( String.format( cardIndex == count ? "%d of %d cards finished! Please close!" : "%d of %d cards finished! Please wait! [%.1f Mb]", 0, count, mb)); } }); p0.add(jComboBox1); p0.add(Box.createVerticalStrut(5)); // Start startDownloadButton = new JButton("Start download"); startDownloadButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new Thread(DownloadPictures.this).start(); startDownloadButton.setEnabled(false); checkBox.setEnabled(false); } }); p0.add(Box.createVerticalStrut(5)); // Progress p0.add(bar); bar.setStringPainted(true); int count = cards.size(); float mb = (count * cardImageSource.getAverageSize()) / 1024; bar.setString( String.format( cardIndex == cards.size() ? "%d of %d cards finished! Please close!" : "%d of %d cards finished! Please wait! [%.1f Mb]", 0, cards.size(), mb)); Dimension d = bar.getPreferredSize(); d.width = 300; bar.setPreferredSize(d); p0.add(Box.createVerticalStrut(5)); checkBox = new JCheckBox("Download images for Standard (Type2) only"); p0.add(checkBox); p0.add(Box.createVerticalStrut(5)); checkBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ArrayList<CardDownloadData> cardsToDownload = DownloadPictures.this.cards; if (checkBox.isSelected()) { DownloadPictures.this.type2cards = new ArrayList<>(); for (CardDownloadData data : DownloadPictures.this.cards) { if (data.isType2() || data.isToken()) { DownloadPictures.this.type2cards.add(data); } } cardsToDownload = DownloadPictures.this.type2cards; } int count = cardsToDownload.size(); float mb = (count * cardImageSource.getAverageSize()) / 1024; bar.setString( String.format( cardIndex == count ? "%d of %d cards finished! Please close!" : "%d of %d cards finished! Please wait! [%.1f Mb]", 0, count, mb)); } }); // JOptionPane Object[] options = {startDownloadButton, closeButton = new JButton("Cancel")}; dlg = new JOptionPane( p0, JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[1]); }
public EditorPaneHTMLHelp(String htmlFile) { if (GlobalValues.useSystemBrowserForHelp) { Desktop d = GlobalValues.desktop; try { // create a temp file GlobalValues.forHTMLHelptempFile = new File("tempHTMLHelpSynthetic.html"); FileWriter fw = new FileWriter(GlobalValues.forHTMLHelptempFile); java.util.List<String> list = readTextFromJar(htmlFile); Iterator<String> it = list.iterator(); while (it.hasNext()) { fw.write(it.next() + "\n"); } String canonicalPathOfFile = GlobalValues.forHTMLHelptempFile.getCanonicalPath(); URL urlFile = new URL("file://" + canonicalPathOfFile); URI uriOfFile = urlFile.toURI(); fw.close(); d.browse(uriOfFile); } catch (Exception e) { e.printStackTrace(); } } else { URL initialURL = getClass().getResource(htmlFile); font = GlobalValues.htmlfont; String title = "HTML Help"; setTitle(title); final Stack<String> urlStack = new Stack<String>(); final JEditorPane editorPane; editorPane = new JEditorPane(new HTMLEditorKit().getContentType(), " "); editorPane.setOpaque(false); editorPane.setBorder(null); editorPane.setEditable(false); JPanel magPanel = new JPanel(); magnificationFactor = GlobalValues.helpMagnificationFactor; magFactor = new JTextField(Double.toString(magnificationFactor)); JButton magButton = new JButton("Set Magnification: "); magButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { magnificationFactor = Double.parseDouble(magFactor.getText()); GlobalValues.helpMagnificationFactor = magnificationFactor; } }); magPanel.setLayout(new GridLayout(1, 2)); magPanel.add(magButton); magPanel.add(magFactor); final JTextField url = new JTextField(initialURL.toString()); // set up hyperlink listener editorPane.setEditable(false); try { // remember URL for back button urlStack.push(initialURL.toString()); // show URL in text field url.setText(initialURL.toString()); // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() * GlobalValues.helpMagnificationFactor + "pt; }"; ((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule); editorPane.setPage(initialURL); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } editorPane.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() * GlobalValues.helpMagnificationFactor + "pt; }"; ((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule); } }); editorPane.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { // remember URL for back button urlStack.push(event.getURL().toString()); // show URL in text field url.setText(event.getURL().toString()); editorPane.setPage(event.getURL()); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } } } }); // set up checkbox for toggling edit mode final JCheckBox editable = new JCheckBox(); editable.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { editorPane.setEditable(editable.isSelected()); } }); // set up load button for loading URL ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { try { // remember URL for back button urlStack.push(url.getText()); editorPane.setPage(url.getText()); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }; JButton loadButton = new JButton("Load/Magnify"); loadButton.addActionListener(listener); url.addActionListener(listener); // set up back button and button action JButton backButton = new JButton("Back"); backButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if (urlStack.size() <= 1) return; try { // get URL from back button urlStack.pop(); // show URL in text field String urlString = urlStack.peek(); url.setText(urlString); editorPane.setPage(urlString); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }); JPanel allPanel = new JPanel(new BorderLayout()); // put all control components in a panel JPanel ctrlPanel = new JPanel(new BorderLayout()); JPanel urlPanel = new JPanel(); urlPanel.add(new JLabel("URL")); urlPanel.add(url); JPanel buttonPanel = new JPanel(); buttonPanel.add(loadButton); buttonPanel.add(backButton); buttonPanel.add(new JLabel("Editable")); buttonPanel.add(magPanel); buttonPanel.add(editable); ctrlPanel.add(buttonPanel, BorderLayout.NORTH); ctrlPanel.add(urlPanel, BorderLayout.CENTER); allPanel.add(ctrlPanel, BorderLayout.NORTH); allPanel.add(new JScrollPane(editorPane), BorderLayout.CENTER); add(allPanel); } }
/** * Creates the video advanced settings. * * @return video advanced settings panel. */ private static Component createVideoAdvancedSettings() { ResourceManagementService resources = NeomediaActivator.getResources(); final DeviceConfiguration deviceConfig = mediaService.getDeviceConfiguration(); TransparentPanel centerPanel = new TransparentPanel(new GridBagLayout()); centerPanel.setMaximumSize(new Dimension(WIDTH, 150)); JButton resetDefaultsButton = new JButton(resources.getI18NString("impl.media.configform.VIDEO_RESET")); JPanel resetButtonPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); resetButtonPanel.add(resetDefaultsButton); final JPanel centerAdvancedPanel = new TransparentPanel(new BorderLayout()); centerAdvancedPanel.add(centerPanel, BorderLayout.NORTH); centerAdvancedPanel.add(resetButtonPanel, BorderLayout.SOUTH); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.insets = new Insets(5, 5, 0, 0); constraints.gridx = 0; constraints.weightx = 0; constraints.weighty = 0; constraints.gridy = 0; centerPanel.add( new JLabel(resources.getI18NString("impl.media.configform.VIDEO_RESOLUTION")), constraints); constraints.gridy = 1; constraints.insets = new Insets(0, 0, 0, 0); final JCheckBox frameRateCheck = new SIPCommCheckBox(resources.getI18NString("impl.media.configform.VIDEO_FRAME_RATE")); centerPanel.add(frameRateCheck, constraints); constraints.gridy = 2; constraints.insets = new Insets(5, 5, 0, 0); centerPanel.add( new JLabel(resources.getI18NString("impl.media.configform.VIDEO_PACKETS_POLICY")), constraints); constraints.weightx = 1; constraints.gridx = 1; constraints.gridy = 0; constraints.insets = new Insets(5, 0, 0, 5); Object[] resolutionValues = new Object[DeviceConfiguration.SUPPORTED_RESOLUTIONS.length + 1]; System.arraycopy( DeviceConfiguration.SUPPORTED_RESOLUTIONS, 0, resolutionValues, 1, DeviceConfiguration.SUPPORTED_RESOLUTIONS.length); final JComboBox sizeCombo = new JComboBox(resolutionValues); sizeCombo.setRenderer(new ResolutionCellRenderer()); sizeCombo.setEditable(false); centerPanel.add(sizeCombo, constraints); // default value is 20 final JSpinner frameRate = new JSpinner(new SpinnerNumberModel(20, 5, 30, 1)); frameRate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { deviceConfig.setFrameRate( ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue()); } }); constraints.gridy = 1; constraints.insets = new Insets(0, 0, 0, 5); centerPanel.add(frameRate, constraints); frameRateCheck.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (frameRateCheck.isSelected()) { deviceConfig.setFrameRate( ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue()); } else // unlimited framerate deviceConfig.setFrameRate(-1); frameRate.setEnabled(frameRateCheck.isSelected()); } }); final JSpinner videoMaxBandwidth = new JSpinner( new SpinnerNumberModel(deviceConfig.getVideoMaxBandwidth(), 1, Integer.MAX_VALUE, 1)); videoMaxBandwidth.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { deviceConfig.setVideoMaxBandwidth( ((SpinnerNumberModel) videoMaxBandwidth.getModel()).getNumber().intValue()); } }); constraints.gridx = 1; constraints.gridy = 2; constraints.insets = new Insets(0, 0, 5, 5); centerPanel.add(videoMaxBandwidth, constraints); resetDefaultsButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // reset to defaults sizeCombo.setSelectedIndex(0); frameRateCheck.setSelected(false); frameRate.setEnabled(false); frameRate.setValue(20); // unlimited framerate deviceConfig.setFrameRate(-1); videoMaxBandwidth.setValue(DeviceConfiguration.DEFAULT_VIDEO_MAX_BANDWIDTH); } }); // load selected value or auto Dimension videoSize = deviceConfig.getVideoSize(); if ((videoSize.getHeight() != DeviceConfiguration.DEFAULT_VIDEO_HEIGHT) && (videoSize.getWidth() != DeviceConfiguration.DEFAULT_VIDEO_WIDTH)) sizeCombo.setSelectedItem(deviceConfig.getVideoSize()); else sizeCombo.setSelectedIndex(0); sizeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Dimension selectedVideoSize = (Dimension) sizeCombo.getSelectedItem(); if (selectedVideoSize == null) { // the auto value, default one selectedVideoSize = new Dimension( DeviceConfiguration.DEFAULT_VIDEO_WIDTH, DeviceConfiguration.DEFAULT_VIDEO_HEIGHT); } deviceConfig.setVideoSize(selectedVideoSize); } }); frameRateCheck.setSelected( deviceConfig.getFrameRate() != DeviceConfiguration.DEFAULT_VIDEO_FRAMERATE); frameRate.setEnabled(frameRateCheck.isSelected()); if (frameRate.isEnabled()) frameRate.setValue(deviceConfig.getFrameRate()); return centerAdvancedPanel; }
public EditorPaneFrame() { setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); final Stack<String> urlStack = new Stack<>(); final JEditorPane editorPane = new JEditorPane(); final JTextField url = new JTextField(30); // set up hyperlink listener editorPane.setEditable(false); editorPane.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { // remember URL for back button urlStack.push(event.getURL().toString()); // show URL in text field url.setText(event.getURL().toString()); editorPane.setPage(event.getURL()); } catch (IOException e) { editorPane.setText("Exception: " + e); } } } }); // set up checkbox for toggling edit mode final JCheckBox editable = new JCheckBox(); editable.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { editorPane.setEditable(editable.isSelected()); } }); // set up load button for loading URL ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { try { // remember URL for back button urlStack.push(url.getText()); editorPane.setPage(url.getText()); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }; JButton loadButton = new JButton("Load"); loadButton.addActionListener(listener); url.addActionListener(listener); // set up back button and button action JButton backButton = new JButton("Back"); backButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if (urlStack.size() <= 1) return; try { // get URL from back button urlStack.pop(); // show URL in text field String urlString = urlStack.peek(); url.setText(urlString); editorPane.setPage(urlString); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }); add(new JScrollPane(editorPane), BorderLayout.CENTER); // put all control components in a panel JPanel panel = new JPanel(); panel.add(new JLabel("URL")); panel.add(url); panel.add(loadButton); panel.add(backButton); panel.add(new JLabel("Editable")); panel.add(editable); add(panel, BorderLayout.SOUTH); }
/** Constructor (create and layout page) */ public SOAPMonitorPage(String host_name) { host = host_name; // Set up default filter (show all messages) filter = new SOAPMonitorFilter(); // Use borders to help improve appearance etched_border = new EtchedBorder(); // Build top portion of split (list panel) model = new SOAPMonitorTableModel(); table = new JTable(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setRowSelectionInterval(0, 0); table.setPreferredScrollableViewportSize(new Dimension(600, 96)); table.getSelectionModel().addListSelectionListener(this); scroll = new JScrollPane(table); remove_button = new JButton("Remove"); remove_button.addActionListener(this); remove_button.setEnabled(false); remove_all_button = new JButton("Remove All"); remove_all_button.addActionListener(this); filter_button = new JButton("Filter ..."); filter_button.addActionListener(this); list_buttons = new JPanel(); list_buttons.setLayout(new FlowLayout()); list_buttons.add(remove_button); list_buttons.add(remove_all_button); list_buttons.add(filter_button); list_panel = new JPanel(); list_panel.setLayout(new BorderLayout()); list_panel.add(scroll, BorderLayout.CENTER); list_panel.add(list_buttons, BorderLayout.SOUTH); list_panel.setBorder(empty_border); // Build bottom portion of split (message details) details_time = new JLabel("Time: ", SwingConstants.RIGHT); details_target = new JLabel("Target Service: ", SwingConstants.RIGHT); details_status = new JLabel("Status: ", SwingConstants.RIGHT); details_time_value = new JLabel(); details_target_value = new JLabel(); details_status_value = new JLabel(); Dimension preferred_size = details_time.getPreferredSize(); preferred_size.width = 1; details_time.setPreferredSize(preferred_size); details_target.setPreferredSize(preferred_size); details_status.setPreferredSize(preferred_size); details_time_value.setPreferredSize(preferred_size); details_target_value.setPreferredSize(preferred_size); details_status_value.setPreferredSize(preferred_size); details_header = new JPanel(); details_header_layout = new GridBagLayout(); details_header.setLayout(details_header_layout); details_header_constraints = new GridBagConstraints(); details_header_constraints.fill = GridBagConstraints.BOTH; details_header_constraints.weightx = 0.5; details_header_layout.setConstraints(details_time, details_header_constraints); details_header.add(details_time); details_header_layout.setConstraints(details_time_value, details_header_constraints); details_header.add(details_time_value); details_header_layout.setConstraints(details_target, details_header_constraints); details_header.add(details_target); details_header_constraints.weightx = 1.0; details_header_layout.setConstraints(details_target_value, details_header_constraints); details_header.add(details_target_value); details_header_constraints.weightx = .5; details_header_layout.setConstraints(details_status, details_header_constraints); details_header.add(details_status); details_header_layout.setConstraints(details_status_value, details_header_constraints); details_header.add(details_status_value); details_header.setBorder(etched_border); request_label = new JLabel("SOAP Request", SwingConstants.CENTER); request_text = new SOAPMonitorTextArea(); request_text.setEditable(false); request_scroll = new JScrollPane(request_text); request_panel = new JPanel(); request_panel.setLayout(new BorderLayout()); request_panel.add(request_label, BorderLayout.NORTH); request_panel.add(request_scroll, BorderLayout.CENTER); response_label = new JLabel("SOAP Response", SwingConstants.CENTER); response_text = new SOAPMonitorTextArea(); response_text.setEditable(false); response_scroll = new JScrollPane(response_text); response_panel = new JPanel(); response_panel.setLayout(new BorderLayout()); response_panel.add(response_label, BorderLayout.NORTH); response_panel.add(response_scroll, BorderLayout.CENTER); details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); details_soap.setTopComponent(request_panel); details_soap.setRightComponent(response_panel); details_soap.setResizeWeight(.5); details_panel = new JPanel(); layout_button = new JButton("Switch Layout"); layout_button.addActionListener(this); reflow_xml = new JCheckBox("Reflow XML text"); reflow_xml.addActionListener(this); details_buttons = new JPanel(); details_buttons.setLayout(new FlowLayout()); details_buttons.add(reflow_xml); details_buttons.add(layout_button); details_panel.setLayout(new BorderLayout()); details_panel.add(details_header, BorderLayout.NORTH); details_panel.add(details_soap, BorderLayout.CENTER); details_panel.add(details_buttons, BorderLayout.SOUTH); details_panel.setBorder(empty_border); // Add the two parts to the age split pane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setTopComponent(list_panel); split.setRightComponent(details_panel); // Build status area start_button = new JButton("Start"); start_button.addActionListener(this); stop_button = new JButton("Stop"); stop_button.addActionListener(this); status_buttons = new JPanel(); status_buttons.setLayout(new FlowLayout()); status_buttons.add(start_button); status_buttons.add(stop_button); status_text = new JLabel(); status_text.setBorder(new BevelBorder(BevelBorder.LOWERED)); status_text_panel = new JPanel(); status_text_panel.setLayout(new BorderLayout()); status_text_panel.add(status_text, BorderLayout.CENTER); status_text_panel.setBorder(empty_border); status_area = new JPanel(); status_area.setLayout(new BorderLayout()); status_area.add(status_buttons, BorderLayout.WEST); status_area.add(status_text_panel, BorderLayout.CENTER); status_area.setBorder(etched_border); // Add the split and status area to page setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); add(status_area, BorderLayout.SOUTH); }
public ThumbMaker() { super("ThumbMaker"); // grab the preferences so that they can be used to fill out the layout ThumbMakerPreferences myPrefs = ThumbMakerPreferences.getInstance(); // content pane JPanel pane = new JPanel(); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); setContentPane(pane); // top panel JPanel top = new JPanel(); top.setLayout(new BoxLayout(top, BoxLayout.X_AXIS)); pane.add(top); // left-hand panel JPanel left = new JPanel(); left.setLayout(new BoxLayout(left, BoxLayout.Y_AXIS)); top.add(left); // horizontal padding top.add(Box.createHorizontalStrut(5)); // label for file list JLabel listLabel = GUIUtil.makeLabel("Files to process:"); listLabel.setDisplayedMnemonic('f'); String listTip = "List of files from which to create thumbnails"; listLabel.setToolTipText(listTip); left.add(GUIUtil.pad(listLabel)); // list of files to convert list = new JList(); listLabel.setLabelFor(list); list.setToolTipText(listTip); list.setModel(new DefaultListModel()); list.setDragEnabled(true); changeFilesInList = new ThumbTransferHandler(); list.setTransferHandler(changeFilesInList); left.add(new JScrollPane(list)); // progress bar progress = new JProgressBar(0, 1); progress.setString("[Drag and drop files onto list to begin]"); progress.setStringPainted(true); progress.setToolTipText("Status of thumbnail processing operation"); left.add(progress); // panel for process and remove buttons JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); // add files button addFiles = new JButton("Add Files"); addFiles.setMnemonic('d'); addFiles.setToolTipText("Add files to be processed."); addFiles.addActionListener(this); p.add(addFiles); p.add(Box.createHorizontalStrut(5)); // process button process = new JButton("Process"); process.setMnemonic('p'); process.setToolTipText("Begin creating thumbnails"); process.addActionListener(this); p.add(process); p.add(Box.createHorizontalStrut(5)); // remove button remove = new JButton("Remove"); remove.setMnemonic('v'); remove.setToolTipText("Remove selected files from the list"); remove.addActionListener(this); p.add(remove); left.add(GUIUtil.pad(p)); // right-hand panel JPanel right = new JPanel(); right.setLayout(new BoxLayout(right, BoxLayout.Y_AXIS)); top.add(right); // panel for resolution settings p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); // resolution label JLabel resLabel = GUIUtil.makeLabel("Resolution: "); resLabel.setDisplayedMnemonic('s'); resLabel.setToolTipText("Resolution of the thumbnails"); p.add(resLabel); // x resolution text box xres = GUIUtil.makeTextField(myPrefs.getStringPref(ThumbMakerPreferences.RES_WIDTH_PREF_NAME), 2); resLabel.setLabelFor(xres); xres.setToolTipText("Thumbnail width"); p.add(xres); // "by" label JLabel byLabel = GUIUtil.makeLabel(" by "); byLabel.setDisplayedMnemonic('y'); p.add(byLabel); // y resolution text box yres = GUIUtil.makeTextField(myPrefs.getStringPref(ThumbMakerPreferences.RES_HEIGHT_PREF_NAME), 2); byLabel.setLabelFor(yres); yres.setToolTipText("Thumbnail height"); p.add(yres); right.add(GUIUtil.pad(p)); right.add(Box.createVerticalStrut(8)); // aspect ratio checkbox aspect = new JCheckBox("Maintain aspect ratio", true); aspect.setMnemonic('m'); aspect.setToolTipText( "When checked, thumbnails are not stretched, " + "but rather padded with the background color."); aspect.addActionListener(this); right.add(GUIUtil.pad(aspect)); // make sure that the check box is initialized correctly aspect.setSelected( myPrefs .getStringPref(ThumbMakerPreferences.DO_MAINTAIN_ASPECT_PREF_NAME) .equalsIgnoreCase(ThumbMakerPreferences.BOOLEAN_TRUE_STRING)); // panel for background color p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); // load the color values from the preferences int redValueNumber = myPrefs.getIntegerPref(ThumbMakerPreferences.RED_VALUE_PREF_NAME); int greenValueNumber = myPrefs.getIntegerPref(ThumbMakerPreferences.GREEN_VALUE_PREF_NAME); int blueValueNumber = myPrefs.getIntegerPref(ThumbMakerPreferences.BLUE_VALUE_PREF_NAME); // background color label colorLabel = GUIUtil.makeLabel("Background color: "); String colorTip = "Thumbnail background color"; colorLabel.setToolTipText(colorTip); p.add(colorLabel); // background color colorBox = new JPanel(); colorBox.setToolTipText(colorTip); colorBox.setBorder(new LineBorder(Color.black, 1)); Dimension colorBoxSize = new Dimension(45, 15); colorBox.setMaximumSize(colorBoxSize); colorBox.setMinimumSize(colorBoxSize); colorBox.setPreferredSize(colorBoxSize); colorBox.setBackground(new Color(redValueNumber, greenValueNumber, blueValueNumber)); p.add(colorBox); right.add(GUIUtil.pad(p)); right.add(Box.createVerticalStrut(2)); // red slider redLabel = GUIUtil.makeLabel("R"); red = new JSlider(0, 255, redValueNumber); redValue = GUIUtil.makeLabel("" + redValueNumber); redValue.setToolTipText("Red color component slider"); right.add(makeSlider(redLabel, red, redValue, "Red")); // green slider greenLabel = GUIUtil.makeLabel("G"); green = new JSlider(0, 255, greenValueNumber); greenValue = GUIUtil.makeLabel("" + greenValueNumber); greenValue.setToolTipText("Green color component slider"); right.add(makeSlider(greenLabel, green, greenValue, "Green")); // blue slider blueLabel = GUIUtil.makeLabel("B"); blue = new JSlider(0, 255, blueValueNumber); blueValue = GUIUtil.makeLabel("" + blueValueNumber); right.add(makeSlider(blueLabel, blue, blueValue, "Blue")); right.add(Box.createVerticalStrut(8)); // panel for algorithm p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); // algorithm label JLabel algorithmLabel = GUIUtil.makeLabel("Algorithm: "); algorithmLabel.setDisplayedMnemonic('l'); String algorithmTip = "Resizing algorithm to use"; algorithmLabel.setToolTipText(algorithmTip); p.add(algorithmLabel); // algorithm combo box algorithm = GUIUtil.makeComboBox( new String[] {"Smooth", "Standard", "Fast", "Replicate", "Area averaging"}); algorithmLabel.setLabelFor(algorithm); algorithm.setToolTipText(algorithmTip); p.add(algorithm); // set the algorithm value from the preferences algorithm.setSelectedIndex(myPrefs.getIntegerPref(ThumbMakerPreferences.RESIZE_ALG_PREF_NAME)); right.add(GUIUtil.pad(p)); // panel for output format p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); // format label JLabel formatLabel = GUIUtil.makeLabel("Format: "); formatLabel.setDisplayedMnemonic('f'); String formatTip = "Thumbnail output format"; formatLabel.setToolTipText(formatTip); p.add(formatLabel); // format combo box format = GUIUtil.makeComboBox(new String[] {"PNG", "JPG"}); formatLabel.setLabelFor(format); format.setToolTipText(formatTip); p.add(format); // set the format value from the preferences format.setSelectedIndex(myPrefs.getIntegerPref(ThumbMakerPreferences.THUMB_FORMAT_PREF_NAME)); right.add(GUIUtil.pad(p)); right.add(Box.createVerticalStrut(5)); // panel for prepend string p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); // prepend label JLabel prependLabel = GUIUtil.makeLabel("Prepend: "); prependLabel.setDisplayedMnemonic('e'); String prependTip = "Starting string for each thumbnail filename"; prependLabel.setToolTipText(prependTip); p.add(prependLabel); // prepend field prepend = GUIUtil.makeTextField( myPrefs.getStringPref(ThumbMakerPreferences.STRING_TO_PREPEND_PREF_NAME), 4); prependLabel.setLabelFor(prepend); prepend.setToolTipText(prependTip); p.add(prepend); p.add(Box.createHorizontalStrut(5)); // append label JLabel appendLabel = GUIUtil.makeLabel("Append: "); appendLabel.setDisplayedMnemonic('a'); String appendTip = "Ending string for each thumbnail filename"; appendLabel.setToolTipText(appendTip); p.add(appendLabel); // append field append = GUIUtil.makeTextField( myPrefs.getStringPref(ThumbMakerPreferences.STRING_TO_APPEND_PREF_NAME), 4); appendLabel.setLabelFor(append); append.setToolTipText(appendTip); p.add(append); right.add(GUIUtil.pad(p)); // vertical padding right.add(Box.createVerticalGlue()); // bottom panel JPanel bottom = new JPanel(); bottom.setLayout(new BoxLayout(bottom, BoxLayout.X_AXIS)); pane.add(bottom); // output folder label JLabel outputLabel = GUIUtil.makeLabel("Output folder: "); outputLabel.setDisplayedMnemonic('o'); String outputTip = "Thumbnail output folder"; outputLabel.setToolTipText(outputTip); bottom.add(outputLabel); // output folder field String filePath = new File(myPrefs.getStringPref(ThumbMakerPreferences.FILE_PATH_STRING_PREF_NAME)) .getAbsolutePath(); output = GUIUtil.makeTextField(filePath, 8); outputLabel.setLabelFor(output); output.setToolTipText(outputTip); // start this in default and then lock down so "..." is used output.setEditable(false); output.setBackground(Color.LIGHT_GRAY); bottom.add(output); // add a file chooser button "..." dotDotDot = new JButton("..."); dotDotDot.setMnemonic('.'); dotDotDot.setToolTipText("Select destination directory."); dotDotDot.addActionListener(this); bottom.add(dotDotDot); right.add(GUIUtil.pad(p)); setFromPreferences(); addWindowListener(this); }
public LJ3MDApp() { tNum.setHorizontalAlignment(JTextField.CENTER); tTemp.setHorizontalAlignment(JTextField.CENTER); tRho.setHorizontalAlignment(JTextField.CENTER); tSpeed.setHorizontalAlignment(JTextField.CENTER); tAvK.setHorizontalAlignment(JTextField.RIGHT); tAvU.setHorizontalAlignment(JTextField.RIGHT); tAvp.setHorizontalAlignment(JTextField.RIGHT); float[] aveKing = new float[501]; float[] avePot = new float[501]; float[] aveEn = new float[501]; JFrame box = new JFrame(); box.setLayout(new BorderLayout()); box.setSize(1000, 1000); box.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); cpnl = new JPanel(); // create a panel for controls cpnl.setLayout(new GridLayout(18, 2)); box.add(cpnl, BorderLayout.EAST); // add controls cpnl.add(bStart); bStart.addActionListener(this); cpnl.add(bReset); bReset.addActionListener(this); cpnl.add(new JLabel(" N:")); tNum.addActionListener(this); cpnl.add(tNum); cpnl.add(new JLabel(" Density (\u03c1):")); tRho.addActionListener(this); cpnl.add(tRho); cpnl.add(new JLabel(" Steps/frame:")); tSpeed.addActionListener(this); cpnl.add(tSpeed); cpnl.add(bTstat); bTstat.addActionListener(this); cpnl.add(bPot); bPot.addActionListener(this); cpnl.add(new JLabel(" < K/N > :")); tAvK.setEditable(false); cpnl.add(tAvK); cpnl.add(new JLabel(" Temperature:")); tTemp.setEditable(false); cpnl.add(tTemp); cpnl.add(new JLabel(" < U/N > :")); tAvU.setEditable(false); cpnl.add(tAvU); cpnl.add(new JLabel(" < pressure > :")); tAvp.setEditable(false); cpnl.add(tAvp); cpnl.add(bRetime); bRetime.addActionListener(this); spnl = new JPanel(); // create a panel for status box.add(spnl, BorderLayout.SOUTH); lStatus.setFont(new Font("Courier", 0, 12)); spnl.add(lStatus); canvas = new XYZCanvas(); box.add(canvas, BorderLayout.CENTER); timer = new Timer(delay, this); timer.start(); // timer.stop(); box.setVisible(true); }
public SceneLayoutApp() { super(); new Pair(); final JFrame frame = new JFrame("Scene Layout"); final JPanel panel = new JPanel(new BorderLayout()); frame.setContentPane(panel); final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setMaximumSize(screenSize); frame.setSize(screenSize); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JMenuBar mb = new JMenuBar(); frame.setJMenuBar(mb); final JMenu jMenu = new JMenu("File"); mb.add(jMenu); mb.add(new JMenu("Edit")); mb.add(new JMenu("Help")); JMenu menu = new JMenu("Look and Feel"); // // Get all the available look and feel that we are going to use for // creating the JMenuItem and assign the action listener to handle // the selection of menu item to change the look and feel. // UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels(); for (int i = 0; i < lookAndFeelInfos.length; i++) { final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i]; JMenuItem item = new JMenuItem(lookAndFeelInfo.getName()); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { // // Set the look and feel for the frame and update the UI // to use a new selected look and feel. // UIManager.setLookAndFeel(lookAndFeelInfo.getClassName()); SwingUtilities.updateComponentTreeUI(frame); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } catch (InstantiationException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (UnsupportedLookAndFeelException e1) { e1.printStackTrace(); } } }); menu.add(item); } mb.add(menu); jMenu.add(new JMenuItem(new scene.action.QuitAction())); panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER); final JToolBar bar = new JToolBar(); panel.add(bar, BorderLayout.NORTH); final JComboBox comboNewWindow = new JComboBox( new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"}); comboNewWindow.addActionListener(new CreateSceneWindowAction()); comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window")); bar.add(comboNewWindow); bar.add( new AbstractAction("Progress Bars") { /** Invoked when an action occurs. */ @Override public void actionPerformed(ActionEvent e) { new ProgressBarAnimator(); } }); bar.add( new AbstractAction("Sliders") { /** Invoked when an action occurs. */ @Override public void actionPerformed(ActionEvent e) { new SliderBarAnimator(); } }); final JCheckBox permaViz = new JCheckBox(); permaViz.setText("Show the dump window"); permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); dumpWindow = new JInternalFrame("perma dump window"); dumpWindow.setContentPane(new JScrollPane(permText)); permaViz.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dumpWindow.setVisible(permaViz.isSelected()); } }); comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize()); permaViz.setSelected(false); bar.add(new CreateWebViewV1Action()); bar.add(new CreateWebViewV2Action()); bar.add(permaViz); desktopPane.add(dumpWindow); dumpWindow.setSize(400, 400); dumpWindow.setResizable(true); dumpWindow.setClosable(false); dumpWindow.setIconifiable(false); final JMenuBar m = new JMenuBar(); final JMenu cmenu = new JMenu("Create"); m.add(cmenu); final JMenuItem menuItem = new JMenuItem( new AbstractAction("new") { @Override public void actionPerformed(ActionEvent e) { Runnable runnable = new Runnable() { public void run() { Object[] in = (Object[]) XSTREAM.fromXML(permText.getText()); final JInternalFrame ff = new JInternalFrame(); final ScenePanel c = new ScenePanel(); ff.setContentPane(c); desktopPane.add(ff); final Dimension d = (Dimension) in[0]; c.setMaximumSize(d); c.setPreferredSize(d); ff.setSize(d.width + 50, d.height + 50); ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]); c.invalidate(); c.repaint(); ff.pack(); ff.setClosable(true); ff.setMaximizable(false); ff.setIconifiable(false); ff.setResizable(false); ff.show(); } }; SwingUtilities.invokeLater(runnable); } }); cmenu.add(menuItem); // JMenuBar menuBar = new JMenuBar(); // getContentPane().add(menuBar); dumpWindow.setJMenuBar(m); frame.setVisible(true); }
/** Shows a dialog with input for logs description. */ private void uploadLogs() { ResourceManagementService resources = LoggingUtilsActivator.getResourceService(); final SIPCommDialog dialog = new SIPCommDialog(false) { /** Serial version UID. */ private static final long serialVersionUID = 0L; /** * Dialog is closed. Do nothing. * * @param escaped <tt>true</tt> if this dialog has been closed by pressing */ @Override protected void close(boolean escaped) {} }; dialog.setModal(true); dialog.setTitle(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON")); Container container = dialog.getContentPane(); container.setLayout(new GridBagLayout()); JLabel descriptionLabel = new JLabel("Add a comment:"); final JTextArea commentTextArea = new JTextArea(); commentTextArea.setRows(4); final JButton uploadButton = new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_BUTTON")); final SIPCommTextField emailField = new SIPCommTextField(resources.getI18NString("plugin.loggingutils.ARCHIVE_UPREPORT_EMAIL")); final JCheckBox emailCheckBox = new SIPCommCheckBox("Email me when more information is available"); emailCheckBox.setSelected(true); emailCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (!emailCheckBox.isSelected()) { uploadButton.setEnabled(true); emailField.setEnabled(false); } else { emailField.setEnabled(true); if (emailField.getText() != null && emailField.getText().trim().length() > 0) uploadButton.setEnabled(true); else uploadButton.setEnabled(false); } } }); emailField .getDocument() .addDocumentListener( new DocumentListener() { public void insertUpdate(DocumentEvent e) { updateButtonsState(); } public void removeUpdate(DocumentEvent e) { updateButtonsState(); } public void changedUpdate(DocumentEvent e) {} /** Check whether we should enable upload button. */ private void updateButtonsState() { if (emailCheckBox.isSelected() && emailField.getText() != null && emailField.getText().trim().length() > 0) uploadButton.setEnabled(true); else uploadButton.setEnabled(false); } }); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(10, 10, 3, 10); c.weightx = 1.0; c.gridx = 0; c.gridy = 0; container.add(descriptionLabel, c); c.insets = new Insets(0, 10, 10, 10); c.gridy = 1; container.add(new JScrollPane(commentTextArea), c); c.insets = new Insets(0, 10, 0, 10); c.gridy = 2; container.add(emailCheckBox, c); c.insets = new Insets(0, 10, 10, 10); c.gridy = 3; container.add(emailField, c); JButton cancelButton = new JButton(resources.getI18NString("service.gui.CANCEL")); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); uploadButton.setEnabled(false); uploadButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { final ArrayList<String> paramNames = new ArrayList<String>(); final ArrayList<String> paramValues = new ArrayList<String>(); if (emailCheckBox.isSelected()) { paramNames.add("Email"); paramValues.add(emailField.getText()); } paramNames.add("Description"); paramValues.add(commentTextArea.getText()); // don't block the UI thread we may need to show // some ui for password input if protected area on the way new Thread( new Runnable() { public void run() { uploadLogs( getUploadLocation(), LogsCollector.getDefaultFileName(), paramNames.toArray(new String[] {}), paramValues.toArray(new String[] {})); } }) .start(); } finally { dialog.dispose(); } } }); JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); buttonsPanel.add(uploadButton); buttonsPanel.add(cancelButton); c.anchor = GridBagConstraints.LINE_END; c.weightx = 0; c.gridy = 4; container.add(buttonsPanel, c); dialog.setVisible(true); }
public GUI() { // Frame frame = new JFrame("HardwareSwap Notifier"); // Panels panel = new JPanel(); group1 = new JPanel(); group2 = new JPanel(); group3 = new JPanel(); group4 = new JPanel(); group5 = new JPanel(); group6 = new JPanel(); group7 = new JPanel(); group8 = new JPanel(); // Menu Bar menus = new JMenuBar(); fileMenu = new JMenu("File"); clearCurrent = new JMenuItem("Clear"); quitItem = new JMenuItem("Quit"); load = new JMenuItem("Load"); saveCurrent = new JMenuItem("Save All"); clearSaved = new JMenuItem("Clear Saved"); removeItem = new JMenuItem("Remove Item"); removePhone = new JMenuItem("Remove Phone"); saveCurrent = new JMenuItem("Save Current"); helpMenu = new JMenu("Help"); help = new JMenuItem("How To Use"); about = new JMenuItem("About"); // Buttons add1 = new JButton("Add"); add2 = new JButton("Add"); start = new JButton("Start"); stop = new JButton("Stop"); save1 = new JButton("Add/Save"); save2 = new JButton("Add/Save"); show = new JButton("Display Data"); add1.setFocusPainted(false); add2.setFocusPainted(false); start.setFocusPainted(false); stop.setFocusPainted(false); save1.setFocusPainted(false); save2.setFocusPainted(false); show.setFocusPainted(false); stop.setEnabled(false); // CheckBox remove = new JCheckBox("Remove items when found"); remove.setFocusable(false); // Listener ButtonListener listener = new ButtonListener(); add1.addActionListener(listener); add2.addActionListener(listener); start.addActionListener(listener); stop.addActionListener(listener); load.addActionListener(listener); save1.addActionListener(listener); save2.addActionListener(listener); saveCurrent.addActionListener(listener); show.addActionListener(listener); quitItem.addActionListener(listener); clearCurrent.addActionListener(listener); clearSaved.addActionListener(listener); saveCurrent.addActionListener(listener); help.addActionListener(listener); about.addActionListener(listener); removePhone.addActionListener(listener); removeItem.addActionListener(listener); remove.addActionListener(listener); // Carrier Selection options = new String[10]; options[0] = "AT&T"; options[1] = "Boost Mobile"; options[2] = "Cellular One"; options[3] = "Nextel"; options[4] = "T-Mobile"; options[5] = "Tracfone"; options[6] = "US Cellular"; options[7] = "Sprint"; options[8] = "Verizon"; options[9] = "Virgin Mobile"; carriers = new JComboBox<String>(options); // Text Fields searchName = new JTextField(15); item = new JTextField(15); phone = new JTextField(15); interval2 = new JTextField(15); results = new JTextArea(10, 20); JScrollPane scrollPane = new JScrollPane(results); results.setEditable(false); // Interval intOptions = new SpinnerNumberModel(5, 1, 60, 1); interval = new JSpinner(intOptions); JFormattedTextField tf = ((JSpinner.DefaultEditor) interval.getEditor()).getTextField(); tf.setHorizontalAlignment(JFormattedTextField.LEFT); // Background panelBackground = new Color(237, 237, 237); panel.setBackground(panelBackground); searchName.setBackground(panelBackground); item.setBackground(panelBackground); phone.setBackground(panelBackground); interval.setBackground(panelBackground); // Panel Layouts panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); group1.setLayout(new BoxLayout(group1, BoxLayout.PAGE_AXIS)); group2.setLayout(new BoxLayout(group2, BoxLayout.X_AXIS)); group3.setLayout(new BoxLayout(group3, BoxLayout.PAGE_AXIS)); group4.setLayout(new BoxLayout(group4, BoxLayout.X_AXIS)); group5.setLayout(new BoxLayout(group5, BoxLayout.X_AXIS)); group6.setLayout(new BoxLayout(group6, BoxLayout.X_AXIS)); group7.setLayout(new BoxLayout(group7, BoxLayout.X_AXIS)); group8.setLayout(new BoxLayout(group8, BoxLayout.X_AXIS)); // Borders searchName.setBorder( BorderFactory.createTitledBorder( null, "Search Name", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); item.setBorder( BorderFactory.createTitledBorder( null, "Item", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); phone.setBorder( BorderFactory.createTitledBorder( null, "Cell Phone", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); group5.setBorder( BorderFactory.createTitledBorder( null, "Check Interval (mins)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); // Sizes panel.setPreferredSize(new Dimension(200, 0)); searchName.setMaximumSize(new Dimension(190, 50)); item.setMaximumSize(new Dimension(190, 50)); phone.setMaximumSize(new Dimension(185, 50)); carriers.setMaximumSize(new Dimension(175, 20)); group5.setPreferredSize(new Dimension(190, 47)); group5.setMaximumSize(new Dimension(190, 47)); add1.setMaximumSize(new Dimension(90, 20)); save1.setMaximumSize(new Dimension(90, 20)); add2.setMaximumSize(new Dimension(90, 20)); save2.setMaximumSize(new Dimension(90, 20)); start.setMaximumSize(new Dimension(90, 20)); stop.setMaximumSize(new Dimension(90, 20)); show.setMaximumSize(new Dimension(120, 20)); // Add file menu items fileMenu.add(clearCurrent); fileMenu.add(clearSaved); fileMenu.add(load); fileMenu.add(removeItem); fileMenu.add(removePhone); fileMenu.add(saveCurrent); fileMenu.add(quitItem); // Add help menu items helpMenu.add(help); helpMenu.add(about); // Add to menu bar menus.add(fileMenu); menus.add(helpMenu); // Add items to panel group1.add(searchName); group1.add(item); group2.add(add1); group2.add(Box.createHorizontalStrut(10)); group2.add(save1); group6.add(remove); group3.add(phone); group3.add(Box.createVerticalStrut(10)); group3.add(carriers); group4.add(add2); group4.add(Box.createHorizontalStrut(10)); group4.add(save2); group5.add(interval); group7.add(show); group8.add(start); group8.add(Box.createHorizontalStrut(10)); group8.add(stop); panel.add(Box.createVerticalStrut(10)); panel.add(group1); panel.add(Box.createVerticalStrut(10)); panel.add(group2); panel.add(Box.createVerticalStrut(40)); panel.add(group3); panel.add(Box.createVerticalStrut(10)); panel.add(group4); panel.add(Box.createVerticalStrut(40)); panel.add(group5); panel.add(Box.createVerticalStrut(30)); panel.add(group6); panel.add(Box.createVerticalStrut(40)); panel.add(group7); panel.add(Box.createVerticalStrut(10)); panel.add(group8); panel.add(Box.createVerticalStrut(10)); // Setup frame frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(menus); frame.add(scrollPane); frame.add(BorderLayout.EAST, panel); frame.pack(); frame.setSize(new Dimension(670, 620)); frame.setVisible(true); }
/** Creating the configuration form */ private void init() { ResourceManagementService resources = LoggingUtilsActivator.getResourceService(); enableCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.ENABLE_DISABLE")); enableCheckBox.addActionListener(this); sipProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.sipaccregwizz.PROTOCOL_NAME")); sipProtocolCheckBox.addActionListener(this); jabberProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.jabberaccregwizz.PROTOCOL_NAME")); jabberProtocolCheckBox.addActionListener(this); String rtpDescription = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP_DESCRIPTION"); rtpProtocolCheckBox = new SIPCommCheckBox( resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP") + " " + rtpDescription); rtpProtocolCheckBox.addActionListener(this); rtpProtocolCheckBox.setToolTipText(rtpDescription); ice4jProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_ICE4J")); ice4jProtocolCheckBox.addActionListener(this); JPanel mainPanel = new TransparentPanel(); add(mainPanel, BorderLayout.NORTH); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.gridx = 0; c.gridy = 0; mainPanel.add(enableCheckBox, c); String label = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_DESCRIPTION"); JLabel descriptionLabel = new JLabel(label); descriptionLabel.setToolTipText(label); enableCheckBox.setToolTipText(label); descriptionLabel.setForeground(Color.GRAY); descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(8)); c.gridy = 1; c.insets = new Insets(0, 25, 10, 0); mainPanel.add(descriptionLabel, c); final JPanel loggersButtonPanel = new TransparentPanel(new GridLayout(0, 1)); loggersButtonPanel.setBorder( BorderFactory.createTitledBorder(resources.getI18NString("service.gui.PROTOCOL"))); loggersButtonPanel.add(sipProtocolCheckBox); loggersButtonPanel.add(jabberProtocolCheckBox); loggersButtonPanel.add(rtpProtocolCheckBox); loggersButtonPanel.add(ice4jProtocolCheckBox); c.insets = new Insets(0, 20, 10, 0); c.gridy = 2; mainPanel.add(loggersButtonPanel, c); final JPanel advancedPanel = new TransparentPanel(new GridLayout(0, 2)); advancedPanel.setBorder( BorderFactory.createTitledBorder(resources.getI18NString("service.gui.ADVANCED"))); fileCountField.getDocument().addDocumentListener(this); fileSizeField.getDocument().addDocumentListener(this); fileCountLabel = new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_COUNT")); advancedPanel.add(fileCountLabel); advancedPanel.add(fileCountField); fileSizeLabel = new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_SIZE")); advancedPanel.add(fileSizeLabel); advancedPanel.add(fileSizeField); c.gridy = 3; mainPanel.add(advancedPanel, c); archiveButton = new JButton(resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON")); archiveButton.addActionListener(this); c = new GridBagConstraints(); c.anchor = GridBagConstraints.LINE_START; c.weightx = 0; c.gridx = 0; c.gridy = 4; mainPanel.add(archiveButton, c); if (!StringUtils.isNullOrEmpty(getUploadLocation())) { uploadLogsButton = new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON")); uploadLogsButton.addActionListener(this); c.insets = new Insets(10, 0, 0, 0); c.gridy = 5; mainPanel.add(uploadLogsButton, c); } }
protected void initComponents( AirspaceBuilderModel model, final AirspaceBuilderController controller) { final JCheckBox resizeNewShapesCheckBox; final JCheckBox enableEditCheckBox; JPanel newShapePanel = new JPanel(); { JButton newShapeButton = new JButton("New shape"); newShapeButton.setActionCommand(NEW_AIRSPACE); newShapeButton.addActionListener(controller); newShapeButton.setToolTipText("Create a new shape centered in the viewport"); this.factoryComboBox = new JComboBox(defaultAirspaceFactories); this.factoryComboBox.setEditable(false); this.factoryComboBox.setToolTipText("Choose shape type to create"); resizeNewShapesCheckBox = new JCheckBox("Fit new shapes to viewport"); resizeNewShapesCheckBox.setActionCommand(SIZE_NEW_SHAPES_TO_VIEWPORT); resizeNewShapesCheckBox.addActionListener(controller); resizeNewShapesCheckBox.setSelected(controller.isResizeNewShapesToViewport()); resizeNewShapesCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); resizeNewShapesCheckBox.setToolTipText( "New shapes are sized to fit the geographic viewport"); enableEditCheckBox = new JCheckBox("Enable shape editing"); enableEditCheckBox.setActionCommand(ENABLE_EDIT); enableEditCheckBox.addActionListener(controller); enableEditCheckBox.setSelected(controller.isEnableEdit()); enableEditCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); enableEditCheckBox.setToolTipText("Allow modifications to shapes"); Box newShapeBox = Box.createHorizontalBox(); newShapeBox.add(newShapeButton); newShapeBox.add(Box.createHorizontalStrut(5)); newShapeBox.add(this.factoryComboBox); newShapeBox.setAlignmentX(Component.LEFT_ALIGNMENT); JPanel gridPanel = new JPanel(new GridLayout(0, 1, 0, 5)); // rows, cols, hgap, vgap gridPanel.add(newShapeBox); gridPanel.add(resizeNewShapesCheckBox); gridPanel.add(enableEditCheckBox); newShapePanel.setLayout(new BorderLayout()); newShapePanel.add(gridPanel, BorderLayout.NORTH); } JPanel entryPanel = new JPanel(); { this.entryTable = new JTable(model); this.entryTable.setColumnSelectionAllowed(false); this.entryTable.setRowSelectionAllowed(true); this.entryTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); this.entryTable .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!ignoreSelectEvents) { controller.actionPerformed( new ActionEvent(e.getSource(), -1, SELECTION_CHANGED)); } } }); this.entryTable.setToolTipText("<html>Click to select<br>Double-Click to rename</html>"); JScrollPane tablePane = new JScrollPane(this.entryTable); tablePane.setPreferredSize(new Dimension(200, 100)); entryPanel.setLayout(new BorderLayout(0, 0)); // hgap, vgap entryPanel.add(tablePane, BorderLayout.CENTER); } JPanel selectionPanel = new JPanel(); { JButton delselectButton = new JButton("Deselect"); delselectButton.setActionCommand(CLEAR_SELECTION); delselectButton.addActionListener(controller); delselectButton.setToolTipText("Clear the selection"); JButton deleteButton = new JButton("Delete Selected"); deleteButton.setActionCommand(REMOVE_SELECTED); deleteButton.addActionListener(controller); deleteButton.setToolTipText("Delete selected shapes"); JPanel gridPanel = new JPanel(new GridLayout(0, 1, 0, 5)); // rows, cols, hgap, vgap gridPanel.add(delselectButton); gridPanel.add(deleteButton); selectionPanel.setLayout(new BorderLayout()); selectionPanel.add(gridPanel, BorderLayout.NORTH); } this.setLayout(new BorderLayout(30, 0)); // hgap, vgap this.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); // top, left, bottom, right this.add(newShapePanel, BorderLayout.WEST); this.add(entryPanel, BorderLayout.CENTER); this.add(selectionPanel, BorderLayout.EAST); controller.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals(e.getPropertyName())) { resizeNewShapesCheckBox.setSelected(controller.isResizeNewShapesToViewport()); } else if (ENABLE_EDIT.equals(e.getPropertyName())) { enableEditCheckBox.setSelected(controller.isEnableEdit()); } } }); }
protected void JogMotors() { JDialog driver = new JDialog(mainframe, "Jog Motors", true); driver.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); final JButton buttonAneg = new JButton("IN"); final JButton buttonApos = new JButton("OUT"); final JCheckBox m1i = new JCheckBox("Invert", m1invert); final JButton buttonBneg = new JButton("IN"); final JButton buttonBpos = new JButton("OUT"); final JCheckBox m2i = new JCheckBox("Invert", m2invert); c.gridx = 0; c.gridy = 0; driver.add(new JLabel("L"), c); c.gridx = 0; c.gridy = 1; driver.add(new JLabel("R"), c); c.gridx = 1; c.gridy = 0; driver.add(buttonAneg, c); c.gridx = 1; c.gridy = 1; driver.add(buttonBneg, c); c.gridx = 2; c.gridy = 0; driver.add(buttonApos, c); c.gridx = 2; c.gridy = 1; driver.add(buttonBpos, c); c.gridx = 3; c.gridy = 0; driver.add(m1i, c); c.gridx = 3; c.gridy = 1; driver.add(m2i, c); ActionListener driveButtons = new ActionListener() { public void actionPerformed(ActionEvent e) { Object subject = e.getSource(); if (subject == buttonApos) SendLineToRobot("D00 L100"); if (subject == buttonAneg) SendLineToRobot("D00 L-100"); if (subject == buttonBpos) SendLineToRobot("D00 R100"); if (subject == buttonBneg) SendLineToRobot("D00 R-100"); SendLineToRobot("M114"); } }; ActionListener invertButtons = new ActionListener() { public void actionPerformed(ActionEvent e) { m1invert = m1i.isSelected(); m2invert = m2i.isSelected(); SaveConfig(); SendConfig(); } }; buttonApos.addActionListener(driveButtons); buttonAneg.addActionListener(driveButtons); buttonBpos.addActionListener(driveButtons); buttonBneg.addActionListener(driveButtons); m1i.addActionListener(invertButtons); m2i.addActionListener(invertButtons); SendLineToRobot("M114"); driver.pack(); driver.setVisible(true); }