com.alee.laf.text.WebTextField Java Examples
The following examples show how to use
com.alee.laf.text.WebTextField.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InstructionEditorPanel.java From Cafebabe with GNU General Public License v3.0 | 6 votes |
private JPanel createInOutDescEditor(InstructionList il, AbstractInsnNode ain, Field f, Object value) { String[] descArgs = ((String) value).split("\\)"); WebTextField argsField = new WebTextField(Descriptors.getDisplayTypeEditable(descArgs[0].substring(1))); argsField.setMaximumWidth(maxWidth / 2); WebTextField retField = new WebTextField(Descriptors.getDisplayTypeEditable(descArgs[1])); retField.setMinimumWidth(maxWidth / 2); ChangeListener l = (c -> { StringBuilder desc = new StringBuilder(); String args = argsField.getText().replace(" ", ""); // spaces don't matter String[] arg = args.split(","); desc.append("("); for (int i = 0; i < arg.length; i++) desc.append(Descriptors.displayTypeToDesc(arg[i])); desc.append(")"); desc.append(Descriptors.displayTypeToDesc(retField.getText().trim())); setField(f, ain, desc.toString()); il.repaint(); }); Listeners.addChangeListener(argsField, l); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(argsField, BorderLayout.CENTER); panel.add(retField, BorderLayout.EAST); return panel; }
Example #2
Source File: GroupPaneExample.java From weblaf with GNU General Public License v3.0 | 6 votes |
@NotNull @Override protected List<? extends JComponent> createPreviewElements () { // First row final WebComboBox e1 = new WebComboBox ( new String[]{ "First", "Second", "Third" } ); final WebButton e2 = new WebButton ( "Second" ); final WebTextField e3 = new WebTextField ( "Third" ); // Second row final WebPanel e4 = new WebPanel ( StyleId.panelDecorated, new WebLabel ( "First", WebLabel.CENTER ) ); final WebTextField e5 = new WebTextField ( "Second" ); final WebButton e6 = new WebButton ( "Third" ); // Third row final WebSpinner e7 = new WebSpinner ( new SpinnerNumberModel ( 100, 0, 100, 1 ) ); final WebButton e8 = new WebButton ( "Second" ); final WebPasswordField e9 = new WebPasswordField ( "Third" ); final GroupPane groupPane = new GroupPane ( getStyleId (), 3, 3, e1, e2, e3, e4, e5, e6, e7, e8, e9 ); SwingUtils.equalizeComponentsWidth ( groupPane.getComponents () ); return CollectionUtils.asList ( groupPane ); }
Example #3
Source File: GroupPaneExample.java From weblaf with GNU General Public License v3.0 | 5 votes |
@NotNull @Override protected List<? extends JComponent> createPreviewElements () { final WebButton e1 = new WebButton ( "First" ); final WebComboBox e2 = new WebComboBox ( new String[]{ "First", "Second", "Third" }, 1 ); final WebTextField e3 = new WebTextField ( "Third" ); final WebButton e4 = new WebButton ( "Last" ); final GroupPane groupPane = new GroupPane ( getStyleId (), e1, e2, e3, e4 ); SwingUtils.equalizeComponentsWidth ( groupPane.getComponents () ); return CollectionUtils.asList ( groupPane ); }
Example #4
Source File: WebTreeCellEditor.java From weblaf with GNU General Public License v3.0 | 5 votes |
/** * Returns custom tree cell editor component. * * @param tree tree * @param value cell value * @param isSelected whether cell is selected or not * @param expanded whether cell is expanded or not * @param leaf whether cell is leaf or not * @param row cell row index * @return cell editor component */ @Override public Component getTreeCellEditorComponent ( final JTree tree, final Object value, final boolean isSelected, final boolean expanded, final boolean leaf, final int row ) { final Component cellEditor = super.getTreeCellEditorComponent ( tree, value, isSelected, expanded, leaf, row ); // Focus listener to stop editing on focus loss event cellEditor.addFocusListener ( this ); // Copying editor size from cell renderer size final TreeCellRenderer r = tree.getCellRenderer (); final Component component = r.getTreeCellRendererComponent ( tree, value, isSelected, expanded, leaf, row, true ); cellEditor.setPreferredSize ( component.getPreferredSize () ); // Updating editor styling if ( cellEditor instanceof WebTextField ) { // Field styling final WebTextField editor = ( WebTextField ) cellEditor; editor.setStyleId ( StyleId.treeCellEditor.at ( tree ) ); // Updating leading icon styling if ( component instanceof JLabel && ( ( JLabel ) component ).getIcon () != null ) { final JLabel label = ( JLabel ) component; if ( autoUpdateLeadingIcon ) { // Leading icon styling final WebImage image = new WebImage ( StyleId.treeCellEditorIcon.at ( editor ), label.getIcon () ); editor.setLeadingComponent ( image ); } } } // Applying component orientation cellEditor.applyComponentOrientation ( tree.getComponentOrientation () ); return cellEditor; }
Example #5
Source File: DictionariesTreeEditor.java From weblaf with GNU General Public License v3.0 | 5 votes |
/** * Returns custom tree cell editor component. * * @param tree tree * @param value cell value * @param isSelected whether cell is selected or not * @param expanded whether cell is expanded or not * @param leaf whether cell is leaf or not * @param row cell row index * @return cell editor component */ @Override public Component getTreeCellEditorComponent ( final JTree tree, final Object value, final boolean isSelected, final boolean expanded, final boolean leaf, final int row ) { final WebTextField editor = ( WebTextField ) super.getTreeCellEditorComponent ( tree, value, isSelected, expanded, leaf, row ); lastValue = ( DefaultMutableTreeNode ) value; final Object val = lastValue.getUserObject (); if ( val instanceof Dictionary ) { editor.setText ( ( ( Dictionary ) val ).getPrefix () ); } else if ( val instanceof Record ) { editor.setText ( ( ( Record ) val ).getKey () ); } else if ( val instanceof Value ) { // todo Add country editing editor.setText ( ( ( Value ) val ).getLocale ().getLanguage () ); } else if ( val instanceof Text ) { // todo Add mnemonic editor editor.setText ( ( ( Text ) val ).getText () ); } return editor; }
Example #6
Source File: WebCheckBoxListCellEditor.java From weblaf with GNU General Public License v3.0 | 5 votes |
/** * Creates list cell editor component for the cell under specified index. * * @param list list to process * @param index cell index * @param value cell value * @return list cell editor created for the cell under specified index */ @Override protected WebTextField createCellEditor ( final JList list, final int index, final CheckBoxCellData value ) { final WebTextField field = new WebTextField ( StyleId.checkboxlistCellEditor.at ( list ) ); field.setText ( value.getUserObject () != null ? value.getUserObject ().toString () : "" ); field.selectAll (); return field; }
Example #7
Source File: WebFileListCellEditor.java From weblaf with GNU General Public License v3.0 | 5 votes |
@Override protected WebTextField createCellEditor ( final JList list, final int index, final FileElement value ) { final WebTextField editor = new WebTextField ( StyleId.filelistCellEditor.at ( list ) ); FileUtils.displayFileName ( editor, value.getFile () ); if ( list instanceof WebFileList ) { final boolean tiles = ( ( WebFileList ) list ).getFileListViewType ().equals ( FileListViewType.tiles ); editor.setHorizontalAlignment ( tiles ? WebTextField.LEFT : WebTextField.CENTER ); } return editor; }
Example #8
Source File: WebFileTreeCellEditor.java From weblaf with GNU General Public License v3.0 | 5 votes |
@Override protected void initialize ( final WebTextField editor ) { this.editorComponent = editor; this.clickCountToStart = 3; this.autoUpdateLeadingIcon = false; this.delegate = new FileNameEditorDelegate (); editor.addActionListener ( delegate ); }
Example #9
Source File: WebFileTableCellEditor.java From weblaf with GNU General Public License v3.0 | 5 votes |
/** * Constructs new WebFileTableCellEditor. */ public WebFileTableCellEditor () { super (); clickCountToStart = 3; editorComponent = new WebTextField (); delegate = new FileNameEditorDelegate (); editorComponent.addActionListener ( delegate ); }
Example #10
Source File: SampleInterface.java From weblaf with GNU General Public License v3.0 | 5 votes |
/** * Returns sample auth form UI. * * @return sample auth form UI */ @NotNull public static JComponent createAuthForm () { final WebPanel form = new WebPanel ( StyleId.panelDecorated, new FormLayout ( 10, 10 ) ); form.setPadding ( 15, 25, 15, 25 ); form.add ( new WebStyledLabel ( "demo.sample.interface.auth.title", SwingConstants.CENTER ), FormLayout.LINE ); form.add ( new WebLabel ( "demo.sample.interface.auth.login", SwingConstants.RIGHT ) ); form.add ( new WebTextField ( 15 ) ); form.add ( new WebLabel ( "demo.sample.interface.auth.password", SwingConstants.RIGHT ) ); form.add ( new WebPasswordField ( 15 ) ); form.add ( new AlignPanel ( new GroupPanel ( 5, true, new WebButton ( "demo.sample.interface.auth.buttons.login" ).setPreferredWidth ( 100 ), new WebButton ( "demo.sample.interface.auth.buttons.cancel" ).setPreferredWidth ( 100 ) ), AlignPanel.CENTER, AlignPanel.CENTER ), FormLayout.LINE ); return form; }
Example #11
Source File: WebPopupExample.java From weblaf with GNU General Public License v3.0 | 5 votes |
@NotNull @Override protected List<? extends JComponent> createPreviewElements () { final WebButton button = new WebButton ( getExampleLanguagePrefix () + "show" ); button.addActionListener ( new ActionListener () { @Override public void actionPerformed ( final ActionEvent e ) { final WebPopup popup = new WebPopup ( getStyleId (), new AlignLayout () ); popup.setPadding ( 10 ); popup.setResizable ( true ); popup.setDraggable ( true ); final WebPanel container = new WebPanel ( StyleId.panelTransparent, new BorderLayout ( 5, 5 ) ); final WebLabel label = new WebLabel ( getExampleLanguagePrefix () + "label", WebLabel.CENTER ); container.add ( label, BorderLayout.NORTH ); final String text = LM.get ( getExampleLanguagePrefix () + "text" ); final WebTextField field = new WebTextField ( text, 20 ); field.setHorizontalAlignment ( WebTextField.CENTER ); container.add ( field, BorderLayout.CENTER ); popup.add ( container ); popup.pack (); popup.setResizable ( true ); popup.showPopup ( button, 0, button.getHeight () ); } } ); return CollectionUtils.asList ( button ); }
Example #12
Source File: WebPopOverExample.java From weblaf with GNU General Public License v3.0 | 5 votes |
@NotNull @Override protected List<? extends JComponent> createPreviewElements () { final WebButton button = new WebButton ( getExampleLanguagePrefix () + "show" ); button.addActionListener ( new ActionListener () { @Override public void actionPerformed ( final ActionEvent e ) { final Window parent = CoreSwingUtils.getNonNullWindowAncestor ( button ); final WebPopOver popOver = new WebPopOver ( getStyleId (), parent ); popOver.setIconImages ( WebLookAndFeel.getImages () ); popOver.setCloseOnFocusLoss ( true ); popOver.setPadding ( 10 ); final WebPanel container = new WebPanel ( StyleId.panelTransparent, new BorderLayout ( 5, 5 ) ); final WebLabel label = new WebLabel ( getExampleLanguagePrefix () + "label", WebLabel.CENTER ); container.add ( label, BorderLayout.NORTH ); final String text = LM.get ( getExampleLanguagePrefix () + "text" ); final WebTextField field = new WebTextField ( text, 20 ); field.setHorizontalAlignment ( WebTextField.CENTER ); container.add ( field, BorderLayout.CENTER ); popOver.add ( container ); popOver.show ( button, PopOverDirection.down ); } } ); return CollectionUtils.asList ( button ); }
Example #13
Source File: WebTextFieldExample.java From weblaf with GNU General Public License v3.0 | 5 votes |
@NotNull @Override protected List<? extends JComponent> createPreviewElements () { final WebTextField textField = new WebTextField ( getStyleId (), 18 ); textField.setInputPrompt ( getPreviewLanguagePrefix () + "prompt" ); textField.setLeadingComponent ( new WebImage ( DemoStyles.leadingImage, DemoIcons.key16 ) ); return CollectionUtils.asList ( textField ); }
Example #14
Source File: InstructionEditorPanel.java From Cafebabe with GNU General Public License v3.0 | 5 votes |
private void ldcComponentUpdate(WebComboBox wcb, LdcInsnNode ain, Field f, WebTextField field) { switch (wcb.getSelectedIndex()) { case 0: setField(f, ain, field.getText().trim()); break; case 1: setField(f, ain, Integer.parseInt(field.getText().trim())); break; case 2: setField(f, ain, Float.parseFloat(field.getText().trim())); break; case 3: setField(f, ain, Long.parseLong(field.getText().trim())); break; case 4: setField(f, ain, Double.parseDouble(field.getText().trim())); break; case 5: setField(f, ain, Type.getType(field.getText().trim())); break; case 6: setField(f, ain, field.getText().trim()); break; case 7: setField(f, ain, field.getText().trim()); break; } }
Example #15
Source File: InstructionEditorPanel.java From Cafebabe with GNU General Public License v3.0 | 5 votes |
private WebTextField createSingleDescEditor(InstructionList il, AbstractInsnNode ain, Field f, Object value) { WebTextField argsField = new WebTextField(Descriptors.getDisplayTypeEditable(((String) value))); argsField.setMaximumWidth(maxWidth); Listeners.addChangeListener(argsField, c -> { setField(f, ain, Descriptors.displayTypeToDesc(argsField.getText().trim())); il.repaint(); }); return argsField; }
Example #16
Source File: DynamicMenu.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public DynamicMenu () { super (); // Custom display event getContentPane ().addMouseListener ( new MouseAdapter () { @Override public void mousePressed ( final MouseEvent e ) { if ( SwingUtils.isMiddleMouseButton ( e ) ) { // Menu with custom elements createMenu ().showMenu ( e.getComponent (), e.getPoint () ); } } } ); setLayout ( new FlowLayout ( FlowLayout.CENTER, 15, 15 ) ); type = new WebComboBox ( DynamicMenuType.values (), DynamicMenuType.shutter ); add ( new GroupPanel ( 5, new WebLabel ( "Display animation:" ), type ) ); hidingType = new WebComboBox ( DynamicMenuType.values (), DynamicMenuType.shutter ); add ( new GroupPanel ( 5, new WebLabel ( "Hide animation:" ), hidingType ) ); radius = new WebTextField ( new IntTextDocument (), "70", 4 ); add ( new GroupPanel ( 5, new WebLabel ( "Menu radius:" ), radius ) ); amount = new WebTextField ( new IntTextDocument (), "5", 4 ); add ( new GroupPanel ( 5, new WebLabel ( "Items amount:" ), amount ) ); setDefaultCloseOperation ( WindowConstants.EXIT_ON_CLOSE ); setSize ( 800, 600 ); setLocationRelativeTo ( null ); setVisible ( true ); }
Example #17
Source File: ComponentUtils.java From desktopclient-java with GNU General Public License v3.0 | 5 votes |
private static void addListener(final AddContactPanel panel, WebTextField field) { field.getDocument().addDocumentListener(new DocumentChangeListener() { @Override public void documentChanged(DocumentEvent e) { panel.checkSaveButton(); } }); }
Example #18
Source File: SampleTreeCellEditor.java From weblaf with GNU General Public License v3.0 | 5 votes |
@Override public Component getTreeCellEditorComponent ( final JTree tree, final Object value, final boolean isSelected, final boolean expanded, final boolean leaf, final int row ) { this.sampleNode = ( SampleNode ) value; final WebTextField editor = ( WebTextField ) super.getTreeCellEditorComponent ( tree, value, isSelected, expanded, leaf, row ); editor.setText ( sampleNode.getTitle () ); return editor; }
Example #19
Source File: WebTextFieldExample.java From weblaf with GNU General Public License v3.0 | 5 votes |
@NotNull @Override protected List<? extends JComponent> createPreviewElements () { final WebTextField textField = new WebTextField ( getStyleId (), 20 ); textField.setInputPrompt ( getPreviewLanguagePrefix () + "prompt" ); return CollectionUtils.asList ( textField ); }
Example #20
Source File: WebTextFieldExample.java From weblaf with GNU General Public License v3.0 | 5 votes |
@NotNull @Override protected List<? extends JComponent> createPreviewElements () { final WebTextField textField = new WebTextField ( getStyleId (), 18 ); textField.setInputPrompt ( getPreviewLanguagePrefix () + "prompt" ); textField.setTrailingComponent ( new WebImage ( DemoStyles.trailingImage, DemoIcons.github16 ) ); return CollectionUtils.asList ( textField ); }
Example #21
Source File: WebOverlayExample.java From weblaf with GNU General Public License v3.0 | 4 votes |
@NotNull @Override protected List<? extends JComponent> createPreviewElements () { final WebOverlay overlay = new WebOverlay ( getStyleId () ); final WebTextField textField = new WebTextField ( 15 ); textField.setLanguage ( getPreviewLanguageKey ( "field" ) ); textField.setMargin ( 3, 0, 3, 0 ); overlay.setContent ( textField ); final WebLabel overlayLabel = new WebLabel ( DemoIcons.info14 ); overlayLabel.setToolTip ( getPreviewLanguageKey ( "tooltip" ), TooltipWay.right ); textField.onChange ( new DocumentEventRunnable<WebTextField> () { @Override public void run ( @NotNull final WebTextField component, @Nullable final DocumentEvent event ) { CoreSwingUtils.invokeLater ( new Runnable () { @Override public void run () { final String text = textField.getText (); if ( text.length () > 0 ) { if ( overlay.getOverlayCount () == 0 ) { overlay.addOverlay ( new AlignedOverlay ( overlayLabel, BoxOrientation.right, BoxOrientation.top, new Insets ( 0, 0, 0, 3 ) ) ); } } else { if ( overlay.getOverlayCount () > 0 ) { overlay.removeOverlay ( overlayLabel ); } } } } ); } } ); return CollectionUtils.asList ( overlay ); }
Example #22
Source File: DecompilerPanel.java From Cafebabe with GNU General Public License v3.0 | 4 votes |
public DecompilerPanel(ClassNode cn, MethodNode mn) { this.dp = new DecompilerTextArea(); dp.setText(CFR.decompile(cn, mn)); this.label = new JLabel("CFR Decompiler 0.145"); this.setLayout(new BorderLayout(0, 0)); JPanel lpad = new JPanel(); lpad.setBorder(new EmptyBorder(1, 5, 0, 1)); lpad.setLayout(new GridLayout()); lpad.add(label); JPanel rs = new JPanel(); rs.setLayout(new GridLayout(1, 5)); for (int i = 0; i < 3; i++) rs.add(new JPanel()); WebTextField search = new WebTextField(); search.setInputPrompt(Translations.get("Search...")); search.addActionListener(l -> { try { String text = search.getText(); if (text.isEmpty()) { dp.getHighlighter().removeAllHighlights(); return; } String searchText = text.toLowerCase(); if (!Objects.equals(searchText, lastSearchText)) { searchIndex = -1; lastSearchText = searchText; } String[] split = dp.getText().split("\\r?\\n"); System.out.println(searchText); int firstIndex = -1; boolean first = false; Label: { for (int i = 0; i < split.length; i++) { String line = split[i]; if (line.toLowerCase().contains(searchText)) { if (i > searchIndex) { dp.setCaretPosition(dp.getDocument().getDefaultRootElement().getElement(i).getStartOffset()); searchIndex = i; break Label; } else if (!first) { firstIndex = i; first = true; } } } if (first) { // go back to first line dp.setCaretPosition(dp.getDocument().getDefaultRootElement().getElement(firstIndex).getStartOffset()); searchIndex = firstIndex; } } hightlightText(searchText); } catch (Exception e) { e.printStackTrace(); } }); rs.add(search); JButton reload = new JButton(Translations.get("Reload")); reload.addActionListener(l -> { dp.setText(CFR.decompile(cn, mn)); }); rs.add(reload); lpad.add(rs); this.add(lpad, BorderLayout.NORTH); JScrollPane scp = new RTextScrollPane(dp); scp.getVerticalScrollBar().setUnitIncrement(16); this.add(scp, BorderLayout.CENTER); }
Example #23
Source File: TypePanel.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructor. * @param wizard {@link CreateMissionWizard} the create mission wizard. */ @SuppressWarnings("unchecked") TypePanel(CreateMissionWizard wizard) { // Use WizardPanel constructor. super(wizard); this.wizard = wizard; missionManager = Simulation.instance().getMissionManager(); // Set the layout. setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // Set the border. setBorder(new MarsPanelBorder()); // Create the type info label. WebLabel typeInfoLabel = new WebLabel("Select Mission Type"); typeInfoLabel.setFont(typeInfoLabel.getFont().deriveFont(Font.BOLD)); typeInfoLabel.setAlignmentX(Component.LEFT_ALIGNMENT); add(typeInfoLabel); // Create the type panel. WebPanel typePane = new WebPanel(new FlowLayout(FlowLayout.LEFT)); typePane.setAlignmentX(Component.LEFT_ALIGNMENT); add(typePane); // Create the type label. WebLabel typeLabel= new WebLabel("Type: "); typePane.add(typeLabel); // Create the mission types. MissionType[] missionTypes = MissionDataBean.getMissionTypes(); // sortStringBubble(missionTypes); // MissionType[] displayMissionTypes = new MissionType[missionTypes.length]; List<String> types = new ArrayList<>(); int size = missionTypes.length; for (int i=0; i<size; i++) { types.add(missionTypes[i].getName()); } // displayMissionTypes[0] = ""; // System.arraycopy(missionTypes, 0, displayMissionTypes, 1, missionTypes.length); typeSelect = new JComboBoxMW<String>(); Iterator<String> k = types.iterator(); while (k.hasNext()) typeSelect.addItem(k.next()); typeSelect.setSelectedIndex(-1); typeSelect.addItemListener(this); typeSelect.setMaximumRowCount(typeSelect.getItemCount()); typePane.add(typeSelect); typePane.setMaximumSize(new Dimension(Short.MAX_VALUE, typeSelect.getPreferredSize().height)); // Add a vertical strut to separate the display. add(Box.createVerticalStrut(10)); // Create the description info label. descriptionInfoLabel = new WebLabel("Edit Mission Description (Optional)"); descriptionInfoLabel.setFont(descriptionInfoLabel.getFont().deriveFont(Font.BOLD)); descriptionInfoLabel.setAlignmentX(Component.LEFT_ALIGNMENT); descriptionInfoLabel.setEnabled(false); add(descriptionInfoLabel); // Create the description panel. WebPanel descriptionPane = new WebPanel(new FlowLayout(FlowLayout.LEFT)); descriptionPane.setAlignmentX(Component.LEFT_ALIGNMENT); add(descriptionPane); // Create the description label. descriptionLabel = new WebLabel("Description: "); descriptionLabel.setEnabled(false); descriptionPane.add(descriptionLabel); // Create the description text field. descriptionTF = new WebTextField(20); descriptionTF.setEnabled(false); descriptionPane.add(descriptionTF); descriptionPane.setMaximumSize(new Dimension(Short.MAX_VALUE, descriptionTF.getPreferredSize().height)); // Listen for changes in the text addChangeListener(descriptionTF, e -> { descriptionText = descriptionTF.getText(); // System.out.println("descriptionText: " + descriptionText); }); // Add a vertical glue. add(Box.createVerticalGlue()); }
Example #24
Source File: WebTreeFilterField.java From weblaf with GNU General Public License v3.0 | 4 votes |
/** * Initializes listeners. */ protected void initListeners () { // Updating filtering on text change onChange ( new DocumentEventRunnable<WebTextField> () { @Override public void run ( @NotNull final WebTextField component, @Nullable final DocumentEvent event ) { filter.setSearchText ( component.getText () ); updateFiltering (); } } ); // Clearing filter field on ESCAPE press onKeyPress ( Hotkey.ESCAPE, new KeyEventRunnable () { @Override public void run ( @NotNull final KeyEvent e ) { clear (); } } ); // Model listener for carrying custom filter over to new model treeModelChangeListener = new PropertyChangeListener () { @Override public void propertyChange ( @NotNull final PropertyChangeEvent evt ) { // Checking model support final TreeModel newModel = ( TreeModel ) evt.getNewValue (); checkTreeModel ( newModel ); // Removing filter from the old model removeFieldFilter (); // Clearing tree state as it might not be applicable to the new model data clearState (); // Saving reference to the new model model = newModel; // Saving tree state before applying the filter saveState (); // Applying filter to the new model applyFieldFilter (); } }; }
Example #25
Source File: BuildingPanelPower.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructor. * @param building the building the panel is for. * @param desktop The main desktop. */ public BuildingPanelPower(Building building, MainDesktopPane desktop) { // Use BuildingFunctionPanel constructor super(building, desktop); // Check if the building is a power producer. isProducer = building.hasFunction(FunctionType.POWER_GENERATION); generator = building.getPowerGeneration(); // Set the layout setLayout(new BorderLayout()); // 2014-11-21 Changed font type, size and color and label text WebLabel titleLabel = new WebLabel( Msg.getString("BuildingPanelPower.title"), //$NON-NLS-1$ WebLabel.CENTER); titleLabel.setFont(new Font("Serif", Font.BOLD, 16)); //titleLabel.setForeground(new Color(102, 51, 0)); // dark brown add(titleLabel, BorderLayout.NORTH); WebPanel springPanel = new WebPanel(new SpringLayout()); add(springPanel, BorderLayout.CENTER); // Prepare power status label. powerStatusCache = building.getPowerMode(); powerStatusLabel = new WebLabel( Msg.getString("BuildingPanelPower.powerStatus"), //$NON-NLS-1$ WebLabel.RIGHT); springPanel.add(powerStatusLabel); WebPanel wrapper1 = new WebPanel(new FlowLayout(0, 0, FlowLayout.LEADING)); statusTF = new WebTextField(powerStatusCache.getName()); statusTF.setEditable(false); statusTF.setColumns(7); statusTF.setPreferredSize(new Dimension(120, 25)); wrapper1.add(statusTF); springPanel.add(wrapper1); // If power producer, prepare power producer label. if (isProducer) { //PowerGeneration generator = building.getPowerGeneration();//(PowerGeneration) building.getFunction(FunctionType.POWER_GENERATION); powerCache = generator.getGeneratedPower(); powerLabel = new WebLabel( Msg.getString("BuildingPanelPower.powerProduced"), //$NON-NLS-1$ WebLabel.RIGHT); springPanel.add(powerLabel); WebPanel wrapper2 = new WebPanel(new FlowLayout(0, 0, FlowLayout.LEADING)); producedTF = new WebTextField(formatter.format(powerCache) + kW); producedTF.setEditable(false); producedTF.setColumns(7); producedTF.setPreferredSize(new Dimension(120, 25)); wrapper2.add(producedTF); springPanel.add(wrapper2); } // Prepare power used label. if (powerStatusCache == PowerMode.FULL_POWER) usedCache = building.getFullPowerRequired(); else if (powerStatusCache == PowerMode.POWER_DOWN) usedCache = building.getPoweredDownPowerRequired(); else usedCache = 0D; usedLabel = new WebLabel( Msg.getString("BuildingPanelPower.powerUsed"), //$NON-NLS-1$ WebLabel.RIGHT ); springPanel.add(usedLabel); WebPanel wrapper3 = new WebPanel(new FlowLayout(0, 0, FlowLayout.LEADING)); usedTF = new WebTextField(formatter.format(usedCache) + kW); usedTF.setEditable(false); usedTF.setColumns(7); usedTF.setPreferredSize(new Dimension(120, 25)); wrapper3.add(usedTF); springPanel.add(wrapper3); //Lay out the spring panel. if (isProducer) { SpringUtilities.makeCompactGrid(springPanel, 3, 2, //rows, cols 75, 10, //initX, initY 3, 1); //xPad, yPad } else SpringUtilities.makeCompactGrid(springPanel, 2, 2, //rows, cols 75, 10, //initX, initY 3, 1); //xPad, yPad }
Example #26
Source File: BuildingPanelPowerStorage.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructor. * @param storage The power storage building function. * @param desktop The main desktop. */ public BuildingPanelPowerStorage(PowerStorage storage, MainDesktopPane desktop) { // Use BuildingFunctionPanel constructor super(storage.getBuilding(), desktop); this.storage = storage; // Set the layout setLayout(new BorderLayout()); // 2014-11-21 Changed font type, size and color and label text WebLabel titleLabel = new WebLabel( Msg.getString("BuildingPanelPowerStorage.title"), //$NON-NLS-1$ WebLabel.CENTER); titleLabel.setFont(new Font("Serif", Font.BOLD, 16)); //titleLabel.setForeground(new Color(102, 51, 0)); // dark brown add(titleLabel, BorderLayout.NORTH); WebPanel springPanel = new WebPanel(new SpringLayout()); add(springPanel, BorderLayout.CENTER); // Create capacity label. capacityCache = Math.round(storage.getCurrentMaxCapacity() *10.0)/10.0;; capacityLabel = new WebLabel( Msg.getString("BuildingPanelPowerStorage.cap"), //$NON-NLS-1$ WebLabel.CENTER); springPanel.add(capacityLabel); WebPanel wrapper1 = new WebPanel(new FlowLayout(0, 0, FlowLayout.LEADING)); capTF = new WebTextField(formatter.format(capacityCache) + kWh); capTF.setEditable(false); capTF.setColumns(7); capTF.setPreferredSize(new Dimension(120, 25)); wrapper1.add(capTF); springPanel.add(wrapper1); // Create stored label. storedCache = Math.round(storage.getkWattHourStored() *10.0)/10.0;; storedLabel = new WebLabel( Msg.getString("BuildingPanelPowerStorage.stored"), //$NON-NLS-1$ WebLabel.CENTER); springPanel.add(storedLabel); WebPanel wrapper2 = new WebPanel(new FlowLayout(0, 0, FlowLayout.LEADING)); storedTF = new WebTextField(storedCache + kWh); storedTF.setEditable(false); storedTF.setColumns(7); storedTF.setPreferredSize(new Dimension(120, 25)); wrapper2.add(storedTF); springPanel.add(wrapper2); SpringUtilities.makeCompactGrid(springPanel, 2, 2, //rows, cols 75, 10, //initX, initY 3, 1); //xPad, yPad }
Example #27
Source File: WebPathField.java From weblaf with GNU General Public License v3.0 | 4 votes |
public WebTextField getPathField () { return pathField; }
Example #28
Source File: WebTreeCellEditor.java From weblaf with GNU General Public License v3.0 | 4 votes |
/** * Constructs default tree cell editor with a text field as editor. */ public WebTreeCellEditor () { this ( new WebTextField () ); }
Example #29
Source File: WebFileChooserPanel.java From weblaf with GNU General Public License v3.0 | 2 votes |
/** * Returns field used to display selected files in {@link FileChooserType#save} mode. * * @return field used to display selected files in {@link FileChooserType#save} mode */ public WebTextField getSelectedFilesTextField () { return selectedFilesTextField; }
Example #30
Source File: WebTreeCellEditor.java From weblaf with GNU General Public License v3.0 | 2 votes |
/** * Constructs tree cell editor with a specified text field as editor. * * @param textField editor textfield */ public WebTreeCellEditor ( final WebTextField textField ) { super ( textField ); }