Java Code Examples for javax.swing.JComboBox#addActionListener()

The following examples show how to use javax.swing.JComboBox#addActionListener() . 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: VisualSettings.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a selector for styles.
 *
 * @return combo box with style options
 */
private JComponent createStyleSelector() {
	final JComboBox<String> selector = new JComboBox<>();

	// Fill with available styles
	for (String s : StyleFactory.getAvailableStyles()) {
		selector.addItem(s);
	}

	final WtWindowManager wm = WtWindowManager.getInstance();
	String currentStyle = wm.getProperty(STYLE_PROPERTY, DEFAULT_STYLE);
	selector.setSelectedItem(currentStyle);

	selector.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			Object selected = selector.getSelectedItem();
			wm.setProperty(STYLE_PROPERTY, selected.toString());
			ClientSingletonRepository.getUserInterface().addEventLine(new EventLine("",
					"The new style will be used the next time you start the game client.",
					NotificationType.CLIENT));
		}
	});

	return selector;
}
 
Example 2
Source File: CustomSettingsDialog.java    From swingsane with Apache License 2.0 6 votes vote down vote up
public CustomTableCellEditor(final JComboBox<?> comboBox, final OptionsOrderValuePair vp) {
  super(comboBox);
  comboBox.removeActionListener(delegate);
  valuePair = vp;
  delegate.setValue(comboBox);
  delegate = new EditorDelegate() {
    @Override
    public void setValue(Object val) {
      if (val instanceof JComboBox) {
        if (value == null) {
          value = val;
        }
      }
    }

    @Override
    public boolean stopCellEditing() {
      updateOption(valuePair, (Component) value);
      return true;
    }
  };
  comboBox.addActionListener(delegate);
  setClickCountToStart(1);
}
 
Example 3
Source File: SoundSettings.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a selector for sound devices.
 *
 * @return combo box with device options
 */
private JComponent createDeviceSelector() {
	final JComboBox<String> selector = new JComboBox<>();

	// Fill with available device names
	selector.addItem(DEFAULT_DEVICE);
	for (String name : ClientSingletonRepository.getSound().getDeviceNames()) {
		selector.addItem(name);
	}

	final WtWindowManager wm = WtWindowManager.getInstance();
	String current = wm.getProperty(DEVICE_PROPERTY, DEFAULT_DEVICE);
	selector.setSelectedItem(current);

	selector.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			Object selected = selector.getSelectedItem();
			wm.setProperty(DEVICE_PROPERTY, (selected != null) ? selected.toString() : DEFAULT_DEVICE);
			wm.save();
			// Warn the user about the delayed effect
			String msg = "Changing the sound device will take effect when you next time restart the game.";
			ClientSingletonRepository.getUserInterface().addEventLine(new EventLine("", msg, NotificationType.CLIENT));
		}
	});

	return selector;
}
 
Example 4
Source File: FmtOptions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void addListener( JComponent jc ) {
    if ( jc instanceof JTextField ) {
        JTextField field = (JTextField)jc;
        field.addActionListener(this);
        field.getDocument().addDocumentListener(this);
    }
    else if ( jc instanceof JCheckBox ) {
        JCheckBox checkBox = (JCheckBox)jc;
        checkBox.addActionListener(this);
    }
    else if ( jc instanceof JComboBox) {
        JComboBox cb  = (JComboBox)jc;
        cb.addActionListener(this);
    }
}
 
Example 5
Source File: MultiGradientTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private JComboBox createCombo(JPanel panel, Enum e) {
    JComboBox cmb = new JComboBox();
    cmb.setModel(new EnumComboBoxModel(e.getClass()));
    cmb.addActionListener(this);
    panel.add(cmb);
    return cmb;
}
 
Example 6
Source File: ComboLinker.java    From jdal with Apache License 2.0 5 votes vote down vote up
public ComboLinker(JComboBox<?> primary, JComboBox<?> dependent, String propertyName) {
	this.primary = primary;
	this.dependent = dependent;
	this.propertyName = propertyName;
	
	primary.addActionListener(this);
}
 
