List of usage examples for javax.swing DefaultListCellRenderer DefaultListCellRenderer
public DefaultListCellRenderer()
From source file:bigdata.explorer.nutch.grapview.ShowLayouts.java
private static JPanel getGraphPanel() throws IOException { g_array = (Graph<? extends Object, ? extends Object>[]) new Graph<?, ?>[graph_names.length]; Factory<Graph<Integer, Number>> graphFactory = new Factory<Graph<Integer, Number>>() { public Graph<Integer, Number> create() { return new SparseMultigraph<Integer, Number>(); }//from ww w. j a v a 2s.c o m }; Factory<Integer> vertexFactory = new Factory<Integer>() { int count; public Integer create() { return count++; } }; Factory<Number> edgeFactory = new Factory<Number>() { int count; public Number create() { return count++; } }; g_array[0] = TestGraphs.createTestGraph(false); g_array[1] = MixedRandomGraphGenerator.generateMixedRandomGraph(graphFactory, vertexFactory, edgeFactory, new HashMap<Number, Number>(), 20, true, new HashSet<Integer>()); g_array[2] = TestGraphs.getDemoGraph(); g_array[3] = TestGraphs.createDirectedAcyclicGraph(4, 4, 0.3); g_array[4] = TestGraphs.getOneComponentGraph(); g_array[5] = TestGraphs.createChainPlusIsolates(18, 5); g_array[6] = TestGraphs.createChainPlusIsolates(0, 20); g_array[7] = NutchGraphLoader.loadFullGraph("/home/kamir/ANALYSIS/Nutch/YellowMED_CORE"); Graph<? extends Object, ? extends Object> g = g_array[4]; // initial graph final VisualizationViewer<Integer, Number> vv = new VisualizationViewer<Integer, Number>(new FRLayout(g)); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow)); final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>(); vv.setGraphMouse(graphMouse); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JButton reset = new JButton("reset"); reset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Layout<Integer, Number> layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { // if(layout instanceof IterativeContext) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(((DefaultModalGraphMouse<Integer, Number>) vv.getGraphMouse()).getModeListener()); JPanel jp = new JPanel(); jp.setBackground(Color.WHITE); jp.setLayout(new BorderLayout()); jp.add(vv, BorderLayout.CENTER); Class[] combos = getCombos(); final JComboBox jcb = new JComboBox(combos); // use a renderer to shorten the layout name presentation jcb.setRenderer(new DefaultListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String valueString = value.toString(); valueString = valueString.substring(valueString.lastIndexOf('.') + 1); return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus); } }); jcb.addActionListener(new LayoutChooser(jcb, vv)); jcb.setSelectedItem(FRLayout.class); JPanel control_panel = new JPanel(new GridLayout(2, 1)); JPanel topControls = new JPanel(); JPanel bottomControls = new JPanel(); control_panel.add(topControls); control_panel.add(bottomControls); jp.add(control_panel, BorderLayout.NORTH); final JComboBox graph_chooser = new JComboBox(graph_names); graph_chooser.addActionListener(new GraphChooser(jcb)); topControls.add(jcb); topControls.add(graph_chooser); bottomControls.add(plus); bottomControls.add(minus); bottomControls.add(modeBox); bottomControls.add(reset); return jp; }
From source file:ca.sqlpower.wabit.swingui.enterprise.UserPanel.java
public UserPanel(User baseUser) { final MessageDigest digester; try {//from w ww .j a v a2s . c om digester = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e1) { throw new RuntimeException(e1); } this.user = baseUser; this.workspace = (WabitWorkspace) this.user.getParent(); this.loginTextField = new JTextField(); this.loginTextField.setText(user.getName()); this.loginLabel = new JLabel("User name"); this.loginTextField.getDocument().addDocumentListener(new DocumentListener() { public void textChanged(DocumentEvent e) { user.setName(loginTextField.getText()); } public void changedUpdate(DocumentEvent e) { textChanged(e); } public void insertUpdate(DocumentEvent e) { textChanged(e); } public void removeUpdate(DocumentEvent e) { textChanged(e); } }); this.passwordTextField = new JPasswordField(); this.passwordLabel = new JLabel("Password"); this.passwordTextField.getDocument().addDocumentListener(new DocumentListener() { public void textChanged(DocumentEvent e) { try { String pass = new String(passwordTextField.getPassword()); String encoded = new String(Hex.encodeHex(digester.digest(pass.getBytes("UTF-8")))); user.setPassword(encoded); } catch (UnsupportedEncodingException e1) { throw new RuntimeException(e1); } } public void changedUpdate(DocumentEvent e) { textChanged(e); } public void insertUpdate(DocumentEvent e) { textChanged(e); } public void removeUpdate(DocumentEvent e) { textChanged(e); } }); this.fullNameTextField = new JTextField(); this.fullNameTextField.setText(user.getFullName()); this.fullNameLabel = new JLabel("Full name"); this.fullNameTextField.getDocument().addDocumentListener(new DocumentListener() { public void textChanged(DocumentEvent e) { user.setFullName(fullNameTextField.getText()); } public void changedUpdate(DocumentEvent e) { textChanged(e); } public void insertUpdate(DocumentEvent e) { textChanged(e); } public void removeUpdate(DocumentEvent e) { textChanged(e); } }); this.emailTextField = new JTextField(); this.emailTextField.setText(user.getEmail()); this.emailLabel = new JLabel("Email"); this.emailTextField.getDocument().addDocumentListener(new DocumentListener() { public void textChanged(DocumentEvent e) { user.setEmail(emailTextField.getText()); } public void changedUpdate(DocumentEvent e) { textChanged(e); } public void insertUpdate(DocumentEvent e) { textChanged(e); } public void removeUpdate(DocumentEvent e) { textChanged(e); } }); this.availableGroupsLabel = new JLabel("Available Groups"); this.availableGroupsListModel = new GroupsListModel(user, workspace, false); this.availableGroupsList = new JList(this.availableGroupsListModel); this.availableGroupsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); this.availableGroupsList.setCellRenderer(new DefaultListCellRenderer() { final JTree dummyTree = new JTree(); final WorkspaceTreeCellRenderer delegate = new WorkspaceTreeCellRenderer(); @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return delegate.getTreeCellRendererComponent(dummyTree, value, isSelected, false, true, 0, cellHasFocus); } }); this.availableGroupsScrollPane = new JScrollPane(this.availableGroupsList); this.currentGroupsLabel = new JLabel("Current Memberships"); this.currentGroupsListModel = new GroupsListModel(user, workspace, true); this.currentGroupsList = new JList(this.currentGroupsListModel); this.currentGroupsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); this.currentGroupsList.setCellRenderer(new DefaultListCellRenderer() { final JTree dummyTree = new JTree(); final WorkspaceTreeCellRenderer delegate = new WorkspaceTreeCellRenderer(); @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return delegate.getTreeCellRendererComponent(dummyTree, value, isSelected, false, true, 0, cellHasFocus); } }); this.groupsLabel = new JLabel("Edit user memberships"); this.currentGroupsScrollPane = new JScrollPane(this.currentGroupsList); this.addButton = new JButton(">"); this.addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object[] selection = availableGroupsList.getSelectedValues(); if (selection.length == 0) { return; } try { workspace.begin("Add user to groups"); for (Object object : selection) { ((Group) object).addMember(new GroupMember(user)); } } finally { workspace.commit(); } } }); this.removeButton = new JButton("<"); this.removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object[] selection = currentGroupsList.getSelectedValues(); if (selection.length == 0) { return; } try { workspace.begin("Remove user from groups"); Map<Group, GroupMember> toRemove = new ArrayMap<Group, GroupMember>(); for (Object object : selection) { for (GroupMember membership : ((Group) object).getChildren(GroupMember.class)) { if (membership.getUser().getUUID().equals(user.getUUID())) { toRemove.put((Group) object, membership); } } } for (Entry<Group, GroupMember> entry : toRemove.entrySet()) { entry.getKey().removeMember(entry.getValue()); } } finally { workspace.commit(); } } }); Action deleteAction = new DeleteFromTreeAction(this.workspace, this.user, this.panel, this.workspace.getSession().getContext()); this.toolbarBuilder.add(deleteAction, "Delete this user", WabitIcons.DELETE_ICON_32); // Panel building time JPanel namePassPanel = new JPanel(new MigLayout()); namePassPanel.add(this.loginLabel, "align right, gaptop 20"); namePassPanel.add(this.loginTextField, "span, wrap, wmin 600"); namePassPanel.add(this.passwordLabel, "align right"); namePassPanel.add(this.passwordTextField, "span, wrap, wmin 600"); namePassPanel.add(this.fullNameLabel, "align right, gaptop 20"); namePassPanel.add(this.fullNameTextField, "span, wrap, wmin 600"); namePassPanel.add(this.emailLabel, "align right"); namePassPanel.add(this.emailTextField, "span, wrap, wmin 600"); this.panel.add(namePassPanel, "north"); this.panel.add(this.groupsLabel, "span, wrap, gaptop 20, align center"); JPanel buttonsPanel = new JPanel(new MigLayout()); buttonsPanel.add(this.addButton, "wrap"); buttonsPanel.add(this.removeButton); JPanel availablePanel = new JPanel(new MigLayout()); availablePanel.add(this.availableGroupsLabel, "wrap, align center"); availablePanel.add(this.availableGroupsScrollPane, "wmin 300"); JPanel currentPanel = new JPanel(new MigLayout()); currentPanel.add(this.currentGroupsLabel, "wrap, align center"); currentPanel.add(this.currentGroupsScrollPane, "wmin 300"); this.panel.add(availablePanel); this.panel.add(buttonsPanel, "shrink, span 1 2"); this.panel.add(currentPanel); }
From source file:org.esa.beam.visat.toolviews.stat.DensityPlotPanel.java
private void initParameters() { axisRangeControls[X_VAR] = new AxisRangeControl("X-Axis"); axisRangeControls[Y_VAR] = new AxisRangeControl("Y-Axis"); initColorModels();//from ww w . j av a2s .co m plotColorsInverted = false; dataSourceConfig = new DataSourceConfig(); bindingContext = new BindingContext(PropertyContainer.createObjectBacked(dataSourceConfig)); xBandList = new JComboBox<>(); xBandList.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { this.setText(((RasterDataNode) value).getName()); } return this; } }); bindingContext.bind(PROPERTY_NAME_X_BAND, xBandList); xBandProperty = bindingContext.getPropertySet().getProperty(PROPERTY_NAME_X_BAND); yBandList = new JComboBox<>(); yBandList.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { this.setText(((RasterDataNode) value).getName()); } return this; } }); bindingContext.bind(PROPERTY_NAME_Y_BAND, yBandList); yBandProperty = bindingContext.getPropertySet().getProperty(PROPERTY_NAME_Y_BAND); }
From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java
public Jmetrik() { super("jMetrik"); setPreferredSize(new Dimension(1024, 650)); setDefaultCloseOperation(EXIT_ON_CLOSE); //properly close database if user closes window this.addWindowListener(new WindowAdapter() { @Override/* w w w . j av a2s . c om*/ public void windowClosing(WindowEvent we) { if (workspace != null) { workspace.closeDatabase(); } System.exit(0); } }); //add statusbar statusBar = new StatusBar(1024, 30); statusBar.setBorder(new EmptyBorder(2, 2, 2, 2)); getContentPane().add(statusBar, BorderLayout.SOUTH); //start logging startLog(); //left-right splitpane JSplitPane splitPane1 = new JSplitPane(); splitPane1.setDividerLocation(200); //setup workspace list workspaceList = new JList(); workspaceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); workspaceList.setModel(new SortedListModel<DataTableName>()); workspaceList.addKeyListener(new DeleteKeyListener()); // workspaceList.getInsets().set(5, 5, 5, 5); //add icon to list cell renderer String urlString = "/images/spreadsheet.png"; URL url = this.getClass().getResource(urlString); final ImageIcon tableIcon = new ImageIcon(url, "Table"); workspaceList.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); label.setIcon(tableIcon); return label; } }); JScrollPane scrollPane1 = new JScrollPane(workspaceList); scrollPane1.setPreferredSize(new Dimension(200, 698)); splitPane1.setLeftComponent(scrollPane1); //tabbed pane for top pane tabbedPane = new JTabbedPane(); tabbedPane.setTabPlacement(JTabbedPane.BOTTOM); //setup data table dataTable = new DataTable(); dataTable.setRowHeight(18); //change size of table header and center text JTableHeader header = dataTable.getTableHeader(); header.setDefaultRenderer(new TableHeaderCellRenderer()); JScrollPane dataScrollPane = new JScrollPane(dataTable); tabbedPane.addTab("Data", dataScrollPane); //setup variable table variableTable = new DataTable(); variableTable.setRowHeight(18); variableTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); if (e.getClickCount() == 2) { JTable target = (JTable) e.getSource(); int row = target.getSelectedRow(); int col = target.getSelectedColumn(); if (col == 0) { if (target.getModel() instanceof VariableModel) { VariableModel vModel = (VariableModel) target.getModel(); String s = (String) vModel.getValueAt(row, col); DatabaseName db = workspace.getDatabaseName(); DataTableName table = workspace.getCurrentDataTable(); RenameVariableDialog renameVariableDialog = new RenameVariableDialog(Jmetrik.this, db, table, s); renameVariableDialog.setVisible(true); if (renameVariableDialog.canRun()) { RenameVariableCommand command = renameVariableDialog.getCommand(); workspace.runProcess(command); } } //end instanceof } //end if col==0 } //end if click count==2 }//end mouse clicked }); //change size of table header and center text JTableHeader variableHeader = variableTable.getTableHeader(); variableHeader.setDefaultRenderer(new TableHeaderCellRenderer()); variableHeader.setPreferredSize(new Dimension(30, 21)); JScrollPane variableScrollPane = new JScrollPane(variableTable); tabbedPane.addTab("Variables", variableScrollPane); splitPane1.setRightComponent(tabbedPane); getContentPane().add(splitPane1, BorderLayout.CENTER); //add status bar listener - needed to display status message that are generated within this class this.addPropertyChangeListener(statusBar.getStatusListener()); //add listener for displaying error messages - needed to display errors and exceptions this.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); //instantiate file utilities fileUtils = new JmetrikFileUtils(); fileUtils.addPropertyChangeListener(statusBar.getStatusListener()); //set import and export path to user's documents folder JFileChooser chooser = new JFileChooser(); FileSystemView fw = chooser.getFileSystemView(); importExportPath = fw.getDefaultDirectory().toString().replaceAll("\\\\", "/"); //create and start a workspace startWorkspace(); //create menu bar and tool bar this.setJMenuBar(createMenuBar()); JToolBar toolBar = createToolBar(); toolBar.setFloatable(false); toolBar.setRollover(true); getContentPane().add(toolBar, BorderLayout.PAGE_START); pack(); }
From source file:com.microsoft.alm.plugin.idea.git.ui.pullrequest.CreatePullRequestForm.java
private void createUIComponents() { this.targetBranchDropdown = new JComboBox(); this.targetBranchDropdown.setRenderer(new DefaultListCellRenderer() { @Override/*from w ww. j av a 2 s.c o m*/ public Component getListCellRendererComponent(JList list, Object gitRemoteBranch, int index, boolean isSelected, boolean cellHasFocus) { return super.getListCellRendererComponent(list, gitRemoteBranch != null ? ((GitRemoteBranch) gitRemoteBranch).getName() : "", index, isSelected, cellHasFocus); } }); this.targetBranchDropdown.setActionCommand(CMD_TARGET_BRANCH_UPDATED); }
From source file:com.jhash.oimadmin.ui.EventHandlerUI.java
@Override public void initializeComponent() { logger.debug("Initializing {} ...", this); javaCompiler = new UIJavaCompile("Source Code", "EventHandlerSource", configuration, selectionTree, displayArea);/* w w w .ja v a 2 s . c o m*/ javaCompiler.initialize(); nameField.setText("CustomEventHandler"); nameField.setToolTipText("Name of event handler"); orcTargetLabel.setToolTipText( "type of orchestration, such as Entity, MDS, Relation, Toplink orchestration.\n The default value is oracle.iam.platform.kernel.vo.EntityOrchestration. This is the only supported type for writing custom event handlers"); syncCheckBox.setToolTipText( "If set to TRUE (synchronous), then the kernel expects the event handler to return an EventResult.\n If set to FALSE (asynchronous), then you must return null as the event result and notify the kernel about the event result later."); txCheckBox.setToolTipText( "The tx attribute indicates whether or not the event handler should run in its own transaction.\n Supported values are TRUE or FALSE. By default, the value is FALSE."); classNameText.setText("com.jhash.oim.eventhandler.CustomEventHandler"); classNameText.setToolTipText("Full package name of the Java class that implements the event handler"); classNameText.getDocument().addDocumentListener( new UIJavaCompile.ConnectTextFieldListener(classNameText, javaCompiler.classNameText)); orderField.setToolTipText( "Identifies the order (or sequence) in which the event handler is executed.\n Order value is in the scope of entity, operation, and stage. Order value for each event handler in this scope must be unique. If there is a conflict, then the order in which these conflicted event handlers are executed is arbitrary." + "\nSupported values are FIRST (same as Integer.MIN_VALUE), LAST (same as Integer.MAX_VALUE), or a numeral."); final Set<String> entityNames = new HashSet<String>(); entityNames.addAll(OIMJMXWrapper.OperationDetail.getOperationDetails(connection).keySet()); entityNames.add("ANY"); String[] entityNamesArray = entityNames.toArray(new String[0]); entityType.setModel(new DefaultComboBoxModel<String>(entityNamesArray)); entityType.setToolTipText( "Identifies the type of entity the event handler is executed on. A value of ANY sets the event handler to execute on any entity."); operationType.setToolTipText( "Identifies the type of operation the event handler is executed on. A value of ANY sets the event handler to execute on any operation."); entityType.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String entityTypeSelected = (String) entityType.getSelectedItem(); if (entityTypeSelected != null && entityNames.contains(entityTypeSelected)) { try { Set<String> operations = null; Map<String, Set<String>> operationDetails = OIMJMXWrapper.OperationDetail .getOperationDetails(connection); if (operationDetails.containsKey(entityTypeSelected)) { operations = operationDetails.get(entityTypeSelected); } else { operations = new HashSet<String>(); } operations.add("ANY"); operationType.setModel(new DefaultComboBoxModel<String>(operations.toArray(new String[0]))); } catch (Exception exception) { displayMessage("Entity Type selection failed", "Failed to load operation details associated with " + entityTypeSelected, exception); } } else { logger.trace("Nothing to do since the selected entity type {} is not recognized", entityTypeSelected); } } }); eventHandlerTypes.setRenderer(new DefaultListCellRenderer() { private static final long serialVersionUID = 1L; @Override public JComponent getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JComponent comp = (JComponent) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (index >= 0 && index < EVENT_HANDLER_TYPES_TOOL_TIPS.length) { list.setToolTipText(EVENT_HANDLER_TYPES_TOOL_TIPS[index]); } else { list.setToolTipText(""); } return comp; } }); eventHandlerTypes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String selectedValue; if ((selectedValue = (String) eventHandlerTypes.getSelectedItem()) != null && (!selectedValue.isEmpty())) { if (selectedValue.equals("action-handler") || selectedValue.equals("change-failed")) { syncCheckBox.setEnabled(true); } else { syncCheckBox.setEnabled(false); syncCheckBox.setSelected(false); } if (selectedValue.equals("validation-handler")) { syncCheckBox.setSelected(true); } if (Arrays.asList(new String[] { "out-of-band-handler", "action-handler", "compensate-handler", "finalization-handler" }).contains(selectedValue)) { txCheckBox.setEnabled(true); } else { txCheckBox.setEnabled(false); txCheckBox.setSelected(false); } if (Arrays.asList(new String[] { "out-of-band-handler", "action-handler", "failed-handler" }) .contains(selectedValue)) { stageComboBox.setEnabled(true); } else { stageComboBox.setEnabled(false); stageComboBox.setSelectedItem(""); } } else { logger.trace("Nothing to do since {} item has been selected", selectedValue); } } }); entityType.setSelectedItem(entityNamesArray[0]); // TODO: Is this needed? // operationType.setSelectedItem(associatedOperationSplitDetails[1]); eventHandlerTypes.setSelectedItem(EVENT_HANDLER_TYPES[0]); javaCompiler.classNameText.setText(classNameText.getText()); configurationPanel = new EventHandlerConfigurationPanel("Configure"); configurationPanel.initialize(); packagePanel = new EventHandlerPackagePanel("Package"); packagePanel.initialize(); eventHandlerUI = buildEventHandlerUI(); logger.debug("Initialized {}", this); }
From source file:CSSDFarm.UserInterface.java
/** * Displays the report screen/* w w w . j ava2s .c om*/ */ public void displayReportScreen() { //Enable and disable the report UI components loadData = false; panelManager.setVisible(false); panelReport.setVisible(true); dpReportCalendar.getEditor().setEditable(false); comboReportSensorType.setLightWeightPopupEnabled(false); dpReportCalendar.setLightWeightPopupEnabled(false); //Load user data from the server userFieldStations = server.loadData(); comboReportFieldStations.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof FieldStation) { FieldStation station = (FieldStation) value; setText(station.getName()); } return this; } }); //Add users fieldstations to the combobox for (FieldStation station : userFieldStations) { comboReportFieldStations.addItem(station); } Date date = new Date(); dpReportCalendar.setDate(date); //Load the users last selected values int pos = loadUserData("data/userData.ser"); try { comboReportFieldStations.setSelectedIndex(pos); } catch (Exception eX) { } updateReport(); }
From source file:de.codesourcery.eve.skills.ui.components.impl.planning.CalendarEntryEditorComponent.java
@Override protected JPanel createPanelHook() { startDateField.setText(format(startDate)); startDateField.setEditable(false);//from w w w. j a va2 s . c o m startDateField.setColumns(13); durationTextField.setColumns(13); notes.setLineWrap(true); notes.setWrapStyleWord(true); durationTextField.setColumns(6); summaryTextField.addActionListener(closeOnEnterListener); durationTextField.addActionListener(closeOnEnterListener); reminderOffsetTextField.addActionListener(closeOnEnterListener); final DefaultListCellRenderer durationTypeRenderer = new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); setText(((Duration.Type) value).getDisplayName()); return this; } }; durationType.setRenderer(durationTypeRenderer); reminderOffsetType.setRenderer(durationTypeRenderer); durationType.setSelectedItem(Duration.Type.DAYS); reminderOffsetType.setSelectedItem(Duration.Type.DAYS); reminderEnabled.setEnabled(true); reminderOffsetTextField.setEnabled(false); reminderOffsetType.setEnabled(false); linkComponentEnabledStates(reminderEnabled, reminderOffsetTextField, reminderOffsetType); // do layout final JPanel result = new JPanel(); result.setLayout(new GridBagLayout()); new GridLayoutBuilder().add(new VerticalGroup( new HorizontalGroup(new Cell(new JLabel("Start date")), new Cell(startDateField)), new HorizontalGroup(new Cell(new JLabel("Summary")), new Cell(summaryTextField)), new HorizontalGroup( new Cell(new JLabel("Duration")), new Cell(durationTextField), new Cell(durationType)), new HorizontalGroup(new Cell(reminderEnabled)), new HorizontalGroup(new Cell(new JLabel("Reminder offset")), new Cell(reminderOffsetTextField), new Cell(reminderOffsetType)), new HorizontalGroup(new Cell(new JScrollPane(notes))))).addTo(result); return result; }
From source file:au.org.ala.delta.editor.ui.ImageDetailsPanel.java
private void createUI() { JPanel panel = new JPanel(); JPanel buttonPanel = new JPanel(); JPanel panel_2 = new JPanel(); GroupLayout groupLayout = new GroupLayout(this); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addComponent(panel, GroupLayout.PREFERRED_SIZE, 262, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(buttonPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_2, GroupLayout.PREFERRED_SIZE, 265, Short.MAX_VALUE) .addContainerGap())); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addComponent(panel, GroupLayout.DEFAULT_SIZE, 238, Short.MAX_VALUE) .addComponent(buttonPanel, 0, 0, Short.MAX_VALUE) .addComponent(panel_2, 0, 0, Short.MAX_VALUE)) .addContainerGap())); btnSettings = new JButton(); btnDisplay = new JButton(); btnAdd = new JButton(); btnDelete = new JButton(); GroupLayout gl_buttonPanel = new GroupLayout(buttonPanel); gl_buttonPanel.setHorizontalGroup(gl_buttonPanel.createParallelGroup(Alignment.TRAILING).addGroup( Alignment.LEADING,/*from ww w . j a va 2 s .co m*/ gl_buttonPanel.createSequentialGroup().addContainerGap().addGroup(gl_buttonPanel .createParallelGroup(Alignment.LEADING) .addComponent(btnSettings, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnDisplay, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE) .addComponent(btnAdd, GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE) .addComponent(btnDelete, GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)) .addContainerGap())); gl_buttonPanel.setVerticalGroup(gl_buttonPanel.createParallelGroup(Alignment.TRAILING) .addGroup(gl_buttonPanel.createSequentialGroup().addContainerGap(119, Short.MAX_VALUE) .addComponent(btnSettings).addPreferredGap(ComponentPlacement.RELATED) .addComponent(btnDisplay).addPreferredGap(ComponentPlacement.RELATED).addComponent(btnAdd) .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnDelete).addContainerGap())); buttonPanel.setLayout(gl_buttonPanel); JLabel lblSubjectText = new JLabel(); lblSubjectText.setName("imageDetailsSubjectLabel"); JScrollPane scrollPane_1 = new JScrollPane(); JLabel lblDevelopersNotes = new JLabel(); lblDevelopersNotes.setName("imageDetailsDevelopersNotesLabel"); JScrollPane scrollPane_2 = new JScrollPane(); JPanel panel_3 = new JPanel(); String title = _resources.getString("imageDetailsSoundTitle"); panel_3.setBorder(new TitledBorder(null, title, TitledBorder.LEADING, TitledBorder.TOP, null, null)); GroupLayout gl_panel_2 = new GroupLayout(panel_2); gl_panel_2.setHorizontalGroup(gl_panel_2.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_2.createSequentialGroup().addContainerGap() .addGroup(gl_panel_2.createParallelGroup(Alignment.LEADING) .addComponent(scrollPane_2, GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE) .addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE) .addComponent(lblDevelopersNotes) .addComponent(panel_3, GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE) .addComponent(lblSubjectText)) .addContainerGap())); gl_panel_2.setVerticalGroup(gl_panel_2.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_2.createSequentialGroup().addContainerGap().addComponent(lblSubjectText) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 41, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblDevelopersNotes) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(scrollPane_2, GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_3, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE) .addContainerGap())); developerNotesTextPane = new RtfEditorPane(); scrollPane_2.setViewportView(developerNotesTextPane); subjectTextPane = new RtfEditorPane(); scrollPane_1.setViewportView(subjectTextPane); soundComboBox = new JComboBox(); soundComboBox.setRenderer(new DefaultListCellRenderer() { private static final long serialVersionUID = 1L; @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String text = ""; ImageOverlay overlay = (ImageOverlay) value; if (overlay != null) { text = overlay.overlayText; } super.getListCellRendererComponent(list, text, index, isSelected, cellHasFocus); return this; } }); deleteSoundButton = new JButton(); playSoundButton = new JButton(); insertSoundButton = new JButton(); GroupLayout gl_panel_3 = new GroupLayout(panel_3); gl_panel_3.setHorizontalGroup(gl_panel_3.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_3.createSequentialGroup().addComponent(soundComboBox, 0, 0, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(deleteSoundButton) .addPreferredGap(ComponentPlacement.RELATED).addComponent(playSoundButton) .addPreferredGap(ComponentPlacement.RELATED).addComponent(insertSoundButton) .addContainerGap())); gl_panel_3.setVerticalGroup(gl_panel_3.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_3.createSequentialGroup().addContainerGap(5, Short.MAX_VALUE) .addGroup(gl_panel_3.createParallelGroup(Alignment.BASELINE) .addComponent(soundComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(deleteSoundButton).addComponent(playSoundButton) .addComponent(insertSoundButton)))); panel_3.setLayout(gl_panel_3); panel_2.setLayout(gl_panel_2); JLabel lblImageFiles = new JLabel(); lblImageFiles.setName("imageDetailsImageFilesLabel"); lblImageFiles.setAlignmentY(Component.TOP_ALIGNMENT); JScrollPane scrollPane = new JScrollPane(); GroupLayout gl_panel = new GroupLayout(panel); gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel.createSequentialGroup() .addGroup(gl_panel.createParallelGroup(Alignment.LEADING).addComponent(lblImageFiles) .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)) .addContainerGap())); gl_panel.setVerticalGroup(gl_panel.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel.createSequentialGroup().addContainerGap().addComponent(lblImageFiles) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE) .addContainerGap())); imageList = new ImageList(); scrollPane.setViewportView(imageList); panel.setLayout(gl_panel); setLayout(groupLayout); }
From source file:net.sf.nmedit.nomad.core.Nomad.java
public void export() { Document doc = getDocumentManager().getSelection(); if (!(doc instanceof Transferable)) return;/*from w w w .jav a 2 s . c o m*/ Transferable transferable = (Transferable) doc; String title = doc.getTitle(); if (title == null) title = "Export"; else title = "Export '" + title + "'"; JComboBox src = new JComboBox(transferable.getTransferDataFlavors()); src.setRenderer(new DefaultListCellRenderer() { /** * */ private static final long serialVersionUID = -4553255745845039428L; public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String text; if (value instanceof DataFlavor) { DataFlavor flavor = (DataFlavor) value; String mimeType = flavor.getMimeType(); String humanRep = flavor.getHumanPresentableName(); String charset = flavor.getParameter("charset"); if (mimeType == null) text = "?"; else { text = mimeType; int ix = text.indexOf(';'); if (ix >= 0) text = text.substring(0, ix).trim(); } if (charset != null) text += "; charset=" + charset; if (humanRep != null) text += " (" + humanRep + ")"; } else { text = String.valueOf(value); } return super.getListCellRendererComponent(list, text, index, isSelected, cellHasFocus); } }); JComboBox dst = new JComboBox(new Object[] { "File", "Clipboard" }); Object[] msg = { "Source:", doc.getTitle(), "Export as:", src, "Export to:", dst }; Object[] options = { "Ok", "Cancel" }; JOptionPane op = new JOptionPane(msg, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options); JDialog dialog = op.createDialog(getWindow(), title); dialog.setModal(true); dialog.setVisible(true); boolean ok = "Ok".equals(op.getValue()); DataFlavor flavor = (DataFlavor) src.getSelectedItem(); dialog.dispose(); if (!ok) return; if (flavor == null) return; if ("Clipboard".equals(dst.getSelectedItem())) { Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); cb.setContents(new SelectedTransfer(flavor, transferable), null); } else { export(transferable, flavor); } }