// Constructor public ParticleGeneratePanel(ParticleList particleList, UintahGui parent) { // Copy the arguments d_particleList = particleList; // Initialize particle size distribution d_partSizeDist = new ParticleSize(); // Create the tabbed pane partTabbedPane = new JTabbedPane(); // Create the panels to be added to the tabbed pane particleSizeInputPanel = new ParticleSizeDistInputPanel(d_partSizeDist, this); particleLocGenPanel = new ParticleLocGeneratePanel(d_particleList, d_partSizeDist, this); // Add the tabs partTabbedPane.addTab("Size Distribution", null, particleSizeInputPanel, null); partTabbedPane.addTab("Generate Locations", null, particleLocGenPanel, null); partTabbedPane.setSelectedIndex(0); // Create a grid bag GridBagLayout gb = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gb); // Set the constraints for the tabbed pane UintahGui.setConstraints(gbc, GridBagConstraints.CENTER, 1.0, 1.0, 0, 1, 1, 1, 5); gb.setConstraints(partTabbedPane, gbc); add(partTabbedPane); // Add the change listener partTabbedPane.addChangeListener(this); }
public TabbedPane1() { int i = 0; for (String flavor : flavors) tabs.addTab(flavors[i], new JButton("Tabbed pane " + i++)); tabs.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { txt.setText("Tab selected: " + tabs.getSelectedIndex()); } }); add(BorderLayout.SOUTH, txt); add(tabs); }
/* * Create using the specified focus policy */ public TabFocusHandler(JTabbedPane tabbedPane, int focusPolicy) { if (focusPolicy != RESET_FOCUS && focusPolicy != RETAIN_FOCUS) throw new IllegalArgumentException("Invalid focus policy"); this.tabbedPane = tabbedPane; this.focusPolicy = focusPolicy; // Add listeners to manage a tab change tabbedPane.addChangeListener(this); KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); focusManager.addPropertyChangeListener("permanentFocusOwner", this); }
// {{{ init() method private void init() { EditBus.addToBus(this); /* Setup panes */ JPanel content = new JPanel(new BorderLayout(12, 12)); content.setBorder(new EmptyBorder(12, 12, 12, 12)); setContentPane(content); tabPane = new JTabbedPane(); tabPane.addTab(jEdit.getProperty("manage-plugins.title"), manager = new ManagePanel(this)); tabPane.addTab( jEdit.getProperty("update-plugins.title"), updater = new InstallPanel(this, true)); tabPane.addTab( jEdit.getProperty("install-plugins.title"), installer = new InstallPanel(this, false)); EditBus.addToBus(installer); content.add(BorderLayout.CENTER, tabPane); tabPane.addChangeListener(new ListUpdater()); /* Create the buttons */ Box buttons = new Box(BoxLayout.X_AXIS); ActionListener al = new ActionHandler(); mgrOptions = new JButton(jEdit.getProperty("plugin-manager.mgr-options")); mgrOptions.addActionListener(al); pluginOptions = new JButton(jEdit.getProperty("plugin-manager.plugin-options")); pluginOptions.addActionListener(al); done = new JButton(jEdit.getProperty("plugin-manager.done")); done.addActionListener(al); buttons.add(Box.createGlue()); buttons.add(mgrOptions); buttons.add(Box.createHorizontalStrut(6)); buttons.add(pluginOptions); buttons.add(Box.createHorizontalStrut(6)); buttons.add(done); buttons.add(Box.createGlue()); getRootPane().setDefaultButton(done); content.add(BorderLayout.SOUTH, buttons); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setIconImage(GUIUtilities.getPluginIcon()); pack(); GUIUtilities.loadGeometry(this, parent, "plugin-manager"); GUIUtilities.addSizeSaver(this, parent, "plugin-manager"); setVisible(true); } // }}}
protected JTabbedPane createTestRunViews() { JTabbedPane pane = new JTabbedPane(); FailureRunView lv = new FailureRunView(this); fTestRunViews.addElement(lv); lv.addTab(pane); TestHierarchyRunView tv = new TestHierarchyRunView(this); fTestRunViews.addElement(tv); tv.addTab(pane); pane.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { testViewChanged(); } }); return pane; }
public SwingDnDFrame() { setTitle("SwingDnDTest"); JTabbedPane tabbedPane = new JTabbedPane(); JList list = SampleComponents.list(); tabbedPane.addTab("List", list); JTable table = SampleComponents.table(); tabbedPane.addTab("Table", table); JTree tree = SampleComponents.tree(); tabbedPane.addTab("Tree", tree); JFileChooser fileChooser = new JFileChooser(); tabbedPane.addTab("File Chooser", fileChooser); JColorChooser colorChooser = new JColorChooser(); tabbedPane.addTab("Color Chooser", colorChooser); final JTextArea textArea = new JTextArea(4, 40); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setBorder(new TitledBorder(new EtchedBorder(), "Drag text here")); JTextField textField = new JTextField("Drag color here"); textField.setTransferHandler(new TransferHandler("background")); tabbedPane.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { textArea.setText(""); } }); tree.setDragEnabled(true); table.setDragEnabled(true); list.setDragEnabled(true); fileChooser.setDragEnabled(true); colorChooser.setDragEnabled(true); textField.setDragEnabled(true); add(tabbedPane, BorderLayout.NORTH); add(scrollPane, BorderLayout.CENTER); add(textField, BorderLayout.SOUTH); pack(); }
// The init method public void init() { // Set the look and feel try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { return; } // Create the menuListener MenuListener menuListener = new MenuListener(); // Create the menu bar JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); // Create the file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); // Create the menuitems JMenuItem menuItem; menuItem = new JMenuItem("Read Particle Location Data"); fileMenu.add(menuItem); menuItem.addActionListener(menuListener); menuItem = new JMenuItem("Save Uintah Input File"); fileMenu.add(menuItem); menuItem.addActionListener(menuListener); menuItem = new JMenuItem("Exit"); fileMenu.add(menuItem); menuItem.addActionListener(menuListener); // Create the main tabbed pane mainTabbedPane = new JTabbedPane(); // Create the panels to be added to the tabbed pane uintahInputPanel = new UintahInputPanel(d_partList, this); particleGenPanel = new ParticleGeneratePanel(d_partList, this); // Add the tabs mainTabbedPane.addTab("Uintah Inputs", null, uintahInputPanel, null); mainTabbedPane.addTab("Generate Particle Locations", null, particleGenPanel, null); mainTabbedPane.setSelectedIndex(0); getContentPane().add(mainTabbedPane); // Create the help menu JMenu helpMenu = new JMenu("Help"); menuBar.add(helpMenu); // Create the menuitems menuItem = new JMenuItem("About"); helpMenu.add(menuItem); menuItem.addActionListener(menuListener); // Create the invisible help frames helpAboutFrame = new HelpAboutFrame(); helpAboutFrame.pack(); // Create the Tab Listener TabListener tabListener = new TabListener(); mainTabbedPane.addChangeListener(tabListener); }
public TestFrame(String title) throws HeadlessException { super(title); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = this.getContentPane(); contentPane.setLayout(new BorderLayout()); JPanel topPanel = new JPanel(); topPanel.setLayout(new BorderLayout()); JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new BorderLayout()); final JTextField textField = new JTextField(); this.addressField = textField; JButton button = new JButton("Parse & Render"); final JTabbedPane tabbedPane = new JTabbedPane(); final JTree tree = new JTree(); final JScrollPane scrollPane = new JScrollPane(tree); this.tree = tree; contentPane.add(topPanel, BorderLayout.NORTH); contentPane.add(bottomPanel, BorderLayout.CENTER); topPanel.add(new JLabel("URL: "), BorderLayout.WEST); topPanel.add(textField, BorderLayout.CENTER); topPanel.add(button, BorderLayout.EAST); bottomPanel.add(tabbedPane, BorderLayout.CENTER); final HtmlPanel panel = new HtmlPanel(); panel.addSelectionChangeListener( new SelectionChangeListener() { public void selectionChanged(SelectionChangeEvent event) { if (logger.isLoggable(Level.INFO)) { logger.info("selectionChanged(): selection node: " + panel.getSelectionNode()); } } }); this.htmlPanel = panel; UserAgentContext ucontext = new SimpleUserAgentContext(); this.rcontext = new LocalHtmlRendererContext(panel, ucontext); final JTextArea textArea = new JTextArea(); this.textArea = textArea; textArea.setEditable(false); final JScrollPane textAreaSp = new JScrollPane(textArea); tabbedPane.addTab("HTML", panel); tabbedPane.addTab("Tree", scrollPane); tabbedPane.addTab("Source", textAreaSp); tabbedPane.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { Component component = tabbedPane.getSelectedComponent(); if (component == scrollPane) { tree.setModel(new NodeTreeModel(panel.getRootNode())); } else if (component == textAreaSp) { textArea.setText(rcontext.getSourceCode()); } } }); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { process(textField.getText()); } }); }
private void jbInit() throws Exception { saveButton.setText("Save"); saveButton.addActionListener(new PrintfTemplateEditor_saveButton_actionAdapter(this)); cancelButton.setText("Cancel"); cancelButton.addActionListener(new PrintfTemplateEditor_cancelButton_actionAdapter(this)); this.setTitle(this.getTitle() + " Template Editor"); printfPanel.setLayout(gridBagLayout1); formatLabel.setFont(new java.awt.Font("DialogInput", 0, 12)); formatLabel.setText("Format String:"); buttonPanel.setLayout(flowLayout1); printfPanel.setBorder(BorderFactory.createEtchedBorder()); printfPanel.setMinimumSize(new Dimension(100, 160)); printfPanel.setPreferredSize(new Dimension(380, 160)); parameterPanel.setLayout(gridBagLayout2); parameterLabel.setText("Parameters:"); parameterLabel.setFont(new java.awt.Font("DialogInput", 0, 12)); parameterTextArea.setMinimumSize(new Dimension(100, 25)); parameterTextArea.setPreferredSize(new Dimension(200, 25)); parameterTextArea.setEditable(true); parameterTextArea.setText(""); insertButton.setMaximumSize(new Dimension(136, 20)); insertButton.setMinimumSize(new Dimension(136, 20)); insertButton.setPreferredSize(new Dimension(136, 20)); insertButton.setToolTipText( "insert the format in the format string and add parameter to list."); insertButton.setText("Insert Parameter"); insertButton.addActionListener(new PrintfTemplateEditor_insertButton_actionAdapter(this)); formatTextArea.setMinimumSize(new Dimension(100, 25)); formatTextArea.setPreferredSize(new Dimension(200, 15)); formatTextArea.setText(""); parameterPanel.setBorder(null); parameterPanel.setMinimumSize(new Dimension(60, 40)); parameterPanel.setPreferredSize(new Dimension(300, 40)); insertMatchButton.addActionListener( new PrintfTemplateEditor_insertMatchButton_actionAdapter(this)); insertMatchButton.setText("Insert Match"); insertMatchButton.setToolTipText( "insert the match in the format string and add parameter to list."); insertMatchButton.setPreferredSize(new Dimension(136, 20)); insertMatchButton.setMinimumSize(new Dimension(136, 20)); insertMatchButton.setMaximumSize(new Dimension(136, 20)); matchPanel.setPreferredSize(new Dimension(300, 40)); matchPanel.setBorder(null); matchPanel.setMinimumSize(new Dimension(60, 60)); matchPanel.setLayout(gridBagLayout3); InsertPanel.setLayout(gridLayout1); gridLayout1.setColumns(1); gridLayout1.setRows(2); gridLayout1.setVgap(0); InsertPanel.setBorder(BorderFactory.createEtchedBorder()); InsertPanel.setMinimumSize(new Dimension(100, 100)); InsertPanel.setPreferredSize(new Dimension(380, 120)); editorPane.setText(""); editorPane.addKeyListener(new PrintfEditor_editorPane_keyAdapter(this)); printfTabPane.addChangeListener(new PrintfEditor_printfTabPane_changeAdapter(this)); parameterPanel.add( insertButton, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(8, 6, 13, 8), 0, 10)); parameterPanel.add( paramComboBox, new GridBagConstraints( 0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(8, 8, 13, 0), 258, 11)); paramComboBox.setRenderer(new MyCellRenderer()); InsertPanel.add(matchPanel, null); InsertPanel.add(parameterPanel, null); buttonPanel.add(cancelButton, null); buttonPanel.add(saveButton, null); this.getContentPane().add(printfTabPane, BorderLayout.NORTH); this.getContentPane().add(InsertPanel, BorderLayout.CENTER); matchPanel.add( insertMatchButton, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(8, 6, 13, 8), 0, 10)); matchPanel.add( matchComboBox, new GridBagConstraints( 0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(8, 8, 13, 0), 258, 11)); printfPanel.add( parameterLabel, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(7, 5, 0, 5), 309, 0)); printfPanel.add( formatLabel, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 5, 0, 5), 288, 0)); printfPanel.add( formatTextArea, new GridBagConstraints( 0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 5, 0, 5), 300, 34)); printfPanel.add( parameterTextArea, new GridBagConstraints( 0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 5, 6, 5), 300, 34)); printfTabPane.addTab("Editor View", null, editorPanel, "View in Editor"); printfTabPane.addTab("Printf View", null, printfPanel, "Vies as Printf"); editorPane.setCharacterAttributes(PLAIN_ATTR, true); editorPane.addStyle("PLAIN", editorPane.getLogicalStyle()); editorPanel.getViewport().add(editorPane, null); this.getContentPane().add(buttonPanel, BorderLayout.SOUTH); buttonGroup.add(cancelButton); }
public QSAdminGUI(QSAdminMain qsadminMain, JFrame parentFrame) { this.parentFrame = parentFrame; Container cp = this; qsadminMain.setGUI(this); cp.setLayout(new BorderLayout(5, 5)); headerPanel = new HeaderPanel(qsadminMain, parentFrame); mainCommandPanel = new MainCommandPanel(qsadminMain); cmdConsole = new CmdConsole(qsadminMain); propertiePanel = new PropertiePanel(qsadminMain); if (headerPanel == null || mainCommandPanel == null || cmdConsole == null || propertiePanel == null) { throw new RuntimeException("Loading of one of gui component failed."); } headerPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); cp.add(headerPanel, BorderLayout.NORTH); JScrollPane propertieScrollPane = new JScrollPane(propertiePanel); // JScrollPane commandScrollPane = new JScrollPane(mainCommandPanel); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, mainCommandPanel, cmdConsole); splitPane.setOneTouchExpandable(false); splitPane.setDividerLocation(250); // splitPane.setDividerLocation(0.70); tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.addTab("Main", ball, splitPane, "Main Commands"); tabbedPane.addTab("Get/Set", ball, propertieScrollPane, "Properties Panel"); QSAdminPluginConfig qsAdminPluginConfig = null; PluginPanel pluginPanel = null; // -- start of loadPlugins try { File xmlFile = null; ClassLoader classLoader = null; Class mainClass = null; File file = new File(pluginDir); File dirs[] = null; if (file.canRead()) dirs = file.listFiles(new DirFileList()); for (int i = 0; dirs != null && i < dirs.length; i++) { xmlFile = new File(dirs[i].getAbsolutePath() + File.separator + "plugin.xml"); if (xmlFile.canRead()) { qsAdminPluginConfig = PluginConfigReader.read(xmlFile); if (qsAdminPluginConfig.getActive().equals("yes") && qsAdminPluginConfig.getType().equals("javax.swing.JPanel")) { classLoader = ClassUtil.getClassLoaderFromJars(dirs[i].getAbsolutePath()); mainClass = classLoader.loadClass(qsAdminPluginConfig.getMainClass()); logger.fine("Got PluginMainClass " + mainClass); pluginPanel = (PluginPanel) mainClass.newInstance(); if (JPanel.class.isInstance(pluginPanel) == true) { logger.info("Loading plugin : " + qsAdminPluginConfig.getName()); pluginPanelMap.put("" + (2 + i), pluginPanel); plugins.add(pluginPanel); tabbedPane.addTab( qsAdminPluginConfig.getName(), ball, (JPanel) pluginPanel, qsAdminPluginConfig.getDesc()); pluginPanel.setQSAdminMain(qsadminMain); pluginPanel.init(); } } else { logger.info( "Plugin " + dirs[i] + " is disabled so skipping " + qsAdminPluginConfig.getActive() + ":" + qsAdminPluginConfig.getType()); } } else { logger.info("No plugin configuration found in " + xmlFile + " so skipping"); } } } catch (Exception e) { logger.warning("Error loading plugin : " + e); logger.fine("StackTrace:\n" + MyString.getStackTrace(e)); } // -- end of loadPlugins tabbedPane.addChangeListener( new ChangeListener() { int selected = -1; int oldSelected = -1; public void stateChanged(ChangeEvent e) { // if plugin selected = tabbedPane.getSelectedIndex(); if (selected >= 2) { ((PluginPanel) pluginPanelMap.get("" + selected)).activated(); } if (oldSelected >= 2) { ((PluginPanel) pluginPanelMap.get("" + oldSelected)).deactivated(); } oldSelected = selected; } }); // tabbedPane.setBorder(BorderFactory.createEmptyBorder(0,5,5,5)); cp.add(tabbedPane, BorderLayout.CENTER); buildMenu(); }
public gui() { frame = new JFrame("Job Tracking System"); frame.setSize(300, 200); jobPanel = new JPanel(); jobPanel.setLayout(new BorderLayout()); JPanel jobButtonPanel = new JPanel(); jobButtonPanel.setLayout(new FlowLayout()); jobButtonPanel.add(new JButton("View")); jobButtonPanel.add(new JButton("Edit")); jobButtonPanel.add(new JButton("Add")); jobPanel.add(jobButtonPanel, BorderLayout.SOUTH); jobTable = new JTable(); jobScrollPane = new JScrollPane(jobTable); jobPanel.add(jobScrollPane, BorderLayout.CENTER); clientPanel = new JPanel(); clientPanel.setLayout(new BorderLayout()); JPanel clientButtonPanel = new JPanel(); clientButtonPanel.setLayout(new FlowLayout()); clientButtonPanel.add(new JButton("View")); clientButtonPanel.add(new JButton("Edit")); clientButtonPanel.add(new JButton("Add")); clientPanel.add(clientButtonPanel, BorderLayout.SOUTH); clientTable = new JTable(); clientScrollPane = new JScrollPane(clientTable); clientPanel.add(clientScrollPane, BorderLayout.CENTER); vendorPanel = new JPanel(); vendorPanel.setLayout(new BorderLayout()); JPanel vendorButtonPanel = new JPanel(); vendorButtonPanel.setLayout(new FlowLayout()); vendorButtonPanel.add(new JButton("View")); vendorButtonPanel.add(new JButton("Edit")); vendorButtonPanel.add(new JButton("Add")); vendorPanel.add(vendorButtonPanel, BorderLayout.SOUTH); vendorTable = new JTable(); vendorScrollPane = new JScrollPane(vendorTable); vendorPanel.add(vendorScrollPane, BorderLayout.CENTER); equipPanel = new JPanel(); equipPanel.setLayout(new BorderLayout()); JPanel equipButtonPanel = new JPanel(); equipButtonPanel.setLayout(new FlowLayout()); equipButtonPanel.add(new JButton("View")); equipButtonPanel.add(new JButton("Edit")); equipButtonPanel.add(new JButton("Add")); equipPanel.add(equipButtonPanel, BorderLayout.SOUTH); equipTable = new JTable(); equipScrollPane = new JScrollPane(equipTable); equipPanel.add(equipScrollPane, BorderLayout.CENTER); tabPane = new JTabbedPane(); tabPane.addTab("Jobs", jobPanel); tabPane.addTab("Customers", clientPanel); tabPane.addTab("Vendors", vendorPanel); tabPane.addTab("Equipment", equipPanel); tabPane.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent evt) { JTabbedPane pane = (JTabbedPane) evt.getSource(); int sel = pane.getSelectedIndex(); if (sel == 0) { showJobs(); } else if (sel == 1) { showClients(); } else if (sel == 2) { showVendors(); } else if (sel == 3) { showEquipment(); } } }); frame.add(tabPane); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.showJobs(); }