Example 7
Source File: MultiGradientTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private JComboBox createCombo(JPanel panel, Enum e) {
    JComboBox cmb = new JComboBox();
    cmb.setModel(new EnumComboBoxModel(e.getClass()));
    cmb.addActionListener(this);
    panel.add(cmb);
    return cmb;
}
 
Example 8
Source File: FilterTopComponent.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private FilterTopComponent() {
    filterSettingsChangedEvent = new ChangedEvent<FilterTopComponent>(this);
    initComponents();
    setName(NbBundle.getMessage(FilterTopComponent.class, "CTL_FilterTopComponent"));
    setToolTipText(NbBundle.getMessage(FilterTopComponent.class, "HINT_FilterTopComponent"));
    //        setIcon(Utilities.loadImage(ICON_PATH, true));

    sequence = new FilterChain();
    filterChain = new FilterChain();
    initFilters();
    manager = new ExplorerManager();
    manager.setRootContext(new AbstractNode(new FilterChildren()));
    associateLookup(ExplorerUtils.createLookup(manager, getActionMap()));
    view = new CheckListView();

    ToolbarPool.getDefault().setPreferredIconSize(16);
    Toolbar toolBar = new Toolbar();
    Border b = (Border) UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N
    toolBar.setBorder(b);
    comboBox = new JComboBox();
    toolBar.add(comboBox);
    this.add(toolBar, BorderLayout.NORTH);
    toolBar.add(SaveFilterSettingsAction.get(SaveFilterSettingsAction.class));
    toolBar.add(RemoveFilterSettingsAction.get(RemoveFilterSettingsAction.class));
    toolBar.addSeparator();
    toolBar.add(MoveFilterUpAction.get(MoveFilterUpAction.class).createContextAwareInstance(this.getLookup()));
    toolBar.add(MoveFilterDownAction.get(MoveFilterDownAction.class).createContextAwareInstance(this.getLookup()));
    toolBar.add(RemoveFilterAction.get(RemoveFilterAction.class).createContextAwareInstance(this.getLookup()));
    toolBar.add(NewFilterAction.get(NewFilterAction.class));
    this.add(view, BorderLayout.CENTER);

    filterSettings = new ArrayList<FilterSetting>();
    updateComboBox();

    comboBox.addActionListener(comboBoxActionListener);
    setChain(filterChain);
}
 
Example 9
Source File: FilterTopComponent.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private FilterTopComponent() {
    filterSettingsChangedEvent = new ChangedEvent<FilterTopComponent>(this);
    initComponents();
    setName(NbBundle.getMessage(FilterTopComponent.class, "CTL_FilterTopComponent"));
    setToolTipText(NbBundle.getMessage(FilterTopComponent.class, "HINT_FilterTopComponent"));
    //        setIcon(Utilities.loadImage(ICON_PATH, true));

    sequence = new FilterChain();
    filterChain = new FilterChain();
    initFilters();
    manager = new ExplorerManager();
    manager.setRootContext(new AbstractNode(new FilterChildren()));
    associateLookup(ExplorerUtils.createLookup(manager, getActionMap()));
    view = new CheckListView();

    ToolbarPool.getDefault().setPreferredIconSize(16);
    Toolbar toolBar = new Toolbar();
    Border b = (Border) UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N
    toolBar.setBorder(b);
    comboBox = new JComboBox();
    toolBar.add(comboBox);
    this.add(toolBar, BorderLayout.NORTH);
    toolBar.add(SaveFilterSettingsAction.get(SaveFilterSettingsAction.class));
    toolBar.add(RemoveFilterSettingsAction.get(RemoveFilterSettingsAction.class));
    toolBar.addSeparator();
    toolBar.add(MoveFilterUpAction.get(MoveFilterUpAction.class).createContextAwareInstance(this.getLookup()));
    toolBar.add(MoveFilterDownAction.get(MoveFilterDownAction.class).createContextAwareInstance(this.getLookup()));
    toolBar.add(RemoveFilterAction.get(RemoveFilterAction.class).createContextAwareInstance(this.getLookup()));
    toolBar.add(NewFilterAction.get(NewFilterAction.class));
    this.add(view, BorderLayout.CENTER);

    filterSettings = new ArrayList<FilterSetting>();
    updateComboBox();

    comboBox.addActionListener(comboBoxActionListener);
    setChain(filterChain);
}
 
Example 10
Source File: RetroWeaverGui.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
private Component createTargetChooser() {
	targetCombo = new JComboBox(new String[] { "1.4", "1.3", "1.2" });
	targetCombo.setSelectedIndex(0);
	targetCombo.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			status.setText(READY);
		}
	});
	return targetCombo;
}
 
Example 11
Source File: SkillEditor.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private JComboBox<Object> createComboBox(Container parent, Object[] items, Object selection, String tooltip) {
    JComboBox<Object> combo = new JComboBox<>(items);
    combo.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
    combo.setSelectedItem(selection);
    combo.addActionListener(this);
    combo.setMaximumRowCount(items.length);
    UIUtilities.setToPreferredSizeOnly(combo);
    combo.setEnabled(mIsEditable);
    parent.add(combo);
    return combo;
}
 
Example 12
Source File: MappingComboBoxHelper.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor initializes object by combo box and data object which will be handled
 *
 * @param synchronizer
 * @param comboBox   handled JComboBox.
 */
public MappingComboBoxHelper(XmlMultiViewDataSynchronizer synchronizer, JComboBox comboBox) {
    this.synchronizer = synchronizer;
    this.comboBox = comboBox;
    comboBox.addActionListener(this);
    setValue(getItemValue());
}
 
Example 13
Source File: BroadcastFrame.java    From JRakNet with MIT License 4 votes vote down vote up
/**
 * Creates a broadcast test frame.
 */
protected BroadcastFrame() {
	// Frame and content settings
	this.setResizable(false);
	this.setSize(FRAME_WIDTH, FRAME_HEIGHT);
	this.setTitle("JRakNet Broadcast Test");
	this.getContentPane().setLayout(null);

	// Discovered MCPE Servers
	JTextPane txtpnDiscoveredMcpeServers = new JTextPane();
	txtpnDiscoveredMcpeServers.setEditable(false);
	txtpnDiscoveredMcpeServers.setBackground(UIManager.getColor("Button.background"));
	txtpnDiscoveredMcpeServers.setText("Discovered servers");
	txtpnDiscoveredMcpeServers.setBounds(10, 10, 350, 20);
	this.getContentPane().add(txtpnDiscoveredMcpeServers);

	// How the client will discover servers on the local network
	JComboBox<String> comboBoxDiscoveryType = new JComboBox<String>();
	comboBoxDiscoveryType.setToolTipText(
			"Changing this will update how the client will discover servers, by default it will look for any possible connection on the network");
	comboBoxDiscoveryType.setModel(new DefaultComboBoxModel<String>(DISCOVERY_MODE_OPTIONS));
	comboBoxDiscoveryType.setBounds(370, 10, 115, 20);
	comboBoxDiscoveryType.addActionListener(new RakNetBroadcastDiscoveryTypeListener());
	this.getContentPane().add(comboBoxDiscoveryType);

	// Used to update the discovery port
	JTextField textFieldDiscoveryPort = new JTextField();
	textFieldDiscoveryPort.setBounds(370, 45, 115, 20);
	textFieldDiscoveryPort.setText(Integer.toString(Discovery.getPorts()[0]));
	this.getContentPane().add(textFieldDiscoveryPort);
	textFieldDiscoveryPort.setColumns(10);
	JButton btnUpdatePort = new JButton("Update Port");
	btnUpdatePort.setBounds(370, 76, 114, 23);
	btnUpdatePort.addActionListener(new RakNetBroadcastUpdatePortListener(textFieldDiscoveryPort));
	this.getContentPane().add(btnUpdatePort);

	// The text containing the discovered MCPE servers
	txtPnDiscoveredMcpeServerList = new JTextPane();
	txtPnDiscoveredMcpeServerList.setToolTipText("This is the list of the discovered servers on the local network");
	txtPnDiscoveredMcpeServerList.setEditable(false);
	txtPnDiscoveredMcpeServerList.setBackground(UIManager.getColor("Button.background"));
	txtPnDiscoveredMcpeServerList.setBounds(10, 30, 350, 165);
	this.getContentPane().add(txtPnDiscoveredMcpeServerList);
}
 
