List of usage examples for javax.swing JPanel setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:org.monome.pages.MIDIKeyboardPage.java
public JPanel getPanel() { if (this.panel != null) { return this.panel; }//from w w w .j av a 2 s.c o m JPanel panel = new JPanel(); panel.setLayout(null); panel.setPreferredSize(new java.awt.Dimension(220, 240)); pageNameLBL = new JLabel("Page " + (this.index + 1) + ": " + pageName); panel.add(pageNameLBL); pageNameLBL.setBounds(0, 0, 245, 14); JLabel midiout = new JLabel("<html>MIDI Out: " + this.midiDeviceName + "</html>"); panel.add(midiout); midiout.setBounds(20, 25, 200, 35); JLabel scalelbl = new JLabel("Scales:"); panel.add(scalelbl); scalelbl.setBounds(20, 75, 100, 14); resetScales = new JButton("Reset Scales"); resetScales.addActionListener(this); panel.add(resetScales); resetScales.setBounds(80, 75, 120, 20); scaleTF1 = new JTextField(); scaleTF2 = new JTextField(); scaleTF3 = new JTextField(); scaleTF4 = new JTextField(); scaleTF5 = new JTextField(); scaleTF6 = new JTextField(); panel.add(scaleTF1); scaleTF1.setBounds(20, 100, 80, 20); panel.add(scaleTF2); scaleTF2.setBounds(120, 100, 80, 20); panel.add(scaleTF3); scaleTF3.setBounds(20, 125, 80, 20); panel.add(scaleTF4); scaleTF4.setBounds(120, 125, 80, 20); panel.add(scaleTF5); scaleTF5.setBounds(20, 150, 80, 20); panel.add(scaleTF6); scaleTF6.setBounds(120, 150, 80, 20); //populate the text fields with the selected scales getScales(); midiOutButton = new JButton("Set MIDI Output"); midiOutButton.addActionListener(this); panel.add(midiOutButton); midiOutButton.setBounds(20, 175, 180, 20); updatePrefsButton = new JButton("Update Preferences"); updatePrefsButton.addActionListener(this); panel.add(this.updatePrefsButton); updatePrefsButton.setBounds(20, 200, 180, 20); this.panel = panel; return panel; }
From source file:org.monome.pages.MIDISequencerPage.java
public JPanel getPanel() { if (this.panel != null) { return this.panel; }/*from w w w. ja va2 s . c o m*/ JPanel panel = new JPanel(); AnchorLayout panelLayout = new AnchorLayout(); panel.setLayout(panelLayout); panel.setPreferredSize(new java.awt.Dimension(490, 175)); panel.add(getBankSizeTF(), new AnchorConstraint(717, 603, 837, 543, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); panel.add(getBankSizeLabel(), new AnchorConstraint(734, 519, 814, 380, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); panel.add(getJPanel1(), new AnchorConstraint(117, 947, 700, 15, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); pageNameLBL = new JLabel("Page " + (this.index + 1) + ": MIDI Sequencer"); panel.add(pageNameLBL, new AnchorConstraint(0, 382, 82, 0, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); panel.add(getUpdatePrefsButton(), new AnchorConstraint(717, 345, 837, 1, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); panel.add(getAddMidiOutButton(), new AnchorConstraint(865, 345, 985, 1, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); panel.add(getChannelL(), new AnchorConstraint(865, 519, 945, 380, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); panel.add(getChannelTF(), new AnchorConstraint(848, 603, 968, 543, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); JLabel midiout = new JLabel("MIDI Out: " + this.midiDeviceName); panel.add(midiout, new AnchorConstraint(2, 786, 82, 419, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); pageNameLBL.setPreferredSize(new java.awt.Dimension(180, 14)); this.getAddMidiOutButton().addActionListener(this); this.getUpdatePrefsButton().addActionListener(this); this.panel = panel; return panel; }
From source file:org.monome.pages.MIDISequencerPagePoly.java
public JPanel getPanel() { if (this.panel != null) { return this.panel; }/*from w w w .j a v a 2 s . c o m*/ JPanel panel = new JPanel(); AnchorLayout panelLayout = new AnchorLayout(); panel.setLayout(panelLayout); panel.setPreferredSize(new java.awt.Dimension(490, 175)); panel.add(getBankSizeTF(), new AnchorConstraint(717, 603, 837, 543, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); panel.add(getBankSizeLabel(), new AnchorConstraint(734, 519, 814, 380, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); panel.add(getJPanel1(), new AnchorConstraint(117, 947, 700, 15, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); pageNameLBL = new JLabel("Page " + (this.index + 1) + ": MIDI Sequencer Poly"); panel.add(pageNameLBL, new AnchorConstraint(0, 382, 82, 0, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); panel.add(getUpdatePrefsButton(), new AnchorConstraint(717, 345, 837, 1, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); panel.add(getAddMidiOutButton(), new AnchorConstraint(865, 345, 985, 1, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); panel.add(getChannelL(), new AnchorConstraint(865, 519, 945, 380, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); panel.add(getChannelTF(), new AnchorConstraint(848, 603, 968, 543, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); JLabel midiout = new JLabel("MIDI Out: " + this.midiDeviceName); panel.add(midiout, new AnchorConstraint(0, 786, 82, 419, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL)); midiout.setPreferredSize(new java.awt.Dimension(180, 14)); this.getAddMidiOutButton().addActionListener(this); this.getUpdatePrefsButton().addActionListener(this); this.panel = panel; return panel; }
From source file:org.monome.pages.MIDITriggersPage.java
public JPanel getPanel() { if (this.panel != null) { return this.panel; }/*from www.j a va 2s . c o m*/ JPanel panel = new JPanel(); panel.setLayout(null); panel.setPreferredSize(new java.awt.Dimension(531, 180)); pageNameLBL = new JLabel("Page " + (this.index + 1) + ": MIDI Triggers"); row16Label = new JLabel(); row16Label.setText("Row 16"); row15Label = new JLabel(); row15Label.setText("Row 15"); row14Label = new JLabel(); row14Label.setText("Row 14"); row13Label = new JLabel(); row13Label.setText("Row 13"); rowRB = new JRadioButton(); rowRB.setText("Rows"); colRB = new JRadioButton(); colRB.setText("Columns"); this.getRowColBG().add(rowRB); this.getRowColBG().add(colRB); addMidiOutButton = new JButton(); addMidiOutButton.addActionListener(this); panel.add(addMidiOutButton); panel.add(colRB); panel.add(rowRB); rowRB.setBounds(19, 104, 86, 18); colRB.setBounds(19, 123, 86, 18); addMidiOutButton.setText("Set MIDI Output"); addMidiOutButton.setBounds(285, 120, 164, 21); row5Label = new JLabel(); row5Label.setText("Row 5"); row6Label = new JLabel(); row6Label.setText("Row 6"); row7Label = new JLabel(); row7Label.setText("Row 7"); row8Label = new JLabel(); row8Label.setText("Row 8"); row9Label = new JLabel(); row9Label.setText("Row 9"); row10Label = new JLabel(); row10Label.setText("Row 10"); row11Label = new JLabel(); row11Label.setText("Row 11"); row12Label = new JLabel(); row12Label.setText("Row 12"); panel.add(toggles[3]); toggles[3].setBounds(58, 78, 74, 18); row3Label = new JLabel(); row3Label.setText("Row 3"); row4Label = new JLabel(); panel.add(row4Label); panel.add(toggles[7]); panel.add(row8Label); panel.add(toggles[11]); panel.add(row12Label); panel.add(toggles[15]); panel.add(row16Label); panel.add(toggles[2]); panel.add(row3Label); panel.add(toggles[6]); panel.add(row7Label); panel.add(toggles[10]); panel.add(row11Label); panel.add(toggles[14]); panel.add(row15Label); row15Label.setBounds(405, 60, 46, 14); toggles[14].setBounds(451, 58, 74, 18); row11Label.setBounds(274, 60, 46, 14); toggles[10].setBounds(320, 58, 74, 18); row7Label.setBounds(143, 60, 46, 14); toggles[6].setBounds(189, 58, 74, 18); row3Label.setBounds(12, 60, 46, 14); toggles[2].setBounds(58, 58, 74, 18); row16Label.setBounds(405, 80, 46, 14); toggles[15].setBounds(451, 78, 74, 18); row12Label.setBounds(274, 80, 46, 14); toggles[11].setBounds(320, 78, 74, 18); row8Label.setBounds(143, 80, 46, 14); toggles[7].setBounds(189, 78, 74, 18); row4Label.setText("Row 4"); row4Label.setBounds(12, 80, 46, 14); row2Label = new JLabel(); row2Label.setText("Row 2"); panel.add(toggles[1]); panel.add(row2Label); panel.add(toggles[5]); panel.add(row6Label); panel.add(toggles[9]); panel.add(row10Label); panel.add(toggles[13]); panel.add(row14Label); row14Label.setBounds(405, 40, 46, 14); toggles[13].setBounds(451, 38, 74, 18); row10Label.setBounds(274, 40, 46, 14); toggles[9].setBounds(320, 38, 74, 18); row6Label.setBounds(143, 40, 46, 14); toggles[5].setBounds(189, 38, 74, 18); row2Label.setBounds(12, 40, 46, 14); toggles[1].setBounds(58, 38, 74, 18); row1Label = new JLabel(); row1Label.setText("Row 1"); panel.add(toggles[0]); panel.add(row1Label); panel.add(toggles[4]); panel.add(row5Label); panel.add(toggles[8]); panel.add(row9Label); panel.add(toggles[12]); panel.add(row13Label); panel.add(pageNameLBL); panel.add(getJLabel1()); pageNameLBL.setBounds(0, 0, 189, 14); row13Label.setBounds(405, 20, 46, 14); toggles[12].setBounds(451, 18, 74, 18); row9Label.setBounds(274, 20, 46, 14); toggles[8].setBounds(320, 18, 74, 18); row5Label.setBounds(143, 20, 46, 14); toggles[4].setBounds(189, 18, 74, 18); row1Label.setBounds(12, 20, 63, 14); toggles[0].setBounds(58, 18, 74, 18); rowRB.setSelected(true); rowRB.addActionListener(this); colRB.addActionListener(this); this.panel = panel; return panel; }
From source file:org.monome.pages.PageTemplate.java
public JPanel getPanel() { if (this.panel != null) { return this.panel; }/*from ww w . j a v a 2s .c o m*/ JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); panel.setPreferredSize(new java.awt.Dimension(464, 156)); pageNameLBL = new JLabel("Page " + (this.index + 1) + ": Page Name"); panel.add(pageNameLBL); this.panel = panel; return panel; }
From source file:org.n52.ifgicopter.spf.gui.SPFMainFrame.java
/** * the gui representation of the framework *///www . j ava2s .c o m public SPFMainFrame() { /* * handled by worker thread. */ this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); this.setTitle("Sensor Platform Framework"); this.menu = new JMenuBar(); try { File f = new File("img/icon.png"); InputStream in; if (!f.exists()) { in = ImageMapMarker.class.getResourceAsStream("/img/icon.png"); } else { in = new FileInputStream(f); } this.setIconImage(ImageIO.read(in)); } catch (IOException e) { this.log.warn(e.getMessage(), e); } /* * simple menu bar */ JMenu file = new JMenu("File"); JMenuItem exit = new JMenuItem("Exit"); /* * shutdown the engine if closed */ exit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { shutdownFrame(); } }); this.pnp = new JCheckBoxMenuItem("Plug'n'Play mode"); this.pnp.setSelected(false); /* * switch the pnp mode */ this.pnp.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean flag = SPFMainFrame.this.pnp.isSelected(); if (flag && !SPFMainFrame.this.dontShow) { JCheckBox checkbox = new JCheckBox("Do not show this message again."); String message = "During Plug'n'Play mode the output generation is blocked."; Object[] params = { message, checkbox }; JOptionPane.showMessageDialog(SPFMainFrame.this, params); SPFMainFrame.this.dontShow = checkbox.isSelected(); } /* * check if we need to restart the output plugins */ if (!flag && SPFMainFrame.this.inputChanged) { SPFRegistry.getInstance().restartOutputPlugins(); } SPFRegistry.getInstance().setPNPMode(flag); } }); JMenuItem restart = new JMenuItem("Restart"); restart.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { shutdownFrame(RESTART_CODE); } }); JMenuItem managePlugins = new JMenuItem("Manage available Plugins"); managePlugins.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PluginRegistrationDialog prd = new PluginRegistrationDialog(SPFMainFrame.this); if (prd.isCanceled()) return; updateConfigurationFile(prd.getSelectedNewPlugins(), prd.getSelectedOldPlugins()); int ret = JOptionPane.showConfirmDialog(SPFMainFrame.this, "<html><body><div>" + "Changes will have effect after restart of the application. " + "</div><div>A restart is highly recommended due to memory usage." + "</div><div><br />Restart now?</div></body></html>", "Restart application", JOptionPane.YES_NO_OPTION); if (ret == 0) { shutdownFrame(RESTART_CODE); } } }); file.add(managePlugins); file.add(this.pnp); file.add(new FixedSeparator()); file.add(restart); file.add(new FixedSeparator()); file.add(exit); this.menu.add(file); this.inputPluginMenu = new JMenu("InputPlugins"); this.outputPluginMenu = new JMenu("OutputPlugins"); this.menu.add(this.inputPluginMenu); this.menu.add(this.outputPluginMenu); /* * help */ this.aboutDialog = new AboutDialog(SPFMainFrame.this); JMenu help = new JMenu("Help"); JMenuItem about = new JMenuItem("About"); about.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SPFMainFrame.this.aboutDialog.showSelf(SPFMainFrame.this); } }); help.add(about); this.menu.add(help); this.setJMenuBar(this.menu); /* * the tabbed pane. every tab represents a input plugin */ this.pane = new JTabbedPane(); this.pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); /* * shutdown the engine if closed */ this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { SPFMainFrame.this.shutdownFrame(); } }); /* * the framework core tab */ this.corePanel = new FrameworkCorePanel(); this.addTab(this.corePanel, "Framework Core", BLUE_IMAGE); /* * the map panel */ if (Boolean.parseBoolean(SPFRegistry.getInstance().getConfigProperty(SPFRegistry.OVERVIEW_MAP_ENABLED))) { this.mapPanel = new MapPanel(); this.addTab(this.mapPanel, "Overview Map", BLUE_IMAGE); } /* * other stuff */ this.getContentPane().add(this.pane); JPanel statusBar = new JPanel(); statusBar.setLayout(new BorderLayout()); statusBar.setPreferredSize(new Dimension(200, 25)); JPanel statusBarWrapper = new JPanel(new BorderLayout()); statusBarWrapper.add(Box.createRigidArea(new Dimension(3, 3)), BorderLayout.WEST); statusBarWrapper.add(statusBar); statusBarWrapper.add(Box.createRigidArea(new Dimension(3, 3)), BorderLayout.EAST); this.statusLabel = new JLabel("SPFramework startup finished."); statusBar.add(this.statusLabel, BorderLayout.EAST); this.outputLabel = new JLabel("(no output yet)"); statusBar.add(this.outputLabel, BorderLayout.WEST); this.getContentPane().add(statusBarWrapper, BorderLayout.SOUTH); this.getContentPane().setBackground(this.pane.getBackground()); this.setPreferredSize(new Dimension(1280, 720)); this.pack(); /* * full screen? */ if (Boolean.parseBoolean(SPFRegistry.getInstance().getConfigProperty(SPFRegistry.MAXIMIZED))) { this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH); } this.setLocationRelativeTo(null); }
From source file:org.o3project.optsdn.don.frame.NeFrame.java
/** * Create a panel that displays Flowmod message. * // w w w . ja v a 2 s .c o m * @return The panel that displays Flowmod message */ private JPanel createFlowmodStatusPanel() { JPanel flowmodStatusPanel = new JPanel(); flowmodStatusPanel.setBackground(Color.WHITE); // Set maximum text size for the Flowmod message flowmodStatusLabel .setText("[match] in_port=65509, odu_sigtype=11, odu_sigid={TPN=1, tslen=8, tsmap=11111111}\n" + "[actions] output=65509, odu_sigtype=11, odu_sigid={TPN=1, tslen=8, tsmap=11111111}"); flowmodStatusPanel.add(flowmodStatusLabel); flowmodStatusPanel.setPreferredSize(flowmodStatusPanel.getPreferredSize()); // Set default text for the Flowmod message flowmodStatusLabel.setText(Constants.FLOWMOD_INFO_TEXT_DEFAULT); return flowmodStatusPanel; }
From source file:org.omelogic.tome.EpiTome.java
public void init() { backingGraph = null;/*from w ww .jav a 2s . co m*/ tomeGraph = null; idFilter = null; JPanel tablePanel = new JPanel(); tomeTable = new JTable(); JScrollPane tomeTableScroller = new JScrollPane(tomeTable); tablePanel.setLayout(new BoxLayout(tablePanel, BoxLayout.PAGE_AXIS)); tablePanel.add(tomeTableScroller); tomeProps = new JLabel(""); JPanel tomePropsPanel = new JPanel(new BorderLayout()); tomePropsPanel.add(tomeProps, BorderLayout.LINE_START); //tablePanel.add(tomeTableFixed); tablePanel.add(tomePropsPanel); //JScrollPane tablePanelScroller = new JScrollPane(tablePanel); tablePanel.setPreferredSize(new Dimension(300, 400)); //####### CONTROLS ######################################### JPanel controlPanel = new JPanel(); JButton load = new JButton("LOAD"); load.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent act) { JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new SIFFileFilter()); chooser.setMultiSelectionEnabled(false); int returnVal = chooser.showOpenDialog(tomeFrame); if (returnVal == JFileChooser.APPROVE_OPTION) { System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName()); } else { return; } File sifFile = chooser.getSelectedFile(); UndirectedSparseGraph result = null; try { result = SIFHandler.load(sifFile); } catch (Exception e) { System.out.println(e.toString()); } System.out.println("Loaded file!"); backingGraph = result; FilterDialog filterMe = new FilterDialog(); idFilter = filterMe.getFilter(); loadInitialGraph((UndirectedSparseGraph) TomeGraphUtilities.filterGraph(backingGraph, idFilter)); } }); JButton save = new JButton("SAVE"); save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent act) { if (tomeGraph == null) { JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE); return; } JFileChooser chooser = new JFileChooser(); if (((Double) ((HashMap<String, Double>) (tomeGraph.getUserDatum("GraphStatistics"))) .get("AveragePathLength")).isInfinite()) { JOptionPane.showMessageDialog(null, "Graph is not fully connected! This renders most output useless. Try trimming the graph first...", "ERROR!", JOptionPane.ERROR_MESSAGE); return; } int returnVal = chooser.showSaveDialog(EpiTome.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); FileOutputStream out; // declare a file output object PrintStream p; // declare a print stream object try { // Create a new file output stream out = new FileOutputStream(file); // Connect print stream to the output stream p = new PrintStream(out); HashMap<String, Double> graphProps = (HashMap<String, Double>) tomeGraph .getUserDatum("GraphStatistics"); p.println("#---SUMMARY---"); p.println("#NumNodes:\t" + tomeGraph.numVertices()); p.println("#NumEdges:\t" + tomeGraph.numEdges()); p.println("#ClustCoeff:\t" + graphProps.get(TomeGraphUtilities.CLUSTERING_COEFFICIENT)); p.println("#AvgPathLen:\t" + graphProps.get(TomeGraphUtilities.AVERAGE_PATH_LENGTH)); p.println("#AvgDegree:\t" + graphProps.get(TomeGraphUtilities.AVERAGE_DEGREE)); p.println("#-------------"); p.println("\n\n"); p.println("NodeID\tClustCoeff\tAvgPathLen\tAvgDegree"); Iterator<TomeVertex> vertIter = tomeGraph.getVertices().iterator(); while (vertIter.hasNext()) { TomeVertex vert = vertIter.next(); p.println(vert.getID() + "\t" + vert.getClusteringCoefficient() + "\t" + vert.getAverageDistance() + "\t" + vert.getDegree()); } p.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error writing to file!\n" + e.toString(), "ERROR!", JOptionPane.ERROR_MESSAGE); } } } }); JButton trim = new JButton("TRIM"); trim.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (tomeGraph == null) { JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE); return; } TrimDialog trimMe = new TrimDialog(); loadSubGraph(trimMe.getTrimmedGraph(tomeGraph)); } }); JButton rset = new JButton("RSET"); rset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (backingGraph == null) { JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE); return; } loadInitialGraph((UndirectedSparseGraph) TomeGraphUtilities.filterGraph(backingGraph, idFilter)); } }); JButton view = new JButton("VIEW"); view.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (tomeGraph == null) { JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE); return; } GraphDialog graf = new GraphDialog(tomeGraph, getSelectedNodeSubGraph()); } }); JButton ctrl = new JButton("CTRL"); ctrl.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (tomeGraph == null) { JOptionPane.showMessageDialog(null, "No graph is loaded!", "ERROR!", JOptionPane.ERROR_MESSAGE); return; } try { ControlsDialog ctrls = new ControlsDialog(tomeGraph, backingGraph, NUM_CONTROLS, NUM_BINS_MAX); } catch (Exception excep) { } } }); JButton help = new JButton("HELP"); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { HelpDialog.display(); } }); controlPanel.add(load); controlPanel.add(save); controlPanel.add(trim); controlPanel.add(rset); controlPanel.add(view); controlPanel.add(ctrl); controlPanel.add(help); //########################################################## Container content = tomeFrame.getContentPane(); content.removeAll(); content.add(tablePanel, BorderLayout.CENTER); content.add(controlPanel, BorderLayout.SOUTH); }
From source file:org.openconcerto.erp.graph.GraphFamilleArticlePanel.java
private Component createColorPanel(final Color color) { final JPanel p = new JPanel(); p.setBorder(BorderFactory.createLineBorder(Color.WHITE)); p.setMinimumSize(new Dimension(40, 16)); p.setPreferredSize(new Dimension(40, 16)); p.setOpaque(true);/* ww w .jav a2 s . c o m*/ p.setBackground(color); return p; }
From source file:org.openflexo.view.controller.FlexoInspectorController.java
public static void main(String[] args) { JFrame frame = new JFrame(); final JDialog dialog = new JDialog(frame); dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); JButton button = new JButton("Show dialog"); button.addActionListener(new ActionListener() { @Override//from w w w.j a v a2s . co m public void actionPerformed(ActionEvent e) { dialog.setVisible(true); } }); JLabel label = new JLabel("coucou"); dialog.add(label); dialog.pack(); JPanel panel = new JPanel(new BorderLayout()); panel.add(button); panel.setPreferredSize(new Dimension(500, 400)); frame.add(panel); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }