List of usage examples for javax.swing JButton setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:org.drugis.addis.gui.WelcomeDialog.java
private JButton createButton(String text, String icon, AbstractAction action) { JButton button = new JButton(text, Main.IMAGELOADER.getIcon(icon)); button.setPreferredSize(new Dimension(BUTTON_WIDTH, COMP_HEIGHT)); button.setHorizontalAlignment(SwingConstants.LEFT); button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); button.addActionListener(action);/* ww w . j a v a2s . c o m*/ return button; }
From source file:org.eclipse.om2m.ipe.sample.gui.GUI.java
/** * Creates the frame.//w ww.j av a2 s .c o m */ public GUI() { setLocationByPlatform(true); setVisible(false); setResizable(false); setTitle("Sample Simulated IPE"); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width - 500) / 2, (screenSize.height - 570) / 2, 497, 570); contentPanel = new JPanel(); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPanel); contentPanel.setLayout(null); // Lamp0 Switcher0 JPanel panel_Lamp0 = new JPanel(); panel_Lamp0.setBounds(10, 5, 319, 260); contentPanel.add(panel_Lamp0); panel_Lamp0.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_Lamp0.setLayout(null); LABEL_LAMP_0.setIcon(iconLampOFF); LABEL_LAMP_0.setHorizontalTextPosition(SwingConstants.CENTER); LABEL_LAMP_0.setHorizontalAlignment(SwingConstants.CENTER); LABEL_LAMP_0.setBounds(10, 9, 149, 240); panel_Lamp0.add(LABEL_LAMP_0); // Lamp0 Switch Button JButton button_Lamp0 = new JButton(); button_Lamp0.setOpaque(false); button_Lamp0.setPressedIcon(iconButtonON); button_Lamp0.setIcon(iconButtonOFF); button_Lamp0.setBounds(187, 44, 122, 155); panel_Lamp0.add(button_Lamp0); button_Lamp0.setMinimumSize(new Dimension(30, 23)); button_Lamp0.setMaximumSize(new Dimension(30, 23)); button_Lamp0.setPreferredSize(new Dimension(30, 23)); JLabel labelSwitcher0 = new JLabel("Switch LAMP_0"); labelSwitcher0.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14)); labelSwitcher0.setFocusCycleRoot(true); labelSwitcher0.setBorder(null); labelSwitcher0.setAutoscrolls(true); labelSwitcher0.setBounds(187, 199, 118, 29); panel_Lamp0.add(labelSwitcher0); // Listener for Lamp0 Switch Button button_Lamp0.addActionListener(new java.awt.event.ActionListener() { // Button Clicked public void actionPerformed(java.awt.event.ActionEvent evt) { // Change Lamp0 State new Thread() { public void run() { // Send switch request to switch lamp0 state SampleMonitor.switchLamp(LAMP_0); } }.start(); } }); // Lamp1 Switcher 1 JPanel panel_Lamp1 = new JPanel(); panel_Lamp1.setBounds(10, 271, 319, 260); contentPanel.add(panel_Lamp1); panel_Lamp1.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_Lamp1.setLayout(null); LABEL_LAMP_1.setIcon(iconLampOFF); LABEL_LAMP_1.setHorizontalTextPosition(SwingConstants.CENTER); LABEL_LAMP_1.setHorizontalAlignment(SwingConstants.CENTER); LABEL_LAMP_1.setBounds(10, 9, 154, 240); panel_Lamp1.add(LABEL_LAMP_1); // Lamp1 Switch Button JButton button_Lamp1 = new JButton(); button_Lamp1.setOpaque(false); button_Lamp1.setPressedIcon(iconButtonON); button_Lamp1.setIcon(iconButtonOFF); button_Lamp1.setBounds(187, 44, 122, 156); panel_Lamp1.add(button_Lamp1); button_Lamp1.setMinimumSize(new Dimension(30, 23)); button_Lamp1.setMaximumSize(new Dimension(30, 23)); button_Lamp1.setPreferredSize(new Dimension(30, 23)); JLabel labelSwitcher1 = new JLabel("Switch LAMP_1"); labelSwitcher1.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14)); labelSwitcher1.setFocusCycleRoot(true); labelSwitcher1.setBorder(null); labelSwitcher1.setAutoscrolls(true); labelSwitcher1.setBounds(187, 199, 118, 29); panel_Lamp1.add(labelSwitcher1); // Listener for Lamp1 Switch Button button_Lamp1.addActionListener(new java.awt.event.ActionListener() { //Switch Button clicked public void actionPerformed(java.awt.event.ActionEvent evt) { // Change Lamp1 State new Thread() { public void run() { // Send switch request to switch lamp1 state SampleMonitor.switchLamp(LAMP_1); } }.start(); } }); // Switcher All lamps JButton buttonAllLamp = new JButton(); buttonAllLamp.setOpaque(false); buttonAllLamp.setPressedIcon(iconButtonON); buttonAllLamp.setIcon(iconButtonOFF); buttonAllLamp.setBounds(339, 190, 145, 168); contentPanel.add(buttonAllLamp); buttonAllLamp.setMinimumSize(new Dimension(30, 23)); buttonAllLamp.setMaximumSize(new Dimension(30, 23)); buttonAllLamp.setPreferredSize(new Dimension(30, 23)); JLabel labelSwitchAll = new JLabel("Switch All"); labelSwitchAll.setAutoscrolls(true); labelSwitchAll.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14)); labelSwitchAll.setFocusCycleRoot(true); labelSwitchAll.setBorder(null); labelSwitchAll.setBounds(371, 369, 85, 29); contentPanel.add(labelSwitchAll); // Listener of Switch all Button buttonAllLamp.addActionListener(new java.awt.event.ActionListener() { // Switch Button Clicked public void actionPerformed(java.awt.event.ActionEvent evt) { // Change all lamps states new Thread() { public void run() { // Send switch all request to create a content with the current State SampleMonitor.switchAll(); } }.start(); } }); lampObserver = new SampleModel.LampObserver() { @Override public void onLampStateChange(String lampId, boolean state) { setLabel(lampId, state); } }; SampleModel.addObserver(lampObserver); }
From source file:org.eclipse.om2m.ipu.sample.GUI.java
/** * Creates the frame./*from w w w.ja v a 2s. c o m*/ */ public GUI() { setLocationByPlatform(true); setResizable(false); setTitle("Sample Simulated IPU"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width - 500) / 2, (screenSize.height - 570) / 2, 497, 570); contentPanel = new JPanel(); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPanel); contentPanel.setLayout(null); // Lamp0 Switcher0 JPanel panel_Lamp0 = new JPanel(); panel_Lamp0.setBounds(10, 5, 319, 260); contentPanel.add(panel_Lamp0); panel_Lamp0.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_Lamp0.setLayout(null); LABEL_LAMP_0.setIcon(iconLampOFF); LABEL_LAMP_0.setHorizontalTextPosition(SwingConstants.CENTER); LABEL_LAMP_0.setHorizontalAlignment(SwingConstants.CENTER); LABEL_LAMP_0.setBounds(10, 9, 149, 240); panel_Lamp0.add(LABEL_LAMP_0); // Lamp0 Switch Button JButton button_Lamp0 = new JButton(); button_Lamp0.setOpaque(false); button_Lamp0.setPressedIcon(iconButtonON); button_Lamp0.setIcon(iconButtonOFF); button_Lamp0.setBounds(187, 44, 122, 155); panel_Lamp0.add(button_Lamp0); button_Lamp0.setMinimumSize(new Dimension(30, 23)); button_Lamp0.setMaximumSize(new Dimension(30, 23)); button_Lamp0.setPreferredSize(new Dimension(30, 23)); JLabel labelSwitcher0 = new JLabel("Switch LAMP_0"); labelSwitcher0.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14)); labelSwitcher0.setFocusCycleRoot(true); labelSwitcher0.setBorder(null); labelSwitcher0.setAutoscrolls(true); labelSwitcher0.setBounds(187, 199, 118, 29); panel_Lamp0.add(labelSwitcher0); // Listener for Lamp0 Switch Button button_Lamp0.addActionListener(new java.awt.event.ActionListener() { // Button Clicked public void actionPerformed(java.awt.event.ActionEvent evt) { // Change Lamp0 State new Thread() { public void run() { // Send switch request to switch lamp0 state Switchs.switchLamp(LAMP_0, !SampleMonitor.LAMPS.get(LAMP_0).getState()); } }.start(); } }); // Lamp1 Switcher 1 JPanel panel_Lamp1 = new JPanel(); panel_Lamp1.setBounds(10, 271, 319, 260); contentPanel.add(panel_Lamp1); panel_Lamp1.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_Lamp1.setLayout(null); LABEL_LAMP_1.setIcon(iconLampOFF); LABEL_LAMP_1.setHorizontalTextPosition(SwingConstants.CENTER); LABEL_LAMP_1.setHorizontalAlignment(SwingConstants.CENTER); LABEL_LAMP_1.setBounds(10, 9, 154, 240); panel_Lamp1.add(LABEL_LAMP_1); // Lamp1 Switch Button JButton button_Lamp1 = new JButton(); button_Lamp1.setOpaque(false); button_Lamp1.setPressedIcon(iconButtonON); button_Lamp1.setIcon(iconButtonOFF); button_Lamp1.setBounds(187, 44, 122, 156); panel_Lamp1.add(button_Lamp1); button_Lamp1.setMinimumSize(new Dimension(30, 23)); button_Lamp1.setMaximumSize(new Dimension(30, 23)); button_Lamp1.setPreferredSize(new Dimension(30, 23)); JLabel labelSwitcher1 = new JLabel("Switch LAMP_1"); labelSwitcher1.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14)); labelSwitcher1.setFocusCycleRoot(true); labelSwitcher1.setBorder(null); labelSwitcher1.setAutoscrolls(true); labelSwitcher1.setBounds(187, 199, 118, 29); panel_Lamp1.add(labelSwitcher1); // Listener for Lamp1 Switch Button button_Lamp1.addActionListener(new java.awt.event.ActionListener() { //Switch Button clicked public void actionPerformed(java.awt.event.ActionEvent evt) { // Change Lamp1 State new Thread() { public void run() { // Send switch request to switch lamp1 state Switchs.switchLamp(LAMP_1, !SampleMonitor.LAMPS.get(LAMP_1).getState()); } }.start(); } }); // Switcher All lamps JButton buttonAllLamp = new JButton(); buttonAllLamp.setOpaque(false); buttonAllLamp.setPressedIcon(iconButtonON); buttonAllLamp.setIcon(iconButtonOFF); buttonAllLamp.setBounds(339, 190, 145, 168); contentPanel.add(buttonAllLamp); buttonAllLamp.setMinimumSize(new Dimension(30, 23)); buttonAllLamp.setMaximumSize(new Dimension(30, 23)); buttonAllLamp.setPreferredSize(new Dimension(30, 23)); JLabel labelSwitchAll = new JLabel("Switch All"); labelSwitchAll.setAutoscrolls(true); labelSwitchAll.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14)); labelSwitchAll.setFocusCycleRoot(true); labelSwitchAll.setBorder(null); labelSwitchAll.setBounds(371, 369, 85, 29); contentPanel.add(labelSwitchAll); // Listener of Switch all Button buttonAllLamp.addActionListener(new java.awt.event.ActionListener() { // Switch Button Clicked public void actionPerformed(java.awt.event.ActionEvent evt) { // Change all lamps states new Thread() { public void run() { // Send switch all request to create a content with the current State Switchs.switchAll(!(SampleMonitor.LAMPS.get(LAMP_0).getState() && SampleMonitor.LAMPS.get(LAMP_1).getState())); } }.start(); } }); }
From source file:org.richie.codeGen.ui.GenAndPreviewUI.java
/** * ??/*from ww w .j ava2s .com*/ * * @param fileName * @param fileContent */ private void addPreviewTablePanel(String fileName, String fileContent) { final JScrollPane content = new JScrollPane(); JTextArea viewTextArea = new JTextArea(); viewTextArea.setText(fileContent); content.setViewportView(viewTextArea); JPanel tab = new JPanel(); tab.setOpaque(false); JLabel tabLabel = new JLabel(fileName); ImageIcon closeXIcon = new ImageIcon(ClassLoader.getSystemResource("resources/images/close.gif")); JButton tabCloseButton = new JButton(closeXIcon); tabCloseButton.setToolTipText("close"); tabCloseButton.setBorder(null); tabCloseButton.setContentAreaFilled(false); tabCloseButton.setPreferredSize(new Dimension(closeXIcon.getIconWidth(), closeXIcon.getIconHeight())); tabCloseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int closeTabNumber = mainPanel.indexOfComponent(content); mainPanel.removeTabAt(closeTabNumber); } }); tab.add(tabLabel, BorderLayout.WEST); tab.add(tabCloseButton, BorderLayout.EAST); mainPanel.addTab(null, content); mainPanel.setTabComponentAt(mainPanel.getTabCount() - 1, tab); mainPanel.setSelectedComponent(content); }
From source file:org.tinymediamanager.ui.tvshows.dialogs.TvShowEpisodeEditorDialog.java
/** * Instantiates a new tv show episode scrape dialog. * /*from www .j a va 2s . c o m*/ * @param episode * the episode * @param inQueue * the in queue */ public TvShowEpisodeEditorDialog(TvShowEpisode episode, boolean inQueue) { super(BUNDLE.getString("tvshowepisode.scrape"), "tvShowEpisodeScraper"); //$NON-NLS-1$ setBounds(5, 5, 964, 632); for (MediaFile mf : episode.getMediaFiles()) { mediaFiles.add(new MediaFile(mf)); } this.episodeToEdit = episode; getContentPane().setLayout(new BorderLayout()); { JPanel panelFilename = new JPanel(); getContentPane().add(panelFilename, BorderLayout.NORTH); panelFilename.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("15px"), FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblFilenameT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$ panelFilename.add(lblFilenameT, "2, 2, left, top"); lblFilename = new JLabel(""); TmmFontHelper.changeFont(lblFilename, 1.166, Font.BOLD); panelFilename.add(lblFilename, "5, 2, left, top"); } JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.NORTH); getContentPane().add(tabbedPane, BorderLayout.CENTER); /** * DetailsPanel */ { JPanel detailsPanel = new JPanel(); tabbedPane.addTab(BUNDLE.getString("metatag.details"), detailsPanel); //$NON-NLS-1$ detailsPanel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("40dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("20dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("30dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"), FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("35dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblTitle = new JLabel(BUNDLE.getString("metatag.title")); //$NON-NLS-1$ detailsPanel.add(lblTitle, "2, 4, right, default"); tfTitle = new JTextField(); detailsPanel.add(tfTitle, "4, 4, 19, 1"); tfTitle.setColumns(10); JLabel lblSeason = new JLabel(BUNDLE.getString("metatag.season")); //$NON-NLS-1$ detailsPanel.add(lblSeason, "2, 6, right, default"); spSeason = new JSpinner(); detailsPanel.add(spSeason, "4, 6"); JLabel lblEpisode = new JLabel(BUNDLE.getString("metatag.episode")); //$NON-NLS-1$ detailsPanel.add(lblEpisode, "8, 6, right, default"); spEpisode = new JSpinner(); detailsPanel.add(spEpisode, "10, 6"); JLabel lblDvdSeason = new JLabel(BUNDLE.getString("metatag.dvdseason")); //$NON-NLS-1$ detailsPanel.add(lblDvdSeason, "2, 8, right, default"); spDvdSeason = new JSpinner(); detailsPanel.add(spDvdSeason, "4, 8"); JLabel lblDvdEpisode = new JLabel(BUNDLE.getString("metatag.dvdepisode")); //$NON-NLS-1$ detailsPanel.add(lblDvdEpisode, "8, 8, right, default"); spDvdEpisode = new JSpinner(); detailsPanel.add(spDvdEpisode, "10, 8"); JLabel lblDvdOrder = new JLabel(BUNDLE.getString("metatag.dvdorder")); //$NON-NLS-1$ detailsPanel.add(lblDvdOrder, "14, 8, right, default"); cbDvdOrder = new JCheckBox(""); detailsPanel.add(cbDvdOrder, "16, 8"); cbDvdOrder.setSelected(episodeToEdit.isDvdOrder()); JLabel lblDisplaySeason = new JLabel(BUNDLE.getString("metatag.displayseason")); //$NON-NLS-1$ detailsPanel.add(lblDisplaySeason, "2, 10, right, default"); spDisplaySeason = new JSpinner(); detailsPanel.add(spDisplaySeason, "4, 10"); JLabel lblDisplayEpisode = new JLabel(BUNDLE.getString("metatag.displayepisode")); //$NON-NLS-1$ detailsPanel.add(lblDisplayEpisode, "8, 10, right, default"); spDisplayEpisode = new JSpinner(); detailsPanel.add(spDisplayEpisode, "10, 10"); JLabel lblRating = new JLabel(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$ detailsPanel.add(lblRating, "2, 12, right, default"); spRating = new JSpinner(); detailsPanel.add(spRating, "4, 12"); JLabel lblFirstAired = new JLabel(BUNDLE.getString("metatag.aired")); //$NON-NLS-1$ detailsPanel.add(lblFirstAired, "8, 12, right, default"); dpFirstAired = new DatePicker(episode.getFirstAired()); detailsPanel.add(dpFirstAired, "10, 12, 3, 1, fill, default"); JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$ detailsPanel.add(lblWatched, "2, 14, right, default"); chckbxWatched = new JCheckBox(""); detailsPanel.add(chckbxWatched, "4, 14"); JLabel lblDateAdded = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$ detailsPanel.add(lblDateAdded, "8, 14, right, default"); spDateAdded = new JSpinner(new SpinnerDateModel()); detailsPanel.add(spDateAdded, "10, 14, 3, 1, fill, default"); JLabel lblMediasource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$ detailsPanel.add(lblMediasource, "2, 16, right, default"); cbMediaSource = new JComboBox(MediaSource.values()); detailsPanel.add(cbMediaSource, "4, 16, 4, 1, fill, default"); JLabel lblPlot = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$ detailsPanel.add(lblPlot, "2, 18, right, top"); JScrollPane scrollPane = new JScrollPane(); detailsPanel.add(scrollPane, "4, 18, 13, 1, fill, fill"); taPlot = new JTextArea(); taPlot.setLineWrap(true); taPlot.setWrapStyleWord(true); scrollPane.setViewportView(taPlot); lblThumb = new ImageLabel(); lblThumb.setAlternativeText(BUNDLE.getString("image.notfound.thumb")); //$NON-NLS-1$ lblThumb.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { Path file = TmmUIHelper.selectFile(BUNDLE.getString("image.choose")); //$NON-NLS-1$ if (file != null && Utils.isRegularFile(file)) { String fileName = file.toAbsolutePath().toString(); lblThumb.setImageUrl("file:/" + fileName); } } }); lblThumb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); detailsPanel.add(lblThumb, "20, 6, 3, 13"); JLabel lblDirector = new JLabel(BUNDLE.getString("metatag.director")); //$NON-NLS-1$ detailsPanel.add(lblDirector, "2, 20, right, default"); tfDirector = new JTextField(); tfDirector.setText((String) null); tfDirector.setColumns(10); detailsPanel.add(tfDirector, "4, 20, 13, 1, fill, default"); JLabel lblWriter = new JLabel(BUNDLE.getString("metatag.writer")); //$NON-NLS-1$ detailsPanel.add(lblWriter, "2, 22, right, default"); tfWriter = new JTextField(); tfWriter.setText((String) null); tfWriter.setColumns(10); detailsPanel.add(tfWriter, "4, 22, 13, 1, fill, default"); JLabel lblGuests = new JLabel(BUNDLE.getString("metatag.guests")); //$NON-NLS-1$ detailsPanel.add(lblGuests, "2, 24, right, top"); JScrollPane scrollPaneGuests = new JScrollPane(); detailsPanel.add(scrollPaneGuests, "4, 24, 13, 7, fill, fill"); tableGuests = new JTable(); tableGuests.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); scrollPaneGuests.setViewportView(tableGuests); JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$ detailsPanel.add(lblTags, "20, 24, default, top"); JScrollPane scrollPaneTags = new JScrollPane(); detailsPanel.add(scrollPaneTags, "22, 24, 1, 5, fill, fill"); listTags = new JList(); scrollPaneTags.setViewportView(listTags); JButton btnAddActor = new JButton(""); btnAddActor.setMargin(new Insets(2, 2, 2, 2)); btnAddActor.setAction(new AddActorAction()); btnAddActor.setIcon(IconManager.LIST_ADD); detailsPanel.add(btnAddActor, "2, 26, right, top"); JButton btnAddTag = new JButton(""); btnAddTag.setMargin(new Insets(2, 2, 2, 2)); btnAddTag.setAction(new AddTagAction()); btnAddTag.setIcon(IconManager.LIST_ADD); detailsPanel.add(btnAddTag, "20, 26, right, top"); JButton btnRemoveActor = new JButton(""); btnRemoveActor.setMargin(new Insets(2, 2, 2, 2)); btnRemoveActor.setAction(new RemoveActorAction()); btnRemoveActor.setIcon(IconManager.LIST_REMOVE); detailsPanel.add(btnRemoveActor, "2, 28, right, top"); JButton btnRemoveTag = new JButton(""); btnRemoveTag.setMargin(new Insets(2, 2, 2, 2)); btnRemoveTag.setAction(new RemoveTagAction()); btnRemoveTag.setIcon(IconManager.LIST_REMOVE); detailsPanel.add(btnRemoveTag, "20, 28, right, top"); cbTags = new AutocompleteComboBox(tvShowList.getTagsInEpisodes().toArray()); cbTags.setEditable(true); detailsPanel.add(cbTags, "22, 30, fill, default"); } /** * Media Files panel */ { mediaFilesPanel = new MediaFileEditorPanel(mediaFiles); tabbedPane.addTab(BUNDLE.getString("metatag.mediafiles"), null, mediaFilesPanel, null); //$NON-NLS-1$ } { JPanel bottomPanel = new JPanel(); getContentPane().add(bottomPanel, BorderLayout.SOUTH); bottomPanel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("25px"), FormFactory.RELATED_GAP_ROWSPEC, })); cbScraper = new MediaScraperComboBox(tvShowList.getAvailableMediaScrapers()); MediaScraper defaultScraper = tvShowList.getDefaultMediaScraper(); cbScraper.setSelectedItem(defaultScraper); bottomPanel.add(cbScraper, "2, 2, fill, default"); JButton btnScrape = new JButton(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$ btnScrape.setPreferredSize(new Dimension(100, 23)); btnScrape.setMaximumSize(new Dimension(0, 0)); btnScrape.setMinimumSize(new Dimension(100, 23)); btnScrape.setActionCommand("Scrape"); btnScrape.addActionListener(this); bottomPanel.add(btnScrape, "4, 2, left, fill"); JButton btnSearch = new JButton(BUNDLE.getString("tvshowepisodechooser.search")); //$NON-NLS-1$ btnSearch.setActionCommand("Search"); btnSearch.addActionListener(this); btnSearch.setIcon(IconManager.SEARCH); bottomPanel.add(btnSearch, "6, 2, left, fill"); { JPanel buttonPane = new JPanel(); bottomPanel.add(buttonPane, "8, 2, fill, fill"); EqualsLayout layout = new EqualsLayout(5); layout.setMinWidth(100); buttonPane.setLayout(layout); JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$ okButton.setToolTipText(BUNDLE.getString("tvshow.change")); okButton.setIcon(IconManager.APPLY); buttonPane.add(okButton); okButton.setActionCommand("OK"); okButton.addActionListener(this); JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$ cancelButton.setToolTipText(BUNDLE.getString("edit.discard")); cancelButton.setIcon(IconManager.CANCEL); buttonPane.add(cancelButton); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); if (inQueue) { JButton abortButton = new JButton(BUNDLE.getString("Button.abortqueue")); //$NON-NLS-1$ abortButton.setToolTipText(BUNDLE.getString("tvshow.edit.abortqueue.desc")); //$NON-NLS-1$ abortButton.setIcon(IconManager.PROCESS_STOP); buttonPane.add(abortButton); abortButton.setActionCommand("Abort"); abortButton.addActionListener(this); } } } initDataBindings(); // fill data { MediaFile mediaFile = episodeToEdit.getMediaFiles().get(0); lblFilename.setText(mediaFile.getFileAsPath().toString()); tfTitle.setText(episodeToEdit.getTitle()); spSeason.setModel(new SpinnerNumberModel(episodeToEdit.getAiredSeason(), -1, Integer.MAX_VALUE, 1)); spEpisode.setModel(new SpinnerNumberModel(episodeToEdit.getAiredEpisode(), -1, Integer.MAX_VALUE, 1)); spDvdSeason.setModel(new SpinnerNumberModel(episodeToEdit.getDvdSeason(), -1, Integer.MAX_VALUE, 1)); spDvdEpisode.setModel(new SpinnerNumberModel(episodeToEdit.getDvdEpisode(), -1, Integer.MAX_VALUE, 1)); spDisplaySeason .setModel(new SpinnerNumberModel(episodeToEdit.getDisplaySeason(), -1, Integer.MAX_VALUE, 1)); spDisplayEpisode .setModel(new SpinnerNumberModel(episodeToEdit.getDisplayEpisode(), -1, Integer.MAX_VALUE, 1)); spDateAdded.setValue(episodeToEdit.getDateAdded()); lblThumb.setImagePath(episodeToEdit.getArtworkFilename(MediaFileType.THUMB)); spRating.setModel(new SpinnerNumberModel(episodeToEdit.getRating(), 0.0, 10.0, 0.1)); spRating.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { voteCount = 1; } }); voteCount = episodeToEdit.getVotes(); chckbxWatched.setSelected(episodeToEdit.isWatched()); taPlot.setText(episodeToEdit.getPlot()); taPlot.setCaretPosition(0); tfDirector.setText(episodeToEdit.getDirector()); tfWriter.setText(episodeToEdit.getWriter()); cbMediaSource.setSelectedItem(episodeToEdit.getMediaSource()); for (TvShowActor origCast : episodeToEdit.getGuests()) { TvShowActor actor = new TvShowActor(); actor.setName(origCast.getName()); actor.setCharacter(origCast.getCharacter()); actor.setThumbUrl(origCast.getThumbUrl()); cast.add(actor); } for (String tag : episodeToEdit.getTags()) { tags.add(tag); } } // adjust table columns tableGuests.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$ tableGuests.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$ }
From source file:pcgen.gui2.dialog.OptionsPathDialog.java
private void initComponents() { setResizable(false);/*ww w . jav a 2 s .c om*/ setTitle("Directory for options.ini location"); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); getContentPane().setLayout(new GridBagLayout()); GridBagConstraints gridBagConstraints = new GridBagConstraints(); JLabel label = new JLabel("Select a directory to store PCGen options in:"); gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.insets = new Insets(4, 4, 0, 4); getContentPane().add(label, gridBagConstraints); gridBagConstraints.insets = new Insets(2, 0, 2, 0); getContentPane().add(new JSeparator(), gridBagConstraints); label = new JLabel( "If you have an existing options.ini file," + "then select the directory containing that file"); gridBagConstraints.insets = new Insets(4, 4, 4, 4); getContentPane().add(label, gridBagConstraints); ActionListener handler = new ActionHandler(); ButtonGroup group = new ButtonGroup(); gridBagConstraints.insets = new Insets(0, 4, 0, 4); addRadioButton("<html><b>PCGen Dir</b>: This is the directory that PCGen is installed into", SettingsFilesPath.pcgen.name(), group, handler, gridBagConstraints); // Remark: do mac user really need to be able to put the file either in a specific mac dir or home? if (SystemUtils.IS_OS_MAC_OSX) { addRadioButton("<html><b>Mac User Dir</b>", SettingsFilesPath.mac_user.name(), group, handler, gridBagConstraints); } else if (SystemUtils.IS_OS_UNIX) { // putting it the same way as mac. merging all and using a system config dir instead would be better IMHO. addRadioButton("<html><b>Freedesktop configuration sub-directory</b> Use for most Linux/BSD", SettingsFilesPath.FD_USER.name(), group, handler, gridBagConstraints); } addRadioButton("<html><b>Home Dir</b>: This is your home directory", SettingsFilesPath.user.name(), group, handler, gridBagConstraints); addRadioButton("Select a directory to use", "select", group, handler, gridBagConstraints); dirField.setText(ConfigurationSettings.getSettingsDirFromFilePath(selectedDir)); dirField.setEditable(false); gridBagConstraints.gridwidth = GridBagConstraints.RELATIVE; gridBagConstraints.weightx = 1; gridBagConstraints.insets = new Insets(0, 4, 0, 0); getContentPane().add(dirField, gridBagConstraints); dirButton.setText("..."); dirButton.setEnabled(false); dirButton.addActionListener(handler); dirButton.setActionCommand("custom"); dirButton.setMargin(new Insets(2, 2, 2, 2)); GridBagConstraints bagConstraints = new GridBagConstraints(); bagConstraints.gridwidth = GridBagConstraints.REMAINDER; bagConstraints.insets = new Insets(0, 0, 0, 4); getContentPane().add(dirButton, bagConstraints); JButton okButton = new JButton("OK"); okButton.setPreferredSize(new Dimension(75, 23)); okButton.setActionCommand("ok"); okButton.addActionListener(handler); bagConstraints.insets = new Insets(4, 0, 4, 0); getContentPane().add(okButton, bagConstraints); getRootPane().setDefaultButton(okButton); pack(); setLocationRelativeTo(null); }
From source file:psidev.psi.mi.filemakers.xsd.Utils.java
public static void setDefaultSize(JButton button) { button.setPreferredSize(Utils.buttonsDimension); button.setMinimumSize(Utils.buttonsDimension); button.setMaximumSize(new Dimension(Short.MAX_VALUE, (short) Utils.buttonsDimension.getHeight())); }
From source file:qic.ui.ManualPanel.java
@SuppressWarnings("serial") public ManualPanel(Main main) { super(new BorderLayout(5, 5)); table.setDoubleBuffered(true);//ww w . j ava2s. co m JTextField searchTf = new JTextField(100); JButton runBtn = new JButton("Run"); runBtn.setPreferredSize(new Dimension(200, 10)); JLabel invalidTermsLblLbl = new JLabel(); invalidTermsLblLbl.setFont(invalidTermsLblLbl.getFont().deriveFont(Font.BOLD)); JLabel invalidTermsLbl = new JLabel(); invalidTermsLbl.setForeground(Color.RED); JPanel northPanel = new JPanel(); northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.X_AXIS)); JLabel searchLbl = new JLabel(" Search: "); searchLbl.setFont(searchLbl.getFont().deriveFont(Font.BOLD)); northPanel.add(searchLbl); northPanel.add(searchTf); northPanel.add(invalidTermsLblLbl); northPanel.add(invalidTermsLbl); northPanel.add(runBtn); this.add(northPanel, BorderLayout.NORTH); List<String> searchList = Util.loadSearchList(MANUAL_TXT_FILENAME); searchList.stream().forEach(searchJListModel::addElement); searchJList.setModel(searchJListModel); searchJList.addListSelectionListener(e -> { if (e.getValueIsAdjusting()) { searchTf.setText(trimToEmpty(searchJList.getSelectedValue())); } }); searchJList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { int index = searchJList.locationToIndex(evt.getPoint()); if (index != -1) { String search = trimToEmpty(searchJListModel.getElementAt(index)); searchTf.setText(search); runBtn.doClick(); } } } }); searchJList.getInputMap().put(KeyStroke.getKeyStroke("DELETE"), "doSomething"); searchJList.getActionMap().put("doSomething", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { int selectedIndex = searchJList.getSelectedIndex(); if (selectedIndex != -1) { searchJListModel.remove(selectedIndex); } } }); ActionListener runCommand = e -> { String tfText = searchTf.getText().trim(); if (!tfText.isEmpty()) { Worker<Command> worker = new Worker<Command>(() -> { runBtn.setEnabled(false); Command result = null; try { result = runQuery(main, tfText); } catch (Exception ex) { runBtn.setEnabled(true); SwingUtil.showError(ex); } return result; }, command -> { if (command != null) { if (command.invalidSearchTerms.isEmpty()) { addDataToTable(command); saveSearchToList(tfText); invalidTermsLbl.setText(""); invalidTermsLblLbl.setText(""); if (getBooleanProperty(MANUAL_AUTO_VERIFY, false)) { long sleep = Config.getLongProperty(Config.MANUAL_AUTO_VERIFY_SLEEP, 5000); table.runAutoVerify(sleep); } } else { String invalidTermsStr = command.invalidSearchTerms.stream().collect(joining(", ")); invalidTermsLbl.setText(invalidTermsStr + " "); invalidTermsLblLbl.setText(" Invalid: "); } } runBtn.setEnabled(true); }); worker.execute(); } }; searchTf.addActionListener(runCommand); runBtn.addActionListener(runCommand); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(table), new JScrollPane(searchJList)); this.add(splitPane, BorderLayout.CENTER); }
From source file:rita.ui.component.DialogSelectEnemies.java
/** * Recorre el directorio robots y agrega al panel a todos los robots * (.class) instalados//from w w w . j a v a 2 s .c o m * * @throws FileNotFoundException * si no hay .class en el dir File(Settings.getInstallPath(), * "robots") */ private void addRobotsToPanel(JPanel panel) throws FileNotFoundException { if (Settings.getInstallPath() == null) { throw new FileNotFoundException( "La carpeta de robots no pudo ser encontrara porque InstallPath no esta definido"); } File robotDir = new File(Settings.getInstallPath(), "robots"); if (!robotDir.isDirectory() || !robotDir.canRead()) { //otra carpeta posible MVN robotDir = new File(Settings.getInstallPath() + Settings.getMvnResourcesPath(), "robots"); if (!robotDir.isDirectory() || !robotDir.canRead()) throw new FileNotFoundException( "La carpeta de robots " + robotDir + " no existe o no tiene permisos de lectura"); } boolean robotFound = false; // recorrer directorio robots y traer todos los robots instalados JCheckBox cb; JButton buttonPos; /* * buscar recursivametne a todos los .class en InstallPath() + "robots", * excluyendo a las inner clases, porque asumimos que son clases de * implementacion. Las reconocemos porque tienen '$' en el nombre de la * clase. */ for (File f : FileUtils.listFiles(robotDir, new String[] { "class" }, true)) { if (f.getName().endsWith(".class") && f.getName().indexOf('$') == -1) { String[] splitPath = f.getParent().split(pattern); /* * si el path del robot tiene directorio/nombrerobot.class => el * nombre del robot es "directorio.nombrerobot", sino es solo * "nombrerobot" */ if (splitPath.length > 0) { cb = new JCheckBox(splitPath[splitPath.length - 1] + "." + f.getName().substring(0, f.getName().lastIndexOf('.')), false); } else { cb = new JCheckBox(f.getName().substring(0, f.getName().lastIndexOf('.')), false); } JPanel panelCheckButton = new JPanel(); buttonPos = new JButton(icon); buttonPos.addActionListener(new PosicionRobotAction(cb.getText())); buttonPos.setPreferredSize(new Dimension(30, 30)); positionComponents.add(buttonPos); cb.addActionListener(robotNameClicked); cb.setPreferredSize(new Dimension(160, 30)); panelCheckButton.add(cb); panelCheckButton.add(buttonPos); panel.add(panelCheckButton); robotFound = true; } } if (!robotFound) { throw new FileNotFoundException("La carpeta de robots no contiene robots"); } }
From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java
private void initUI() { setLayout(new GridBagLayout()); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); components = new ArrayList<JComponent>(); checks = new ArrayList<JCheckBox>(); int size = paramList.size(); boolean shouldExpand = false; boolean needScroll = false; for (int i = 0; i < size; i++) { final int pos = i; final QueryParameter param = paramList.get(i); if (param.isHidden()) { components.add(null);//from w w w.j av a 2s . c om checks.add(null); initHiddenParameterValues(param); continue; } String source = param.getSource(); String defaultSource = param.getDefaultSource(); if ((defaultSource != null) && !defaultSource.trim().equals("")) { try { param.setDefaultSourceValues(Globals.getDBViewer().getDefaultSourceValues(con, param)); } catch (NextSqlException e) { Show.error(e); } } final JComponent component; int anchor = GridBagConstraints.WEST; double y = 0.0; int expand = GridBagConstraints.HORIZONTAL; if ((source != null) && !source.equals("")) { List<IdName> values = new ArrayList<IdName>(); try { if (param.isManualSource()) { if (!param.isDependent()) { values = Globals.getDBViewer().getValues(con, source, true, param.getOrderBy()); } } else { int index = source.indexOf("."); int index2 = source.lastIndexOf("."); String tableName = source.substring(0, index); String columnName; String shownColumnName = null; if (index == index2) { columnName = source.substring(index + 1); } else { columnName = source.substring(index + 1, index2); shownColumnName = source.substring(index2 + 1); } values = Globals.getDBViewer().getColumnValues(con, param.getSchema(), tableName, columnName, shownColumnName, param.getOrderBy()); } } catch (NextSqlException e) { error = true; Show.error(e); } catch (InvalidSqlException e) { String m = I18NSupport.getString("source.dialog.valid"); Show.info(m + " : \"select <exp1> , <exp2> from ...\""); } if (param.getSelection().equals(ParameterEditPanel.SINGLE_SELECTION)) { component = new JComboBox(); final JComboBox combo = (JComboBox) component; combo.setRenderer(new IdNameRenderer()); combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --"); for (int j = 0, len = values.size(); j < len; j++) { combo.addItem(values.get(j)); } combo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { IdName in = null; if (combo.getSelectedIndex() > 0) { in = (IdName) combo.getSelectedItem(); } parameterSelection(pos, in); } } }); AutoCompleteDecorator.decorate(combo); needScroll = false; } else { anchor = GridBagConstraints.NORTHWEST; y = 1.0; expand = GridBagConstraints.BOTH; DefaultListModel model = new DefaultListModel(); for (int j = 0, len = values.size(); j < len; j++) { model.addElement(values.get(j)); } List srcList = Arrays.asList(model.toArray()); component = new ListSelectionPanel(srcList, new ArrayList(), "", "", true, false) { protected void onAdd() { selection(); } protected void onRemove() { selection(); } // needed for saved parameters on rerun protected void onSetRight() { selection(); } private void selection() { if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) { Object[] values = getDestinationElements().toArray(); if (values.length == 0) { values = new Object[] { ParameterUtil.NULL }; } parameterSelection(pos, values); } } }; ((ListSelectionPanel) component).setListSize(scrListDim); ((ListSelectionPanel) component).setRenderer(new IdNameRenderer(), new IdNameComparator(param.getOrderBy())); shouldExpand = true; } } else { if (param.getSelection().equals(QueryParameter.MULTIPLE_SELECTION)) { anchor = GridBagConstraints.NORTHWEST; y = 1.0; expand = GridBagConstraints.BOTH; ; component = new ListAddPanel(param) { protected void onAdd() { selection(); } protected void onRemove() { selection(); } private void selection() { if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) { Object[] values = getElements().toArray(); parameterSelection(pos, values); } } }; } else { needScroll = false; if (param.getValueClassName().equals("java.util.Date")) { component = new JXDatePicker(); ((JXDatePicker) component).addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("date".equals(e.getPropertyName())) { parameterSelection(pos, ((JXDatePicker) component).getDate()); } } }); // hack to fix bug with big popup button JButton popupButton = (JButton) component.getComponent(1); //popupButton.setMargin(new Insets(2, 2, 2, 2)); popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY)); } else if (param.getValueClassName().equals("java.sql.Timestamp") || param.getValueClassName().equals("java.sql.Time")) { component = new JDateTimePicker() { protected void onChange() { parameterSelection(pos, getDate()); } }; // hack to fix bug with big popup button JButton popupButton = (JButton) (((JDateTimePicker) component).getDatePicker()) .getComponent(1); //popupButton.setMargin(new Insets(2, 2, 2, 2)); popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY)); } else if (param.getValueClassName().equals("java.lang.Boolean")) { component = new JCheckBox(); ((JCheckBox) component).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); parameterSelection(pos, selected); } }); } else { component = new JTextField(25); ((JTextField) component).getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { updateFromTextField(e); } @Override public void insertUpdate(DocumentEvent e) { updateFromTextField(e); } @Override public void removeUpdate(DocumentEvent e) { updateFromTextField(e); } private void updateFromTextField(DocumentEvent e) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { Object value = null; try { if ("".equals(((JTextField) component).getText().trim())) { value = null; } else { value = ParameterUtil.getParameterValueFromString( param.getValueClassName(), ((JTextField) component).getText()); } parameterSelection(pos, value); } catch (Exception e) { e.printStackTrace(); LOG.error(e.getMessage(), e); } } }); } }); } } } components.add(component); final JCheckBox cb = new JCheckBox(I18NSupport.getString("run.parameter.ignore")); checks.add(cb); final JLabel label = new JLabel(getRuntimeParameterName(param)); panel.add(label, new GridBagConstraints(0, i, 1, 1, 0.0, 0.0, anchor, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); final JComponent addComponent; if (needScroll) { JScrollPane scr = new JScrollPane(component, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scr.setPreferredSize(listDim); addComponent = scr; } else { addComponent = component; } panel.add(addComponent, new GridBagConstraints(1, i, 1, 1, 1.0, y, GridBagConstraints.WEST, expand, new Insets(5, 0, 5, 5), 0, 0)); int checkAnchor = GridBagConstraints.WEST; if ((addComponent instanceof JScrollPane) || (addComponent instanceof ListSelectionPanel)) { checkAnchor = GridBagConstraints.NORTHWEST; } if (Globals.getParametersIgnore()) { panel.add(cb, new GridBagConstraints(2, i, 1, 1, 0.0, 0.0, checkAnchor, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); } cb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (cb.isSelected()) { if (addComponent instanceof JScrollPane) { component.setEnabled(false); } label.setEnabled(false); addComponent.setEnabled(false); param.setIgnore(true); } else { if (addComponent instanceof JScrollPane) { component.setEnabled(true); } label.setEnabled(true); addComponent.setEnabled(true); param.setIgnore(false); } } }); } // populate hidden dependent parameters (this will be done if a parameter depends only on a single hidden parameter) // if a parameter depends on a hidden parameter and other parameters, it cannot be populated here for (int i = 0; i < size; i++) { final QueryParameter param = paramList.get(i); if (param.isHidden()) { populateDependentParameters(param, false); } } if (!shouldExpand) { panel.add(new JLabel(), new GridBagConstraints(0, size, 3, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } JScrollPane scrPanel = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrPanel.setPreferredSize(scrDim); scrPanel.setMinimumSize(scrDim); add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); setParameterValues(parametersValues); setParameterIgnore(parametersIgnore); }