Example 14
Source File: ConnectPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void addConnectors(int defaultIndex) {
    //assert connectorsLoaded.get();
    if (connectors.isEmpty()) {
        // no attaching connectors available => print message only
        add (new JLabel (
            NbBundle.getMessage (ConnectPanel.class, "CTL_No_Connector")
        ));
        return;
    }
    if (connectors.size () > 1) {
        // more than one attaching connector available => 
        // init cbConnectors & selext default connector
        
        cbConnectors = new JComboBox ();
        cbConnectors.getAccessibleContext ().setAccessibleDescription (
            NbBundle.getMessage (ConnectPanel.class, "ACSD_CTL_Connector")
        );
        int i, k = connectors.size ();
        for (i = 0; i < k; i++) {
            Connector connector = connectors.get (i);
            int jj = connector.name ().lastIndexOf ('.');
                          
            String s = (jj < 0) ? 
                connector.name () : 
                connector.name ().substring (jj + 1);
            cbConnectors.addItem (
                s + " (" + connector.description () + ")"
            );
        }
        cbConnectors.setActionCommand ("SwitchMe!");
        cbConnectors.addActionListener (this);
    }
    cbConnectors.setSelectedIndex (defaultIndex);
    selectedConnector = connectors.get(defaultIndex);
    setCursor(standardCursor);
    
    synchronized (connectorsLoaded) {
        connectorsLoaded.set(true);
        connectorsLoaded.notifyAll();
    }
}
 
Example 15
Source File: ComboBoxAdaptor.java    From cropplanning with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new ComobBoxAdaptor for the given combobox.
 * @param comboBox the combobox that should be adapted
 */
public ComboBoxAdaptor(JComboBox comboBox) {
    this.comboBox = comboBox;
    // mark the entire text when a new item is selected
    comboBox.addActionListener(this);
}
 
