List of usage examples for java.awt.event ItemEvent getItem
public Object getItem()
From source file:boundary.GraphPane.java
public GraphPane(Dominoes domino) { // create a simple graph for the demo graph = new DelegateForest<String, String>(); if (domino.getType() == DominoType.SUPPORT) graph = new UndirectedSparseGraph<String, String>(); else/*from w w w . j av a2 s .c om*/ graph = new DirectedSparseGraph<String, String>(); createTree(domino); treeLayout = new FRLayout<>(graph); //treeLayout = new CircleLayout(graph); vv = new VisualizationViewer<String, String>(treeLayout, new Dimension(400, 400)); vv.getRenderContext().setVertexFillPaintTransformer(new Transformer<String, Paint>() { @Override public Paint transform(String i) { return (Paint) nodes.get(i).getColor(); } }); vv.getRenderContext().setVertexLabelTransformer(new Transformer<String, String>() { @Override public String transform(String arg0) { return ""; } }); vv.getRenderContext().setEdgeLabelTransformer(new Transformer<String, String>() { @Override public String transform(String arg0) { return ""; } }); vv.getRenderContext().setEdgeDrawPaintTransformer(new Transformer<String, Paint>() { @Override public Paint transform(String arg0) { return edges.get(arg0).getColor(); } }); final PickedState<String> pickedState = vv.getPickedVertexState(); pickedState.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { Object obj = e.getItem(); if (obj instanceof String) { String vertexId = (String) obj; nodes.get(vertexId).setHighlighted(pickedState.isPicked(vertexId)); } } }); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new Transformer<String, String>() { @Override public String transform(String arg0) { return nodes.get(arg0).getUserData(); } }); //vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); ; graphMouse.setZoomAtMouse(false); vv.getRenderContext().setEdgeIncludePredicate(edgePredicate); vv.getRenderContext().setVertexIncludePredicate(vertexPredicate); SwingNode s = new SwingNode(); s.setContent(panel); this.setTop(addTransformingModeOptions()); this.setBottom(addThresholdSlider(domino.getMat().findMinValue(), domino.getMat().findMaxValue())); this.setCenter(s); //this.getChildren().add(borderPane); }
From source file:fr.free.hd.servers.gui.FaceView.java
private JPanel createKind() { JPanel panel = new JPanel(new GridLayout(3, 0)); final JSlider sliderX = new JSlider(); final JSlider sliderY = new JSlider(); final JComboBox box = new JComboBox(HandKeyEnum.values()); sliderX.setMinimum(-1000);/*from w w w. j ava 2 s . c om*/ sliderX.setMaximum(1000); sliderX.setMajorTickSpacing(100); sliderX.setPaintLabels(true); sliderX.setPaintTicks(true); sliderX.setPaintTrack(true); sliderY.setMinimum(-1000); sliderY.setMaximum(1000); sliderY.setMajorTickSpacing(100); sliderY.setPaintLabels(true); sliderY.setPaintTicks(true); sliderY.setPaintTrack(true); box.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { kind = (HandKeyEnum) e.getItem(); updateLabel(); } }); panel.add(box); sliderX.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { switch (kind) { case HAND_KEY_2D: face.setAnchorX_2D(sliderX.getValue()); break; case HAND_KEY_2M: face.setAnchorX_2M(sliderX.getValue()); break; case HAND_KEY_1M: face.setAnchorX_1M(sliderX.getValue()); break; case HAND_KEY_2V: face.setAnchorX_2V(sliderX.getValue()); break; case HAND_KEY_3D: face.setAnchorX_3D(sliderX.getValue()); break; case HAND_KEY_3G: face.setAnchorX_3G(sliderX.getValue()); break; case HAND_KEY_4G: face.setAnchorX_4G(sliderX.getValue()); break; case HAND_KEY_5M: face.setAnchorX_5M(sliderX.getValue()); break; } updateLabel(); } }); sliderY.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { switch (kind) { case HAND_KEY_2D: face.setAnchorY_2D(sliderY.getValue()); break; case HAND_KEY_2M: face.setAnchorY_2M(sliderY.getValue()); break; case HAND_KEY_1M: face.setAnchorY_1M(sliderY.getValue()); break; case HAND_KEY_2V: face.setAnchorY_2V(sliderY.getValue()); break; case HAND_KEY_3D: face.setAnchorY_3D(sliderY.getValue()); break; case HAND_KEY_3G: face.setAnchorY_3G(sliderY.getValue()); break; case HAND_KEY_4G: face.setAnchorY_4G(sliderY.getValue()); break; case HAND_KEY_5M: face.setAnchorY_5M(sliderY.getValue()); break; } updateLabel(); } }); panel.add(sliderX); panel.add(sliderY); return panel; }
From source file:model.DrawTopologyDiagram.java
@Override public void init() { //create a graph Graph<VertexTopology, Number> ig = Graphs.<VertexTopology, Number>synchronizedDirectedGraph( new DirectedSparseMultigraph<VertexTopology, Number>()); ObservableGraph<VertexTopology, Number> og = new ObservableGraph<VertexTopology, Number>(ig); og.addGraphEventListener(new GraphEventListener<VertexTopology, Number>() { public void handleGraphEvent(GraphEvent<VertexTopology, Number> evt) { System.err.println("got " + evt); }/* ww w .j a v a 2 s.c o m*/ }); this.g = og; //layouts //create a graphdraw // layout = new FRLayout2<String,Number>(g); // layout = new SpringLayout<String,Number>(g); // ((FRLayout)layout).setMaxIterations(200); layout = new KKLayout<VertexTopology, Number>(g); vv = new VisualizationViewer<VertexTopology, Number>(layout, new Dimension(600, 600)); createGraph(); Container content = getContentPane(); JPanel totalCasesPanel = new JPanel(); final JPanel scaleGrids = new JPanel(new GridLayout(0, 2)); scaleGrids.add(new JLabel(" Test Cases ")); scaleGrids.add(new JLabel(" ")); totalCasesPanel.add(scaleGrids); JPanel filteredCasesPanel = new JPanel(); final JPanel filteredGrids = new JPanel(new GridLayout(0, 2)); filteredGrids.add(new JLabel(" Filtered Cases ")); filteredGrids.add(new JLabel(" ")); filteredCasesPanel.add(filteredGrids); JRootPane rp = this.getRootPane(); rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE); content.setLayout(new BorderLayout()); content.setBackground(java.awt.Color.lightGray); content.setFont(new Font("Serif", Font.PLAIN, 12)); vv.getModel().getRelaxer().setSleepTime(500); vv.setGraphMouse(new DefaultModalGraphMouse<VertexTopology, Number>()); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); vv.setForeground(Color.white); FontMetrics fm = vv.getFontMetrics(vv.getFont()); int width = fm.stringWidth(g.toString()); Transformer<VertexTopology, Shape> vertexSize = new Transformer<VertexTopology, Shape>() { public Shape transform(VertexTopology i) { Ellipse2D circle = new Ellipse2D.Double(-20, -20, 40, 40); // in this case, the vertex is twice as large return circle; } }; vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller() { @Override public String transform(Object v) { return ((VertexTopology) v).getScreenName(); } }); vv.getRenderContext().setVertexShapeTransformer(vertexSize); //Get picked states final PickedState<VertexTopology> pickedState = vv.getPickedVertexState(); pickedState.addItemListener(new ItemListener() { ArrayList<TestCase> outputTestCase = new ArrayList<TestCase>(); final Map<String, JButton> createdBtns = new HashMap<String, JButton>(); Map<String, Integer> deviceSelected = new HashMap<String, Integer>(); // not useful ArrayList<String> endPointList = new ArrayList<String>(); @Override public void itemStateChanged(ItemEvent e) { // TODO Auto-generated method stub Object subject = e.getItem(); if (e.getStateChange() != 1) { scaleGrids.removeAll(); filteredGrids.removeAll(); endPointList.remove(getScreenName(subject)); outputTestCase.clear(); filteredGrids.repaint(); filteredGrids.add(new JLabel(" Filtered Cases ")); filteredGrids.add(new JLabel(" ")); scaleGrids.repaint(); scaleGrids.add(new JLabel(" Test Cases ")); scaleGrids.add(new JLabel(" ")); deviceSelected.clear(); } if (e.getStateChange() == 1) { for (TestCase testCase : outputTestCase) { scaleGrids.removeAll(); scaleGrids.add(new JLabel(" Test Cases ")); scaleGrids.add(new JLabel(" ")); filteredGrids.removeAll(); filteredGrids.add(new JLabel(" Filtered Cases ")); filteredGrids.add(new JLabel(" ")); } if (subject instanceof VertexTopology) { final VertexTopology edgePicked = (VertexTopology) subject; if (pickedState.isPicked(edgePicked)) { for (TestCase testCase : edgePicked.getTestCaseList()) { if (!outputTestCase.contains(testCase)) outputTestCase.add(testCase); System.out.println("The size for reference is " + testCase.inputReferenceMap.size() + testCase.getName()); System.out.println("The size for target is " + testCase.inputTargetMap.size() + testCase.getName()); } if (deviceSelected.get(edgePicked.getScreenName()) != null) deviceSelected.put(edgePicked.getScreenName(), deviceSelected.get(edgePicked.getScreenName()) + 1); else deviceSelected.put(edgePicked.getScreenName(), 1); endPointList.add(edgePicked.getScreenName()); } } } for (TestCase testCase : outputTestCase) { JButton btnCase = new JButton(testCase.getName()); scaleGrids.add(btnCase); if (testCase.getInputDeviceList().size() <= endPointList.size()) if (testCaseSelected(testCase, endPointList)) { JButton btnCaseFiltered = new JButton(testCase.getName()); filteredGrids.add(btnCaseFiltered); } ; } scaleGrids.revalidate(); scaleGrids.setVisible(true); } }); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); content.setPreferredSize(new Dimension(1400, 900)); content.add(vv); switchLayout = new JButton("Switch to SpringLayout"); // switchLayout.addActionListener(new ActionListener() { // // @SuppressWarnings("unchecked") // public void actionPerformed(ActionEvent ae) { // Dimension d = new Dimension(600,600); // if (switchLayout.getText().indexOf("Spring") > 0) { // switchLayout.setText("Switch to FRLayout"); // layout = new SpringLayout<String,Number>(g, // new ConstantTransformer(EDGE_LENGTH)); // layout.setSize(d); // vv.getModel().setGraphLayout(layout, d); // } else { // switchLayout.setText("Switch to SpringLayout"); // layout = new FRLayout<String,Number>(g, d); // vv.getModel().setGraphLayout(layout, d); // } // } // }); JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, totalCasesPanel, filteredCasesPanel); jSplitPane.setResizeWeight(.5d); content.add(switchLayout, BorderLayout.SOUTH); content.add(jSplitPane, BorderLayout.EAST); }
From source file:ec.util.chart.swing.JTimeSeriesRendererSupportDemo.java
private Component createToolBar() { JToolBar result = new JToolBar(); result.setFloatable(false);/* www .j a va 2 s . co m*/ result.add(RANDOM_DATA.toAction(chart)).setIcon(FontAwesome.FA_RANDOM.getIcon(getForeground(), 16f)); JComboBox<RendererType> types = new JComboBox<>( support.getSupportedRendererTypes().toArray(new RendererType[0])); types.setMaximumSize(new Dimension(150, 100)); types.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { RendererType type = (RendererType) e.getItem(); chart.getXYPlot().setRenderer(support.createRenderer(type)); chart.getXYPlot().setBackgroundPaint(support.getPlotColor()); chart.setBackgroundPaint(colorSchemeSupport.getBackColor()); } }); types.setSelectedIndex(1); result.add(types); return result; }
From source file:net.sf.taverna.t2.workbench.views.results.processor.RenderedProcessorResultComponent.java
/** * Creates the component./*from ww w. j a v a 2 s . c o m*/ */ public RenderedProcessorResultComponent(RendererRegistry rendererRegistry, List<SaveIndividualResultSPI> saveActions) { this.rendererRegistry = rendererRegistry; setLayout(new BorderLayout()); setBorder(new EtchedBorder()); // Results type combo box renderersComboBox = new JComboBox<>(); renderersComboBox.setModel(new DefaultComboBoxModel<String>()); // initially empty renderersComboBox.setRenderer(new ColorCellRenderer()); renderersComboBox.setEditable(false); renderersComboBox.setEnabled(false); // initially disabled // Set the new listener - listen for changes in the currently selected renderer renderersComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == SELECTED && !ERROR_DOCUMENT.equals(e.getItem())) // render the result using the newly selected renderer renderResult(); } }); JPanel resultsTypePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); resultsTypePanel.add(new JLabel("Value type")); resultsTypePanel.add(renderersComboBox); // Refresh (re-render) button refreshButton = new JButton("Refresh", refreshIcon); refreshButton.setEnabled(false); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { renderResult(); refreshButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is clicked * on and did its action */ } }); resultsTypePanel.add(refreshButton); // Check box for wrapping text if result is of type "text/plain" wrapTextCheckBox = new JCheckBox(WRAP_TEXT); wrapTextCheckBox.setVisible(false); wrapTextCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // Should have only one child component holding the rendered result // Check for empty just as well if (renderedResultPanel.getComponents().length == 0) return; if (renderedResultPanel.getComponent(0) instanceof DialogTextArea) { nodeToWrapSelection.put(node.hashCode(), e.getStateChange() == SELECTED); renderResult(); } } }); resultsTypePanel.add(wrapTextCheckBox); // 'Save result' buttons panel saveButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); for (SaveIndividualResultSPI action : saveActions) { action.setResultReference(null); final JButton saveButton = new JButton(action.getAction()); saveButton.setEnabled(false); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is * clicked on and did its action */ } }); saveButtonsPanel.add(saveButton); } // Top panel contains result type combobox and various save buttons JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, LINE_AXIS)); topPanel.add(resultsTypePanel); topPanel.add(saveButtonsPanel); // Rendered results panel - initially empty renderedResultPanel = new JPanel(new BorderLayout()); renderedResultPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); // Add all components add(topPanel, NORTH); add(new JScrollPane(renderedResultPanel), CENTER); }
From source file:fr.free.hd.servers.gui.FaceView.java
private JPanel createPosition() { JPanel panel = new JPanel(new GridLayout(5, 0)); final JSlider slider = new JSlider(); final JSlider sliderDegree = new JSlider(); final JSlider sliderX = new JSlider(); final JSlider sliderY = new JSlider(); slider.setMinimum(0);/*from ww w . j a va2 s . c o m*/ slider.setMaximum(1000); sliderX.setMinimum(-1000); sliderX.setMaximum(1000); sliderX.setMajorTickSpacing(100); sliderX.setPaintLabels(true); sliderX.setPaintTicks(true); sliderX.setPaintTrack(true); sliderY.setMinimum(-1000); sliderY.setMaximum(1000); sliderY.setMajorTickSpacing(100); sliderY.setPaintLabels(true); sliderY.setPaintTicks(true); sliderY.setPaintTrack(true); sliderDegree.setMinimum(0); sliderDegree.setMaximum(360); sliderDegree.setMajorTickSpacing(20); sliderDegree.setPaintLabels(true); sliderDegree.setPaintTicks(true); sliderDegree.setPaintTrack(true); final JComboBox box = new JComboBox(HandPositionEnum.values()); box.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { position = (HandPositionEnum) e.getItem(); updateLabel(); } }); panel.add(box); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { switch (position) { case HAND_POSITION_BOUCHE: face.setBoucheRatio(slider.getValue()); break; case HAND_POSITION_COTE: face.setCoteRatio(slider.getValue()); break; case HAND_POSITION_COU: face.setCouRatio(slider.getValue()); break; case HAND_POSITION_MENTON: face.setMentonRatio(slider.getValue()); break; case HAND_POSITION_PAUMETTE: face.setPaumetteRatio(slider.getValue()); break; } updateLabel(); } }); sliderDegree.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { switch (position) { case HAND_POSITION_BOUCHE: face.setBoucheDegree(sliderDegree.getValue()); break; case HAND_POSITION_COTE: face.setCoteDegree(sliderDegree.getValue()); break; case HAND_POSITION_COU: face.setCouDegree(sliderDegree.getValue()); break; case HAND_POSITION_MENTON: face.setMentonDegree(sliderDegree.getValue()); break; case HAND_POSITION_PAUMETTE: face.setPaumetteDegree(sliderDegree.getValue()); break; } updateLabel(); } }); sliderX.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { switch (position) { case HAND_POSITION_BOUCHE: face.setBoucheX(sliderX.getValue()); break; case HAND_POSITION_COTE: face.setCoteX(sliderX.getValue()); break; case HAND_POSITION_COU: face.setCouX(sliderX.getValue()); break; case HAND_POSITION_MENTON: face.setMentonX(sliderX.getValue()); break; case HAND_POSITION_PAUMETTE: face.setPaumetteX(sliderX.getValue()); break; } updateLabel(); } }); sliderY.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { switch (position) { case HAND_POSITION_BOUCHE: face.setBoucheY(sliderY.getValue()); break; case HAND_POSITION_COTE: face.setCoteY(sliderY.getValue()); break; case HAND_POSITION_COU: face.setCouY(sliderY.getValue()); break; case HAND_POSITION_MENTON: face.setMentonY(sliderY.getValue()); break; case HAND_POSITION_PAUMETTE: face.setPaumetteY(sliderY.getValue()); break; } updateLabel(); } }); panel.add(slider); panel.add(sliderX); panel.add(sliderY); panel.add(sliderDegree); return panel; }
From source file:hwcdhackwaterloo.GUIMain.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.//from w ww . ja v a2s . co m */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { menuPanel = new javax.swing.JPanel(); titleLabel = new javax.swing.JLabel(); closeButton = new javax.swing.JButton(); topPanel = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); roomChoice = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); timeField = new javax.swing.JTextField(); findButton = new javax.swing.JButton(); monthChoice = new javax.swing.JComboBox(); dayChoice = new javax.swing.JComboBox(); jLabel6 = new javax.swing.JLabel(); middlePanel = new javax.swing.JPanel(); resultHeader = new javax.swing.JLabel(); result = new javax.swing.JLabel(); bottomPanel = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Fuck_Nuts"); setBackground(new java.awt.Color(0, 0, 0)); setForeground(java.awt.Color.pink); setUndecorated(true); setResizable(false); menuPanel.setBackground(new java.awt.Color(10, 10, 10)); titleLabel.setBackground(new java.awt.Color(255, 255, 255)); titleLabel.setFont(new java.awt.Font("DejaVu Sans Condensed", 0, 18)); // NOI18N titleLabel.setForeground(new java.awt.Color(230, 230, 230)); titleLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); titleLabel.setText("WaterLOOKup"); closeButton.setBackground(new java.awt.Color(0, 0, 0)); closeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/closeButtonAlt.png"))); // NOI18N closeButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { closeButtonMouseClicked(evt); } }); javax.swing.GroupLayout menuPanelLayout = new javax.swing.GroupLayout(menuPanel); menuPanel.setLayout(menuPanelLayout); menuPanelLayout .setHorizontalGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(menuPanelLayout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(titleLabel).addGap(156, 156, 156).addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))); menuPanelLayout.setVerticalGroup(menuPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(menuPanelLayout.createSequentialGroup() .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(titleLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, menuPanelLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap())); topPanel.setBackground(new java.awt.Color(135, 0, 71)); topPanel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel1.setForeground(new java.awt.Color(250, 250, 250)); jLabel1.setText("SEARCH FOR AVAILABLE ROOMS"); roomChoice.setBackground(new java.awt.Color(200, 50, 100)); roomChoice.addItem("MC"); roomChoice.addItemListener(new ItemListener() { Object state = new Object(); //Object oldState = new Object(); Object oldState = roomChoice.getSelectedItem(); public void itemStateChanged(ItemEvent e) { state = e.getItem(); if (state != oldState) { //System.out.println("changed to:"+ state); // code here to pass info to openroom.java } oldState = state; } }); String json = getJSONData("/buildings/list"); JSONObject obj = (JSONObject) JSONValue.parse(json); JSONArray courses = (JSONArray) obj.get("data"); ArrayList<String> buildingNames = new ArrayList<>(); for (Object course : courses) { JSONObject courseBlock = (JSONObject) course; buildingNames.add(courseBlock.get("building_code").toString()); } Collections.sort(buildingNames); for (String buildingName : buildingNames) { roomChoice.addItem(buildingName); } jLabel3.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N jLabel3.setForeground(new java.awt.Color(250, 250, 250)); jLabel3.setText("WHAT'S DA CLOSEST BUILDIN TO YOU?"); jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel5.setForeground(new java.awt.Color(250, 250, 250)); jLabel5.setText("WHEN DO YOU WANT A ROOM, AND FOR HOW LONG?"); timeField.setBackground(new java.awt.Color(255, 160, 202)); timeField.setText("(minutes)"); findButton.setBackground(new java.awt.Color(255, 170, 202)); findButton.setText("FIND AVAILABLE ROOM!"); Object comboBoxState = roomChoice.getSelectedItem(); findButton.setActionCommand("FIND"); //findButton.addActionListener(this); findButton.setToolTipText("Dooooo itttt!"); //pubic void actionPerformed(ActionEvent e){ // if("FIND".equals(e.getActionCommand())){ // System.out.println("Press registered."); // } //} findButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseReleased(java.awt.event.MouseEvent evt) { findButtonMouseReleased(evt); } }); monthChoice.setBackground(new java.awt.Color(200, 50, 100)); monthChoice.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "<select month>", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" })); monthChoice.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { monthChoiceItemStateChanged(evt); } }); dayChoice.setBackground(new java.awt.Color(200, 50, 100)); jLabel6.setForeground(new java.awt.Color(255, 255, 255)); jLabel6.setText("DURATION:"); javax.swing.GroupLayout topPanelLayout = new javax.swing.GroupLayout(topPanel); topPanel.setLayout(topPanelLayout); topPanelLayout.setHorizontalGroup(topPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(topPanelLayout.createSequentialGroup().addGroup(topPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(topPanelLayout.createSequentialGroup().addGap(34, 34, 34) .addGroup(topPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3) .addComponent(roomChoice, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5) .addGroup(topPanelLayout.createSequentialGroup() .addComponent(monthChoice, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(dayChoice, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(timeField, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(topPanelLayout.createSequentialGroup().addGap(135, 135, 135).addComponent( findButton, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(38, 38, 38)) .addGroup(topPanelLayout.createSequentialGroup().addGap(93, 93, 93).addComponent(jLabel1) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); topPanelLayout.setVerticalGroup(topPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(topPanelLayout.createSequentialGroup() .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(roomChoice, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(timeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(monthChoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(dayChoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(findButton, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE) .addContainerGap())); middlePanel.setBackground(new java.awt.Color(0, 129, 16)); middlePanel.setForeground(new java.awt.Color(240, 240, 240)); resultHeader.setFont(new java.awt.Font("Tahoma", 0, 18)); resultHeader.setForeground(new java.awt.Color(250, 250, 250)); result.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N result.setForeground(new java.awt.Color(255, 255, 255)); javax.swing.GroupLayout middlePanelLayout = new javax.swing.GroupLayout(middlePanel); middlePanel.setLayout(middlePanelLayout); middlePanelLayout.setHorizontalGroup(middlePanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(middlePanelLayout.createSequentialGroup().addGap(84, 84, 84) .addComponent(resultHeader, javax.swing.GroupLayout.PREFERRED_SIZE, 267, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(115, Short.MAX_VALUE)) .addGroup(middlePanelLayout.createSequentialGroup().addContainerGap().addComponent(result, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); middlePanelLayout.setVerticalGroup(middlePanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(middlePanelLayout.createSequentialGroup() .addComponent(resultHeader, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE) .addComponent(result, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(44, 44, 44))); bottomPanel.setBackground(new java.awt.Color(159, 238, 0)); jLabel4.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N jLabel4.setText("BY: KERI WARR, ANTHONY CALANDRA, DANIEL HOPPER, NEIL DE VRIES"); javax.swing.GroupLayout bottomPanelLayout = new javax.swing.GroupLayout(bottomPanel); bottomPanel.setLayout(bottomPanelLayout); bottomPanelLayout .setHorizontalGroup(bottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bottomPanelLayout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 406, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); bottomPanelLayout.setVerticalGroup( bottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, bottomPanelLayout.createSequentialGroup().addGap(0, 132, Short.MAX_VALUE).addComponent( jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(middlePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(menuPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(bottomPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(topPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(menuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(topPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(middlePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bottomPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); pack(); }
From source file:net.sf.taverna.t2.workbench.views.results.workflow.RenderedResultComponent.java
/** * Creates the component./* w ww .j a v a2 s .c o m*/ */ public RenderedResultComponent(RendererRegistry rendererRegistry, List<SaveIndividualResultSPI> saveActions) { this.rendererRegistry = rendererRegistry; setLayout(new BorderLayout()); // Results type combo box renderersComboBox = new JComboBox<>(); renderersComboBox.setModel(new DefaultComboBoxModel<String>()); // initially empty renderersComboBox.setRenderer(new ColorCellRenderer()); renderersComboBox.setEditable(false); renderersComboBox.setEnabled(false); // initially disabled // Set the new listener - listen for changes in the currently selected renderer renderersComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED && !ERROR_DOCUMENT.equals(e.getItem())) // render the result using the newly selected renderer renderResult(); } }); JPanel resultsTypePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); resultsTypePanel.add(new JLabel("Value type")); resultsTypePanel.add(renderersComboBox); // Refresh (re-render) button refreshButton = new JButton("Refresh", refreshIcon); refreshButton.setEnabled(false); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { renderResult(); refreshButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is clicked * on and did its action */ } }); resultsTypePanel.add(refreshButton); // Check box for wrapping text if result is of type "text/plain" wrapTextCheckBox = new JCheckBox(WRAP_TEXT); wrapTextCheckBox.setVisible(false); wrapTextCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // Should have only one child component holding the rendered result // Check for empty just as well if (renderedResultPanel.getComponents().length == 0) return; Component component = renderedResultPanel.getComponent(0); if (component instanceof DialogTextArea) { nodeToWrapSelection.put(path, e.getStateChange() == SELECTED); renderResult(); } } }); resultsTypePanel.add(wrapTextCheckBox); // 'Save result' buttons panel saveButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); for (SaveIndividualResultSPI action : saveActions) { action.setResultReference(null); final JButton saveButton = new JButton(action.getAction()); saveButton.setEnabled(false); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is * clicked on and did its action */ } }); saveButtonsPanel.add(saveButton); } // Top panel contains result type combobox and various save buttons JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, LINE_AXIS)); topPanel.add(resultsTypePanel); topPanel.add(saveButtonsPanel); // Rendered results panel - initially empty renderedResultPanel = new JPanel(new BorderLayout()); // Add all components add(topPanel, NORTH); add(new JScrollPane(renderedResultPanel), CENTER); }
From source file:ro.nextreports.designer.datasource.ConnectionDialog.java
public void itemStateChanged(ItemEvent e) { String s = (String) e.getItem(); for (DriverTemplate template : templates) { if (s.equals(template.getType())) { mDriver.setText(template.getClassName()); mURL.setText(template.getUrlTemplate()); urlFormatLabel.setText(template.getUrlTemplate()); defaultPort = template.getDefaultPort(); }//from w w w. j a v a 2s. c o m } }
From source file:com.emr.schemas.TableRelationsForm.java
/** * Constructor//from ww w. ja v a2 s . com * @param tables {@link List} List of source tables */ public TableRelationsForm(List tables, SchemerMapper parent) { fileManager = null; dbManager = null; emrConn = null; this.parent = parent; this.tables = tables; //source tables //Create KenyaEMR DB connection fileManager = new FileManager(); String[] settings = fileManager.getConnectionSettings("emr_database.properties", "emr"); if (settings == null) { //Connection settings not found JOptionPane.showMessageDialog(null, "Database Settings not found. Please set the connection settings for the database first.", "KenyaEMR Database settings", JOptionPane.ERROR_MESSAGE); //Open KenyaEMRConnectionForm form } else { if (settings.length < 1) { JOptionPane.showMessageDialog(null, "Database Settings not found. Please set the connection settings for the database first.", "KenyaEMR Database settings", JOptionPane.ERROR_MESSAGE); //Open KenyaEMRConnectionForm form } else { //Connection settings are ok //We establish a connection dbManager = new DatabaseManager(settings[0], settings[1], settings[3], settings[4], settings[5]); emrConn = dbManager.getConnection(); if (emrConn == null) { JOptionPane.showMessageDialog(null, "Test Connection Failed", "Connection Test", JOptionPane.ERROR_MESSAGE); } } } //get all columns and add them to the columns list for (Object table : tables) { String tablename = (String) table; populateTableColumnsToList(tablename); } model = new DefaultTableModel( new Object[] { "Primary Table", "Column", "Reference Table", "Foreign Column" }, 10); initComponents(); this.setClosable(true); foreignTables = tables; combo1 = new JComboBox();//Combobox for the primary tables combo2 = new JComboBox(); combo3 = new JComboBox(); combo4 = new JComboBox(); combo1.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { String selectedTable = (String) event.getItem(); //populate primary table columns primaryColumns = getTableColumns(selectedTable); DefaultComboBoxModel combo2_model = new DefaultComboBoxModel( primaryColumns.toArray(new String[primaryColumns.size()])); JComboBox comboBox = new JComboBox(); comboBox.setModel(combo2_model); relationsTable.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(comboBox)); } } }); combo3.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { String selectedTable = (String) event.getItem(); //populate foreign table columns foreignColumns = getTableColumns(selectedTable); DefaultComboBoxModel combo3_model = new DefaultComboBoxModel( foreignColumns.toArray(new String[foreignColumns.size()])); JComboBox comboBox = new JComboBox(); comboBox.setModel(combo3_model); relationsTable.getColumnModel().getColumn(3).setCellEditor(new DefaultCellEditor(comboBox)); } } }); ComboBoxTableCellEditor primaryTableEditor = new ComboBoxTableCellEditor(tables, combo1); ComboBoxTableCellEditor primaryTableColumns = new ComboBoxTableCellEditor(primaryColumns, combo2); ComboBoxTableCellEditor foreignTableEditor = new ComboBoxTableCellEditor(foreignTables, combo3);//TODO: remove selected primary table from list ComboBoxTableCellEditor foreignTableColumns = new ComboBoxTableCellEditor(foreignColumns, combo4); relationsTable.getColumnModel().getColumn(0).setCellEditor(primaryTableEditor); relationsTable.getColumnModel().getColumn(1).setCellEditor(primaryTableColumns); relationsTable.getColumnModel().getColumn(2).setCellEditor(foreignTableEditor); relationsTable.getColumnModel().getColumn(3).setCellEditor(foreignTableColumns); columnsList.setCellRenderer(new CheckboxListCellRenderer()); SourceTablesListener listSelectionListener = new SourceTablesListener(new JTextArea(), selected_columns); columnsList.addListSelectionListener(listSelectionListener); columnsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); columnsList.setSelectionModel(new DefaultListSelectionModel() { @Override public void setSelectionInterval(int index0, int index1) { if (isSelectedIndex(index0)) super.removeSelectionInterval(index0, index1); else super.addSelectionInterval(index0, index1); } }); }