private JPanel createCentrePanel(YDataStateException exception) { JPanel centrePanel = new JPanel(new GridLayout(1, 2)); JPanel msgPanel = new JPanel(new BorderLayout()); msgPanel.setBackground(YAdminGUI._apiColour); msgPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Schema for completing task"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); JTextPane msgTextPane = new JTextPane(); msgTextPane.setContentType("text/plain"); msgTextPane.setFont(new Font("courier", Font.PLAIN, 12)); msgTextPane.setForeground(Color.RED); msgTextPane.setText(exception.getMessage()); msgTextPane.setEditable(false); msgTextPane.setBackground(Color.LIGHT_GRAY); JPanel noWrapPanel = new JPanel(); noWrapPanel.setLayout(new BorderLayout()); noWrapPanel.add(msgTextPane); msgPanel.add(new JScrollPane(noWrapPanel)); centrePanel.add(msgPanel, BorderLayout.NORTH); return centrePanel; }
/** @param frameName title name for frame */ public ShowSavedResults(String frameName) { super(frameName); aboutRes = new JTextArea( "Select a result set from" + "\nthose listed and details" + "\nof that analysis will be" + "\nshown here. Then you can" + "\neither delete or view those" + "\nresults using the buttons below."); aboutScroll = new JScrollPane(aboutRes); ss = new JScrollPane(sp); ss.getViewport().setBackground(Color.white); // resMenu.setLayout(new FlowLayout(FlowLayout.LEFT,10,1)); ClassLoader cl = getClass().getClassLoader(); rfii = new ImageIcon(cl.getResource("images/Refresh_button.gif")); // results status resButtonStatus = new JPanel(new BorderLayout()); Border loweredbevel = BorderFactory.createLoweredBevelBorder(); Border raisedbevel = BorderFactory.createRaisedBevelBorder(); Border compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel); statusField = new JTextField(); statusField.setBorder(compound); statusField.setEditable(false); }
public void createColorPanel() { JPanel colorPanel = new JPanel(new GridLayout(0, 1)); int curRow = 0; for (int i = 0; i < colorString.length / 5; i++) { JPanel row = new JPanel(new GridLayout(1, 0, 2, 1)); row.setBorder(new EmptyBorder(2, 2, 2, 2)); for (int j = curRow; j < curRow + 5; j++) { final JLabel colorLabel = new JLabel(null, new ColoredIcon(color[j], 14, 14), JLabel.CENTER); colorLabel.setOpaque(true); final Border emb = BorderFactory.createEmptyBorder(2, 1, 2, 1); final Border lnb = BorderFactory.createLineBorder(Color.black); final Border cmb = BorderFactory.createCompoundBorder(lnb, emb); colorLabel.setBorder(emb); colorLabel.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { JButton btn = (JButton) getTarget(); Color selColor = ((ColoredIcon) colorLabel.getIcon()).getCurrentColor(); btn.setIcon(new ColoredIcon(selColor)); setVisible(false); btn.doClick(); oldLabel.setBackground(null); colorLabel.setBackground(new Color(150, 150, 200)); colorLabel.setBorder(emb); oldLabel = colorLabel; } public void mouseEntered(MouseEvent e) { colorLabel.setBorder(cmb); colorLabel.setBackground(new Color(150, 150, 200)); } public void mouseExited(MouseEvent e) { colorLabel.setBorder(emb); colorLabel.setBackground(null); } }); row.add(colorLabel); } colorPanel.add(row); curRow += row.getComponentCount(); // System.out.println(curRow); } add(colorPanel, BorderLayout.CENTER); // More Colors Button moreColors = new JButton(new ColorChooserAction((JButton) target)); moreColors.setText("More Colors..."); moreColors.setIcon(null); moreColors.setFont(new Font("Verdana", Font.PLAIN, 10)); // JPanel c = new JPanel(new FlowLayout(FlowLayout.CENTER)); c.add(moreColors); add(c, BorderLayout.SOUTH); }
protected void setMainComponent() { mainComponent = new JPanel(new GridBagLayout()); currentPanel = (JPanel) mainComponent; Border mainComponentBorder = BorderFactory.createCompoundBorder( BorderFactory.createEtchedBorder(), BorderFactory.createEmptyBorder(5 + inset, 5 + inset, 5 + inset, 5 + inset)); currentPanel.setBorder(mainComponentBorder); }
public ComboBoxDemo2() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); JComboBox patternList = new JComboBox(patternExamples); patternList.setEditable(true); patternList.addActionListener(this); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // == LEFT result = new JLabel(" "); result.setForeground(Color.black); result.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); } // constructor
public PlayButton(String name) { super(name); myBorder = BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.black), BorderFactory.createLineBorder(Color.blue)), BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.cyan), BorderFactory.createLineBorder(Color.white))); addMouseListener( new MouseAdapter() { public void mouseEntered(MouseEvent e) { setBorder(myBorder); } public void mouseExited(MouseEvent e) { setBorder(null); } }); }
private JPanel createTopPanel(YWorkItem item) { JPanel topPanel = new JPanel(new BorderLayout()); topPanel.setBackground(YAdminGUI._apiColour); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JTextArea explanatoryText = new JTextArea(); explanatoryText.setText( "The data you submitted for this work item was \n" + "validated against a schema (see below). For some reason the\n" + "this data did not succeed in passing the constrainst set\n" + "inside the schema.\n" + "Usage Note: If this is causing problems try using the Web server\n" + "version of YAWL, which supports automatic forms generation.\n" + "Otherwise you could copy the schema from this page and use it\n " + "to create a valid output document using an XML development tool."); explanatoryText.setEditable(false); explanatoryText.setFont(new Font("Arial", Font.BOLD, 12)); explanatoryText.setForeground(Color.DARK_GRAY); explanatoryText.setBackground(YAdminGUI._apiColour); leftPanel.add(explanatoryText); topPanel.add(leftPanel, BorderLayout.WEST); JPanel rightPanel = new JPanel(new GridLayout(4, 2)); rightPanel.setBackground(YAdminGUI._apiColour); rightPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Work Item Details"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); YTask task = YEngine.getInstance().getTaskDefinition(item.getSpecificationID(), item.getTaskID()); String taskName = task.getName(); String[] text = { item.getSpecificationID().toString(), taskName, item.getIDString(), item.getStartTimeStr() }; String[] labels = {"Specification ID", "Task Name", "WorkItem ID", "Task Started"}; for (int i = 0; i < text.length; i++) { String s = text[i]; rightPanel.add(new JLabel(labels[i])); JTextField t = new JTextField(s); t.setEditable(false); rightPanel.add(t); } topPanel.add(rightPanel, BorderLayout.CENTER); return topPanel; }
public InterpreterFrame() { super("Simple Lisp Interpreter"); // Create the menu menubar = buildMenuBar(); setJMenuBar(menubar); // Create the toolbar toolbar = buildToolBar(); // disable cut and copy actions cutAction.setEnabled(false); copyAction.setEnabled(false); // Setup text area for editing source code // and setup document listener so interpreter // is notified when current file modified and // when the cursor is moved. textView = buildEditor(); textView.getDocument().addDocumentListener(this); textView.addCaretListener(this); // set default key bindings bindKeyToCommand("ctrl C", "(buffer-copy)"); bindKeyToCommand("ctrl X", "(buffer-cut)"); bindKeyToCommand("ctrl V", "(buffer-paste)"); bindKeyToCommand("ctrl E", "(buffer-eval)"); bindKeyToCommand("ctrl O", "(file-open)"); bindKeyToCommand("ctrl S", "(file-save)"); bindKeyToCommand("ctrl Q", "(exit)"); // Give text view scrolling capability Border border = BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(3, 3, 3, 3), BorderFactory.createLineBorder(Color.gray)); JScrollPane topSplit = addScrollers(textView); topSplit.setBorder(border); // Create tabbed pane for console/problems consoleView = makeConsoleArea(10, 50, true); problemsView = makeConsoleArea(10, 50, false); tabbedPane = buildProblemsConsole(); // Plug the editor and problems/console together // using a split pane. This allows one to change // their relative size using the split-bar in // between them. splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topSplit, tabbedPane); // Create status bar statusView = new JLabel(" Status"); lineNumberView = new JLabel("0:0"); statusbar = buildStatusBar(); // Now, create the outer panel which holds // everything together outerpanel = new JPanel(); outerpanel.setLayout(new BorderLayout()); outerpanel.add(toolbar, BorderLayout.PAGE_START); outerpanel.add(splitPane, BorderLayout.CENTER); outerpanel.add(statusbar, BorderLayout.SOUTH); getContentPane().add(outerpanel); // tell frame to fire a WindowsListener event // but not to close when "x" button clicked. setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(this); // set minimised icon to use setIconImage(makeImageIcon("spi.png").getImage()); // setup additional internal functions InternalFunctions.setup_internals(interpreter, this); // set default window size Component top = splitPane.getTopComponent(); Component bottom = splitPane.getBottomComponent(); top.setPreferredSize(new Dimension(100, 400)); bottom.setPreferredSize(new Dimension(100, 200)); pack(); // load + run user configuration file (if there is one) String homedir = System.getProperty("user.home"); try { interpreter.load(homedir + "/.simplelisp"); } catch (FileNotFoundException e) { // do nothing if file does not exist! System.out.println("Didn't find \"" + homedir + "/.simplelisp\""); } textView.grabFocus(); setVisible(true); // redirect all I/O to problems/console redirectIO(); // start highlighter thread highlighter = new DisplayThread(250); highlighter.setDaemon(true); highlighter.start(); }
public PlayerView(String player) { playerName = new String(player); // Set-Up Top of Score Area namePanel = new JPanel(); nameText = new JLabel(player); nameText.setFont(ScoreFont); namePanel.setLayout(new BorderLayout()); namePanel.add(nameText, BorderLayout.CENTER); scorePanel = new JPanel(); scoreText = new JLabel(" 0"); scoreText.setFont(ScoreFont); scorePanel.setLayout(new BorderLayout()); scorePanel.add(scoreText, BorderLayout.CENTER); topPanel = new JPanel(); BoxLayout layout = new BoxLayout(topPanel, BoxLayout.LINE_AXIS); topPanel.setLayout(layout); topPanel.add(namePanel); topPanel.add(Box.createRigidArea(new Dimension(10, 0))); topPanel.add(scorePanel); topPanel.add(Box.createRigidArea(new Dimension(10, 0))); // // topPanel.setLayout( new BorderLayout()); // topPanel.add(namePanel, BorderLayout.WEST); // topPanel.add(scorePanel, BorderLayout.EAST); // // Create bordering for top panel Border raisedBevel, loweredBevel, compound; raisedBevel = BorderFactory.createRaisedBevelBorder(); loweredBevel = BorderFactory.createLoweredBevelBorder(); compound = BorderFactory.createCompoundBorder(raisedBevel, loweredBevel); topPanel.setBorder(compound); // Set-Up area to display word list wordPanel = new JPanel(); Border etched = BorderFactory.createEtchedBorder(); TitledBorder etchedTitle = BorderFactory.createTitledBorder(etched, "Word List"); etchedTitle.setTitleJustification(TitledBorder.RIGHT); wordPanel.setBorder(etchedTitle); myWordList = new ExpandableList(); myWordList.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String word = e.getActionCommand(); java.util.List<BoardCell> list = myFinder.cellsForWord(myBoard, word); myBoardPanel.highlightDice(list); } }); wordPanel.add( new JScrollPane( myWordList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)); setLayout(new BorderLayout(30, 30)); add(topPanel, BorderLayout.NORTH); add(wordPanel, BorderLayout.CENTER); }
private JPanel createCentrePanel(YDataStateException exception) { XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat()); JPanel centrePanel = new JPanel(new GridLayout(1, 2)); JPanel schemaPanel = new JPanel(new BorderLayout()); schemaPanel.setBackground(YAdminGUI._apiColour); schemaPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Schema for completing task"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); JTextPane schemaTextPane = new JTextPane(); schemaTextPane.setContentType("text/xml"); schemaTextPane.setFont(new Font("courier", Font.PLAIN, 12)); String schemaXML = xmlOut.outputString(exception.getSchema()); /** AJH: Trap various XML format errors gracefully. */ try { String xml = schemaXML.substring(schemaXML.indexOf('<'), schemaXML.lastIndexOf("</xsd:schema>") + 13); schemaTextPane.setText(xml); } catch (Exception e) { schemaTextPane.setText(schemaXML); } schemaTextPane.setEditable(false); schemaTextPane.setBackground(Color.LIGHT_GRAY); JPanel noWrapPanel = new JPanel(); noWrapPanel.setLayout(new BorderLayout()); noWrapPanel.add(schemaTextPane); schemaPanel.add(new JScrollPane(noWrapPanel)); JPanel rightPanel = new JPanel(new GridLayout(2, 1)); JPanel dataPanel = new JPanel(new BorderLayout()); dataPanel.setBackground(YAdminGUI._apiColour); dataPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "The data that failed to validate"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); JTextPane dataTextPane = new JTextPane(); dataTextPane.setContentType("text/xml"); dataTextPane.setFont(new Font("courier", Font.PLAIN, 12)); String data = xmlOut.outputString(exception.get_dataInput()); /** AJH: Trap various XML format errors gracefully. */ try { String temp = data.substring(data.lastIndexOf("<?xml"), data.lastIndexOf('>')); dataTextPane.setText(temp); } catch (Exception e) { dataTextPane.setText(data); } dataTextPane.setEditable(false); dataTextPane.setBackground(Color.LIGHT_GRAY); JPanel noWrapPanel2 = new JPanel(); noWrapPanel2.setLayout(new BorderLayout()); noWrapPanel2.add(dataTextPane); dataPanel.add(new JScrollPane(noWrapPanel2)); JPanel errorPanel = new JPanel(new BorderLayout()); errorPanel.setBackground(YAdminGUI._apiColour); errorPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "The error message from validation engine"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); JTextPane errorTextPane = new JTextPane(); errorTextPane.setContentType("text/plain"); errorTextPane.setFont(new Font("courier", Font.PLAIN, 12)); /** AJH: Trap various XML format errors gracefully. */ try { String error = schemaXML.substring(schemaXML.lastIndexOf("ERRORS ="), schemaXML.length()); errorTextPane.setText(error); } catch (Exception e) { // null action ! } errorTextPane.setText(exception.getErrors()); errorTextPane.setEditable(false); errorTextPane.setBackground(Color.LIGHT_GRAY); JPanel noWrapPanel3 = new JPanel(); noWrapPanel3.setLayout(new BorderLayout()); noWrapPanel3.add(errorTextPane); errorPanel.add(new JScrollPane(noWrapPanel3)); rightPanel.add(dataPanel); rightPanel.add(errorPanel); centrePanel.add(schemaPanel, BorderLayout.NORTH); centrePanel.add(rightPanel, BorderLayout.CENTER); return centrePanel; }
public ServerDialog(OptionsDialog options_, Options opts_, CConn cc_) { super(true); cc = cc_; opts = opts_; options = options_; JLabel serverLabel = new JLabel("VNC server:", JLabel.RIGHT); String valueStr = null; if (opts.serverName != null) { String[] s = new String[1]; s[0] = opts.serverName; server = new JComboBox(s); } else if ((valueStr = UserPreferences.get("ServerDialog", "history")) != null) { server = new JComboBox(valueStr.split(",")); } else { server = new JComboBox(); } // Hack to set the left inset on editable JComboBox if (UIManager.getLookAndFeel().getID() == "Windows") { server.setBorder( BorderFactory.createCompoundBorder( server.getBorder(), BorderFactory.createEmptyBorder(0, 2, 0, 0))); } else if (UIManager.getLookAndFeel().getID() == "Metal") { ComboBoxEditor editor = server.getEditor(); JTextField jtf = (JTextField) editor.getEditorComponent(); jtf.setBorder(new CompoundBorder(jtf.getBorder(), new EmptyBorder(0, 2, 0, 0))); } server.setEditable(true); editor = server.getEditor(); editor .getEditorComponent() .addKeyListener( new KeyListener() { public void keyTyped(KeyEvent e) {} public void keyReleased(KeyEvent e) {} public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { server.insertItemAt(editor.getItem(), 0); server.setSelectedIndex(0); commit(); endDialog(); } } }); topPanel = new JPanel(new GridBagLayout()); Dialog.addGBComponent( new JLabel(VncViewer.logoIcon), topPanel, 0, 0, 1, 1, 0, 0, 0, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(5, 5, 5, 15)); Dialog.addGBComponent( serverLabel, topPanel, 1, 0, 1, 1, 0, 0, 0, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_END, new Insets(10, 0, 5, 5)); Dialog.addGBComponent( server, topPanel, 2, 0, 1, 1, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(10, 0, 5, 20)); optionsButton = new JButton("Options..."); aboutButton = new JButton("About..."); okButton = new JButton("Connect"); cancelButton = new JButton("Cancel"); buttonPanel = new JPanel(new GridBagLayout()); buttonPanel.setPreferredSize(new Dimension(350, 40)); Dialog.addGBComponent( aboutButton, buttonPanel, 0, 3, 1, 1, 0, 0, 0.8, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 2, 0, 5)); Dialog.addGBComponent( optionsButton, buttonPanel, 1, 3, 1, 1, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 2, 0, 5)); Dialog.addGBComponent( okButton, buttonPanel, 2, 3, 1, 1, 0, 0, 0.7, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 2, 0, 5)); Dialog.addGBComponent( cancelButton, buttonPanel, 3, 3, 1, 1, 0, 0, 0.6, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 2, 0, 5)); server.addActionListener(this); optionsButton.addActionListener(this); aboutButton.addActionListener(this); okButton.addActionListener(this); cancelButton.addActionListener(this); }
public void initializeComponents( DiscountCardsTableModel tableModel, MessageSource messageSource, LocaleHolder localeHolder) { this.tableModel = tableModel; this.filters = new ArrayList<>(); FiltersPurpose filtersPurpose = tableModel.getFiltersPurpose(); FilterElementsListener filterElementsListener = new FilterElementsListener(); // panel for search operations filtersPanel = new JPanel(); filtersPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( messageSource.getMessage( "mainForm.panel.search.title", null, localeHolder.getLocale())), BorderFactory.createEmptyBorder())); filtersPanel.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.insets = new Insets(1, 5, 1, 5); boolean allCardsPurpose = FiltersPurpose.ALL_DISCOUNT_CARDS == filtersPurpose; for (Field field : DiscountCardJdo.class.getDeclaredFields()) { FilterColumn filterColumn = field.getAnnotation(FilterColumn.class); if (filterColumn != null) { if (allCardsPurpose && filterColumn.showForAllDiscountCards()) { FilterUnit filterUnit = new FilterUnit(); if (allCardsPurpose) { filterUnit.order = filterColumn.orderForAllDiscountCards(); } filterUnit.order = filterUnit.order == 0 ? Integer.MAX_VALUE : filterUnit.order; filterUnit.filterType = filterColumn.type(); filterUnit.columnTitle = getColumnTitle(field, messageSource, localeHolder); filterUnit.columnDatePattern = getColumnDatePattern(field); if (!filterColumn.labelKey().isEmpty()) { filterUnit.label = new JLabel( messageSource.getMessage( filterColumn.labelKey(), null, localeHolder.getLocale())); filterUnit.textField = new JTextField(filterColumn.editSize()); filterUnit.textField.getDocument().addDocumentListener(filterElementsListener); } if (filterColumn.checkBoxesNumber() > 0) { filterUnit.checkBoxes = new JCheckBox[filterColumn.checkBoxesNumber()]; for (int i = 0; i < filterColumn.checkBoxesNumber(); ++i) { String text = messageSource.getMessage( filterColumn.checkBoxesText()[i], null, localeHolder.getLocale()); String actionCommand = messageSource.getMessage( filterColumn.checkBoxesAction()[i], null, localeHolder.getLocale()); filterUnit.checkBoxes[i] = new JCheckBox(text); filterUnit.checkBoxes[i].setActionCommand(actionCommand); if (field.getName().equals("activationDate")) { filterUnit.checkBoxes[i].setSelected(true); } else { filterUnit.checkBoxes[i].setSelected(false); } filterUnit.checkBoxes[i].addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { int state = e.getStateChange(); if (state == ItemEvent.SELECTED) { applyFilters(); updateAnalyzeComponent(); } else if (state == ItemEvent.DESELECTED) { applyFilters(); updateAnalyzeComponent(); } } }); } } filters.add(filterUnit); } } } Collections.sort( filters, new Comparator<FilterUnit>() { @Override public int compare(FilterUnit filterUnit1, FilterUnit filterUnit2) { return filterUnit1.order - filterUnit2.order; } }); for (int i = 0; i < filters.size(); ++i) { if (filters.get(i).label != null) { filters.get(i).label.setLabelFor(filters.get(i).textField); constraints.fill = GridBagConstraints.NONE; constraints.gridwidth = GridBagConstraints.RELATIVE; constraints.anchor = GridBagConstraints.EAST; constraints.weightx = 0.0; filtersPanel.add(filters.get(i).label, constraints); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.anchor = GridBagConstraints.EAST; constraints.weightx = 1.0; filtersPanel.add(filters.get(i).textField, constraints); } else if (filters.get(i).checkBoxes != null) { JPanel checkBoxPanel = new JPanel(); checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.LINE_AXIS)); checkBoxPanel.add(Box.createHorizontalGlue()); for (int j = 0; j < filters.get(i).checkBoxes.length; ++j) { checkBoxPanel.add(filters.get(i).checkBoxes[j]); checkBoxPanel.add(Box.createHorizontalGlue()); } constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.anchor = GridBagConstraints.EAST; constraints.weightx = 1.0; filtersPanel.add(checkBoxPanel, constraints); } } JButton clearSearchButton = new JButton( messageSource.getMessage( "mainForm.button.clear.title", null, localeHolder.getLocale())); clearSearchButton.setPreferredSize(new Dimension(500, 20)); clearSearchButton.setMaximumSize(new Dimension(500, 20)); clearSearchButton.setMinimumSize(new Dimension(500, 20)); constraints.gridx = 1; constraints.gridy = filters.size() + 1; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.anchor = GridBagConstraints.EAST; constraints.weightx = 1.0; clearSearchButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (FilterUnit filterUnit : filters) { if (filterUnit.label != null) { filterUnit.textField.setText(""); } else if (filterUnit.checkBoxes != null) { for (int j = 0; j < filterUnit.checkBoxes.length; ++j) { filterUnit.checkBoxes[j].setSelected(true); } } } } }); filtersPanel.add(clearSearchButton, constraints); sorter = new TableRowSorter<>(tableModel); cardAnalyzeComponent.initializeComponents(tableModel, messageSource, localeHolder); }