Example 16
Source File: BinningFilterPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private Component createTemporalFilterPanel() {
    TableLayout layout = new TableLayout(3);
    layout.setTableFill(TableLayout.Fill.BOTH);
    layout.setTableAnchor(TableLayout.Anchor.NORTHWEST);
    layout.setTableWeightX(0.0);
    layout.setTableWeightY(0.0);
    layout.setTablePadding(10, 5);
    layout.setCellColspan(0, 1, 2);
    layout.setCellColspan(3, 1, 2);
    layout.setCellWeightX(2, 1, 1.0);
    layout.setCellWeightX(2, 2, 0.0);
    layout.setColumnWeightX(1, 1.0);

    JPanel panel = new JPanel(layout);
    JLabel temporalFilterLabel = new JLabel("Time filter method:");
    JLabel startDateLabel = new JLabel("Start date:");
    JLabel startDateFormatLabel = new JLabel("yyyy-MM-dd( HH:mm:ss)");
    JLabel periodDurationLabel = new JLabel("Period duration:");
    JLabel minDataHourLabel = new JLabel("Min data hour:");
    JLabel periodDurationUnitLabel = new JLabel("days");

    final JComboBox<BinningOp.TimeFilterMethod> temporalFilterComboBox = new JComboBox<>(new BinningOp.TimeFilterMethod[]{
            NONE,
            TIME_RANGE,
            SPATIOTEMPORAL_DATA_DAY
    });
    temporalFilterComboBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            BinningOp.TimeFilterMethod method = (BinningOp.TimeFilterMethod) temporalFilterComboBox.getSelectedItem();
            if (method != null) {
                temporalFilterComboBox.setToolTipText(timeFilterMethodDescriptions.get(method));
            }
        }
    });
    JTextField startDateTextField = new JTextField();
    JTextField periodDurationTextField = new JTextField();
    JTextField minDataHourTextField = new JTextField();
    startDateLabel.setEnabled(false);
    periodDurationLabel.setEnabled(false);
    temporalFilterLabel.setToolTipText("The method that is used to decide which source pixels are used with respect to their observation time.");
    startDateLabel.setToolTipText("The UTC start date of the binning period. If only the date part is given, the time 00:00:00 is assumed.");
    periodDurationLabel.setToolTipText("Duration of the binning period in days.");
    minDataHourLabel.setToolTipText(
            "A sensor-dependent constant given in hours of a day (0 to 24) at which a sensor has a minimum number of observations at the date line (the 180 degree meridian).");
    BindingContext bindingContext = binningFormModel.getBindingContext();

    bindingContext.bind(BinningFormModel.PROPERTY_KEY_TIME_FILTER_METHOD, temporalFilterComboBox);
    bindingContext.bind(BinningFormModel.PROPERTY_KEY_START_DATE_TIME, startDateTextField);
    bindingContext.bind(BinningFormModel.PROPERTY_KEY_PERIOD_DURATION, periodDurationTextField);
    bindingContext.bind(BinningFormModel.PROPERTY_KEY_MIN_DATA_HOUR, minDataHourTextField);

    bindingContext.getBinding(BinningFormModel.PROPERTY_KEY_START_DATE_TIME).addComponent(startDateLabel);
    bindingContext.getBinding(BinningFormModel.PROPERTY_KEY_START_DATE_TIME).addComponent(startDateFormatLabel);
    bindingContext.getBinding(BinningFormModel.PROPERTY_KEY_PERIOD_DURATION).addComponent(periodDurationLabel);
    bindingContext.getBinding(BinningFormModel.PROPERTY_KEY_PERIOD_DURATION).addComponent(periodDurationUnitLabel);
    bindingContext.getBinding(BinningFormModel.PROPERTY_KEY_MIN_DATA_HOUR).addComponent(minDataHourLabel);

    temporalFilterComboBox.setSelectedIndex(0); // selected value must not be empty when setting enablement

    bindingContext.bindEnabledState(BinningFormModel.PROPERTY_KEY_START_DATE_TIME, true, hasTimeInformation(TIME_RANGE, SPATIOTEMPORAL_DATA_DAY));
    bindingContext.bindEnabledState(BinningFormModel.PROPERTY_KEY_PERIOD_DURATION, true, hasTimeInformation(TIME_RANGE, SPATIOTEMPORAL_DATA_DAY));
    bindingContext.bindEnabledState(BinningFormModel.PROPERTY_KEY_MIN_DATA_HOUR, true, hasTimeInformation(SPATIOTEMPORAL_DATA_DAY));

    temporalFilterComboBox.setSelectedIndex(0); // ensure that enablement is applied

    panel.add(temporalFilterLabel);
    panel.add(temporalFilterComboBox);
    panel.add(startDateLabel);
    panel.add(startDateTextField);
    panel.add(startDateFormatLabel);
    panel.add(periodDurationLabel);
    panel.add(periodDurationTextField);
    panel.add(periodDurationUnitLabel);
    panel.add(minDataHourLabel);
    panel.add(minDataHourTextField);
    return panel;
}
 
Example 17
Source File: QueryWindow.java    From bboxdb with Apache License 2.0 4 votes vote down vote up
/**
 * Add the drop down action listener
 * @param queryTypeBox
 * @param table1Field
 * @param table2Field
 * @param executeButton 
 */
private void addActionListener(final JComboBox<String> queryTypeBox, final JComponent table1Field,
		final JComponent table1ColorField, final JComponent table2Field, final JComponent table2ColorField, 
		final JButton executeButton, final JTextField udfNameField, final JTextField udfValueField) {
	
	queryTypeBox.addActionListener(l -> {
		
		final String selectedQuery = queryTypeBox.getSelectedItem().toString();
		switch (selectedQuery) {
		
		case QUERY_RANGE:
		case QUERY_RANGE_CONTINUOUS:
			table1Field.setEnabled(true);
			table1ColorField.setEnabled(true);
			table2Field.setEnabled(false);
			table2ColorField.setEnabled(false);
			executeButton.setEnabled(true);
			udfNameField.setText("");
			udfValueField.setText("");
			break;
			
		case QUERY_JOIN:
			table1Field.setEnabled(true);
			table1ColorField.setEnabled(true);
			table2Field.setEnabled(true);
			table2ColorField.setEnabled(true);
			executeButton.setEnabled(true);
			udfNameField.setText(UserDefinedGeoJsonSpatialFilter.class.getCanonicalName());
			udfValueField.setText("");
			break;
			
		case QUERY_JOIN_CONTINUOUS:
			table1Field.setEnabled(true);
			table1ColorField.setEnabled(true);
			table2Field.setEnabled(true);
			table2ColorField.setEnabled(true);
			executeButton.setEnabled(true);
			udfNameField.setText(UserDefinedGeoJsonSpatialFilter.class.getCanonicalName());
			udfValueField.setText("Elizabeth Street");
			break;

		default:
			table1Field.setEnabled(false);
			table1ColorField.setEnabled(false);
			table2Field.setEnabled(false);
			table1ColorField.setEnabled(false);
			executeButton.setEnabled(false);
			udfNameField.setText("");
			udfValueField.setText("");
			break;
		}
	});
	
}
 
Example 18
Source File: HierarchyTopComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NbBundle.Messages({
    "TXT_NonActiveContent=<No View Available - Refresh Manually>",
    "TXT_InspectHierarchyHistory=<empty>",
    "TOOLTIP_RefreshContent=Refresh for entity under cursor",
    "TOOLTIP_OpenJDoc=Open Javadoc Window",
    "TOOLTIP_ViewHierarchyType=Hierachy View Type",
    "TOOLTIP_InspectHierarchyHistory=Inspect Hierarchy History"
})
public HierarchyTopComponent() {
    history = HistorySupport.getInstnace(this.getClass());
    jdocFinder = SelectJavadocTask.create(this);
    jdocTask = RP.create(jdocFinder);
    explorerManager = new ExplorerManager();
    rootChildren = new RootChildren();
    filters = new HierarchyFilters();
    explorerManager.setRootContext(Nodes.rootNode(rootChildren, filters));
    selectedNodes  = new InstanceContent();
    lookup = new AbstractLookup(selectedNodes);
    explorerManager.addPropertyChangeListener(this);
    initComponents();
    setName(Bundle.CTL_HierarchyTopComponent());
    setToolTipText(Bundle.HINT_HierarchyTopComponent());        
    viewTypeCombo = new JComboBox(new DefaultComboBoxModel(ViewType.values()));
    viewTypeCombo.setMinimumSize(new Dimension(MIN_TYPE_WIDTH,COMBO_HEIGHT));
    viewTypeCombo.addActionListener(this);
    viewTypeCombo.setToolTipText(Bundle.TOOLTIP_ViewHierarchyType());
    historyCombo = new JComboBox(HistorySupport.createModel(history, Bundle.TXT_InspectHierarchyHistory()));
    historyCombo.setMinimumSize(new Dimension(MIN_HISTORY_WIDTH,COMBO_HEIGHT));
    historyCombo.setRenderer(HistorySupport.createRenderer(history));
    historyCombo.addActionListener(this);
    historyCombo.setEnabled(false);
    historyCombo.getModel().addListDataListener(this);
    historyCombo.setToolTipText(Bundle.TOOLTIP_InspectHierarchyHistory());
    refreshButton = new JButton(ImageUtilities.loadImageIcon(REFRESH_ICON, true));
    refreshButton.addActionListener(this);
    refreshButton.setToolTipText(Bundle.TOOLTIP_RefreshContent());
    jdocButton = new JButton(ImageUtilities.loadImageIcon(JDOC_ICON, true));
    jdocButton.addActionListener(this);
    jdocButton.setToolTipText(Bundle.TOOLTIP_OpenJDoc());
    final Box upperToolBar = new MainToolBar(
        constrainedComponent(viewTypeCombo, GridBagConstraints.HORIZONTAL, 1.0, new Insets(0,0,0,0)),
        constrainedComponent(historyCombo, GridBagConstraints.HORIZONTAL, 1.5, new Insets(0,3,0,0)),
        constrainedComponent(refreshButton, GridBagConstraints.NONE, 0.0, new Insets(0,3,0,0)),
        constrainedComponent(jdocButton, GridBagConstraints.NONE, 0.0, new Insets(0,3,0,3)));
    add(decorateAsUpperPanel(upperToolBar), BorderLayout.NORTH);
    contentView = new JPanel();
    contentView.setLayout(new CardLayout());
    JPanel nonActiveContent = Utils.updateBackground(new JPanel());
    nonActiveContent.setLayout(new BorderLayout());
    nonActiveInfo = new JLabel(Bundle.TXT_NonActiveContent());
    nonActiveInfo.setEnabled(false);
    nonActiveInfo.setHorizontalAlignment(SwingConstants.CENTER);
    nonActiveContent.add(nonActiveInfo, BorderLayout.CENTER);
    btw = createBeanTreeView();
    contentView.add(nonActiveContent, NON_ACTIVE_CONTENT);
    contentView.add(btw, ACTIVE_CONTENT);
    add(contentView,BorderLayout.CENTER);
    lowerToolBar = new TapPanel();
    lowerToolBar.setOrientation(TapPanel.DOWN);
    final JComponent lowerButtons = filters.getComponent();
    lowerButtons.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 0));
    lowerToolBar.add(lowerButtons);
    final boolean expanded = NbPreferences.forModule(HierarchyTopComponent.class).
            getBoolean(PROP_LOWER_TOOLBAR_EXPANDED, true); //NOI18N
    lowerToolBar.setExpanded(expanded);
    lowerToolBar.addPropertyChangeListener(this);
    add(Utils.updateBackground(lowerToolBar), BorderLayout.SOUTH);
}
 
Example 19
Source File: DumpDatabase.java    From DKO with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void buildCard1() {
	JPanel card = new JPanel();
	card.setLayout(new BoxLayout(card, BoxLayout.Y_AXIS));
	JLabel title = new JLabel("Welcome to the DKO Database Dumper!");
	title.setAlignmentX(Component.CENTER_ALIGNMENT);
	title.setBorder(new EmptyBorder(15, 20, 15, 20));
	card.add(title);
	JLabel question = new JLabel("What kind of database are you pulling from?");
	question.setAlignmentX(Component.CENTER_ALIGNMENT);
	question.setBorder(new EmptyBorder(5, 10, 5, 10));
	card.add(question);
	String[] databaseTypes = {"SQL Server"};
	final JComboBox dbTypeSelectBox = new JComboBox(databaseTypes);
	dbTypeSelectBox.setBorder(new EmptyBorder(5, 10, 5, 10));
	card.add(dbTypeSelectBox);
	server = new JTextField("jdbc:sqlserver://server:1433");
	server.setBorder(new EmptyBorder(2, 10, 2, 10));
	username = new JTextField("sa");
	username.setBorder(new EmptyBorder(2, 10, 2, 10));
	password = new JPasswordField("password");
	password.setBorder(new EmptyBorder(2, 10, 2, 10));
	card.add(server);
	card.add(username);
	card.add(password);
	cards.add(card, CARD_1);
	final NextListener nexter = new NextListener() {
		@Override
		public void goNext() {
			new Thread(new SchemaGetter()).start();
			cardStack.add(CARD_2);
			cl.show(cards, CARD_2);
		}
		@Override
		public void show() {
			next.setVisible(true);
			finish.setVisible(false);
			Object selectedItem = dbTypeSelectBox.getModel().getSelectedItem();
			next.setEnabled(!"".equals(selectedItem) && !server.getText().isEmpty());
		}
	};
	dbTypeSelectBox.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			nexter.show();
		}
	});
	nexters.put(CARD_1, nexter);
}
 
Example 20
Source File: PlainTextExportDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Initialize the dialog.
 */
private void init() {
  setTitle( getResources().getString( "plain-text-exportdialog.dialogtitle" ) ); //$NON-NLS-1$
  messages =
      new Messages( Locale.getDefault(), PlainTextExportGUIModule.BUNDLE_NAME, ObjectUtilities
          .getClassLoader( PlainTextExportGUIModule.class ) );
  epson9Printers = loadEpson9Printers();
  epson24Printers = loadEpson24Printers();

  cbEpson9PrinterType = new JComboBox( epson9Printers );
  cbEpson9PrinterType.addActionListener( new SelectEpsonModelAction() );

  cbEpson24PrinterType = new JComboBox( epson24Printers );
  cbEpson24PrinterType.addActionListener( new SelectEpsonModelAction() );

  statusBar = new JStatusBar();

  final Float[] lpiModel = { PlainTextExportDialog.LPI_6, PlainTextExportDialog.LPI_10 };

  final Float[] cpiModel =
  { PlainTextExportDialog.CPI_10, PlainTextExportDialog.CPI_12, PlainTextExportDialog.CPI_15,
    PlainTextExportDialog.CPI_17, PlainTextExportDialog.CPI_20 };

  cbLinesPerInch = new JComboBox( new DefaultComboBoxModel( lpiModel ) );
  cbCharsPerInch = new JComboBox( new DefaultComboBoxModel( cpiModel ) );

  final String plainPrinterName =
      getResources().getString( PlainTextExportDialog.PRINTER_NAMES[PlainTextExportDialog.TYPE_PLAIN_OUTPUT] );
  final String epson9PrinterName =
      getResources().getString( PlainTextExportDialog.PRINTER_NAMES[PlainTextExportDialog.TYPE_EPSON9_OUTPUT] );
  final String epson24PrinterName =
      getResources().getString( PlainTextExportDialog.PRINTER_NAMES[PlainTextExportDialog.TYPE_EPSON24_OUTPUT] );
  final String ibmPrinterName =
      getResources().getString( PlainTextExportDialog.PRINTER_NAMES[PlainTextExportDialog.TYPE_IBM_OUTPUT] );

  rbPlainPrinterCommandSet =
      new JRadioButton( new ActionSelectPrinter( plainPrinterName, PlainTextExportDialog.TYPE_PLAIN_OUTPUT ) );
  rbEpson9PrinterCommandSet =
      new JRadioButton( new ActionSelectPrinter( epson9PrinterName, PlainTextExportDialog.TYPE_EPSON9_OUTPUT ) );
  rbEpson24PrinterCommandSet =
      new JRadioButton( new ActionSelectPrinter( epson24PrinterName, PlainTextExportDialog.TYPE_EPSON24_OUTPUT ) );
  rbIBMPrinterCommandSet =
      new JRadioButton( new ActionSelectPrinter( ibmPrinterName, PlainTextExportDialog.TYPE_IBM_OUTPUT ) );

  txFilename = new JTextField();
  encodingSelector = new EncodingSelector();

  final ButtonGroup bg = new ButtonGroup();
  bg.add( rbPlainPrinterCommandSet );
  bg.add( rbIBMPrinterCommandSet );
  bg.add( rbEpson9PrinterCommandSet );
  bg.add( rbEpson24PrinterCommandSet );

  getFormValidator().registerTextField( txFilename );
  getFormValidator().registerButton( rbEpson24PrinterCommandSet );
  getFormValidator().registerButton( rbEpson9PrinterCommandSet );
  getFormValidator().registerButton( rbIBMPrinterCommandSet );
  getFormValidator().registerButton( rbPlainPrinterCommandSet );

  final JComponent exportPane = createExportPane();

  final Configuration config = ClassicEngineBoot.getInstance().getGlobalConfig();
  final boolean advancedSettingsTabAvail =
      "true"
          .equals( config
              .getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.gui.plaintext.AdvancedSettingsAvailable" ) );
  final JTabbedPane tabbedPane = new JTabbedPane();
  tabbedPane.add( getResources().getString( "plain-text-exportdialog.export-settings" ), exportPane ); //$NON-NLS-1$
  tabbedPane.add( getResources().getString( "plain-text-exportdialog.parameters" ), getParametersPanel() );

  if ( advancedSettingsTabAvail ) {
    tabbedPane.add( getResources().getString( "plain-text-exportdialog.advanced-settings" ), createAdvancedPane() ); //$NON-NLS-1$
  }
  setContentPane( createContentPane( tabbedPane ) );
  clear();
}