Search in sources :

Example 76 with JTabbedPane

use of javax.swing.JTabbedPane in project ACS by ACS-Community.

the class LogMonitorFrame method initialize.

/**
	 * Init the GUI
	 */
private void initialize() {
    setTitle("ACS logs monitor");
    JRootPane rootP = getRootPane();
    rootP.setLayout(new BorderLayout());
    // Add the tabs
    tabbedPnl = new JTabbedPane();
    totalStatsPnl = new TotalStatisticsPnl();
    tabbedPnl.add("Values", totalStatsPnl);
    trendPnl = new TrendPnl();
    tabbedPnl.add("Trend", trendPnl);
    rootP.add(tabbedPnl, BorderLayout.CENTER);
    // Add the close button at the bottom
    JPanel btnPnl = new JPanel(new FlowLayout(FlowLayout.CENTER));
    btnPnl.add(closeBtn);
    closeBtn.addActionListener(this);
    rootP.add(btnPnl, BorderLayout.SOUTH);
    pack();
    setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) JTabbedPane(javax.swing.JTabbedPane) JRootPane(javax.swing.JRootPane)

Example 77 with JTabbedPane

use of javax.swing.JTabbedPane in project adempiere by adempiere.

the class APanel method stateChanged.

//	set Busy
/**************************************************************************
	 *	Change Listener - (tab change)			<->
	 *  @param e event
	 */
public void stateChanged(ChangeEvent e) {
    //Run LostFocus Event when change tab			
    if (m_curWinTab != null) {
        Component cp = m_window.getFocusOwner();
        if (cp != null) {
            m_window.dispatchEvent(new FocusEvent(cp, FocusEvent.FOCUS_LOST));
        }
    }
    if (m_disposing)
        return;
    log.info(e.toString());
    setBusy(true, true);
    VTabbedPane tp = (VTabbedPane) e.getSource();
    boolean back = false;
    boolean isAPanelTab = false;
    //  Workbench Tab Change
    if (tp.isWorkbench()) {
        int WBIndex = tabPanel.getSelectedIndex();
        m_curWindowNo = m_mWorkbench.getWindowNo(WBIndex);
        //  Window Change
        log.info("curWin=" + m_curWindowNo + " - Win=" + tp);
        if (tp.getSelectedComponent() instanceof JTabbedPane)
            m_curWinTab = (JTabbedPane) tp.getSelectedComponent();
        else
            throw new java.lang.IllegalArgumentException("Window does not contain Tabs");
        if (m_curWinTab.getSelectedComponent() instanceof GridController) {
            m_curGC = (GridController) m_curWinTab.getSelectedComponent();
            initSwitchLineAction();
        } else
            throw new java.lang.IllegalArgumentException("Window-Tab does not contain GridControler");
        //  change pointers
        m_curTabIndex = m_curWinTab.getSelectedIndex();
    } else {
        //  Just a Tab Change
        log.info("Tab=" + tp);
        m_curWinTab = tp;
        int tpIndex = m_curWinTab.getSelectedIndex();
        //	detect no tab change
        if (tpIndex == m_curTabIndex)
            return;
        back = tpIndex < m_curTabIndex;
        GridController gc = null;
        if (m_curWinTab.getSelectedComponent() instanceof GridController)
            gc = (GridController) m_curWinTab.getSelectedComponent();
        else if (m_curWinTab.getSelectedComponent() instanceof APanelTab)
            isAPanelTab = true;
        else
            throw new java.lang.IllegalArgumentException("Tab does not contain GridControler");
        //  Save old Tab
        if (m_curGC != null) {
            m_curGC.stopEditor(true);
            //  has anything changed?
            if (m_curTab.needSave(true, false)) {
                //  do we have real change
                if (m_curTab.needSave(true, true)) {
                    //	Automatic Save
                    if (Env.isAutoCommit(m_ctx, m_curWindowNo)) {
                        if (!m_curTab.dataSave(true)) {
                            //  there is a problem, so we go back
                            showLastError();
                            m_curWinTab.setSelectedIndex(m_curTabIndex);
                            setBusy(false, true);
                            return;
                        }
                    } else //  explicitly ask when changing tabs
                    if (ADialog.ask(m_curWindowNo, this, "SaveChanges?", m_curTab.getCommitWarning())) {
                        //  yes we want to save
                        if (!m_curTab.dataSave(true)) {
                            //  there is a problem, so we go back
                            showLastError();
                            m_curWinTab.setSelectedIndex(m_curTabIndex);
                            setBusy(false, true);
                            return;
                        }
                    } else //  Don't save
                    {
                        //VOSS COM
                        int newRecord = m_curTab.getTableModel().getNewRow();
                        if (newRecord == -1)
                            m_curTab.dataIgnore();
                        else {
                            m_curWinTab.setSelectedIndex(m_curTabIndex);
                            setBusy(false, true);
                            return;
                        }
                    }
                } else
                    //  new record, but nothing changed
                    m_curTab.dataIgnore();
            }
        //  there is a change
        }
        if (m_curAPanelTab != null) {
            m_curAPanelTab.saveData();
            m_curAPanelTab.unregisterPanel();
            m_curAPanelTab = null;
        }
        //	new tab
        //	if (m_curTabIndex >= 0)
        //		m_curWinTab.setForegroundAt(m_curTabIndex, AdempierePLAF.getTextColor_Normal());
        //	m_curWinTab.setForegroundAt(tpIndex, AdempierePLAF.getTextColor_OK());
        //	previousIndex = m_curTabIndex;
        m_curTabIndex = tpIndex;
        if (!isAPanelTab) {
            m_curGC = gc;
            initSwitchLineAction();
        }
    }
    //	Sort Tab Handling
    if (isAPanelTab) {
        m_curAPanelTab = (APanelTab) m_curWinTab.getSelectedComponent();
        m_curAPanelTab.registerAPanel(this);
        m_curAPanelTab.loadData();
        // Consider that APanelTab (e.g. VSortTab) is not navigable - teo_sarca [ 1705444 ]
        aFirst.setEnabled(false);
        aPrevious.setEnabled(false);
        aNext.setEnabled(false);
        aLast.setEnabled(false);
    } else //	Cur Tab Setting
    {
        int gwTabIndex = m_mWorkbench.getMWindow(0).getTabIndex(m_curGC.getMTab());
        //boolean needValidate = false;
        if (m_mWorkbench.getMWindow(0).isTabInitialized(gwTabIndex) == false) {
            m_mWorkbench.getMWindow(0).initTab(gwTabIndex);
        //needValidate = true;
        }
        m_curGC.activate();
        m_curTab = m_curGC.getMTab();
        //	Refresh only current row when tab is current
        if (back && m_curTab.isCurrent())
            m_curTab.dataRefresh();
        else //	Requery & autoSize
        {
            MRole role = MRole.getDefault();
            m_curGC.query(m_onlyCurrentRows, m_onlyCurrentDays, role.getMaxQueryRecords());
        /*
				if (m_curGC.isNeedToSaveParent())
				{
					// there is a problem, so we go back
					ADialog.error(m_curWindowNo, this, "SaveParentFirst");
					m_curWinTab.setSelectedIndex(previousIndex);
					setBusy(false, true);
					return;
				}*/
        }
        //  Set initial record
        if (m_curTab.getRowCount() == 0) {
            //	Automatically create New Record, if none & tab not RO
            if (!m_curTab.isReadOnly() && (Env.isAutoNew(m_ctx, m_curWindowNo) || m_curTab.isQueryNewRecord())) {
                log.config("No record - New - AutoNew=" + Env.isAutoNew(m_ctx, m_curWindowNo) + " - QueryNew=" + m_curTab.isQueryNewRecord());
                m_curTab.dataNew(false);
            } else //	No Records found
            {
                aSave.setEnabled(false);
                aDelete.setEnabled(false);
                aDeleteSelection.setEnabled(false);
            }
            //  updates counter
            m_curTab.navigateCurrent();
            m_curGC.dynamicDisplay(0);
        }
    /*
			if (needValidate)
			{
				JFrame frame = Env.getFrame(APanel.this);
				if (frame != null)
				{
					//not sure why, the following lines is needed to make dynamic resize work
					//tested on jdk1.5, 1.6 using jgoodies look and feel
					frame.getPreferredSize();

					if (frame.getExtendedState() != JFrame.MAXIMIZED_BOTH)
					{
						frame.setMinimumSize(frame.getSize());
						revalidate();
						SwingUtilities.invokeLater(new Runnable() {

							public void run() {
								JFrame frame = Env.getFrame(APanel.this);
								frame.validate();
								AEnv.showCenterScreen(frame);
								frame.setMinimumSize(null);
							}

						});
					}
				}
			}*/
    //	else		##CHANGE
    //		m_curTab.navigateCurrent();
    }
    //	Update <-> Navigation
    aDetail.setEnabled(m_curTabIndex != m_curWinTab.getTabCount() - 1);
    aParent.setEnabled(m_curTabIndex != 0 && m_curWinTab.getTabCount() > 1);
    //	History (on first tab only)
    if (m_mWorkbench.getMWindow(getWindowIndex()).isTransaction())
        aHistory.setEnabled(isFirstTab());
    else {
        aHistory.setPressed(false);
        aHistory.setEnabled(false);
    }
    //	Document Print
    aPrint.setEnabled(m_curTab.isPrinted());
    aPrintPreview.setEnabled(m_curTab.isPrinted());
    //	Query
    aFind.setPressed(m_curTab.isQueryActive());
    //	Order Tab
    if (isAPanelTab) {
        aMulti.setPressed(false);
        aMulti.setEnabled(false);
        aNew.setEnabled(false);
        aDelete.setEnabled(false);
        aDeleteSelection.setEnabled(false);
        aFind.setEnabled(false);
        aRefresh.setEnabled(false);
        aAttachment.setEnabled(false);
        aChat.setEnabled(false);
    } else //	Grid Tab
    {
        aMulti.setEnabled(true);
        aMulti.setPressed(!m_curGC.isSingleRow());
        aFind.setEnabled(true);
        aRefresh.setEnabled(true);
        aAttachment.setEnabled(true);
        aChat.setEnabled(true);
    }
    //
    m_curWinTab.requestFocusInWindow();
    setBusy(false, true);
    log.config("fini");
}
Also used : APanelTab(org.compiere.grid.APanelTab) JTabbedPane(javax.swing.JTabbedPane) MRole(org.compiere.model.MRole) FocusEvent(java.awt.event.FocusEvent) Point(java.awt.Point) VTabbedPane(org.compiere.grid.VTabbedPane) Component(java.awt.Component) GridController(org.compiere.grid.GridController)

Example 78 with JTabbedPane

use of javax.swing.JTabbedPane in project pcgen by PCGen.

the class InfoTabbedPane method switchTabsAndAdviseTodo.

/**
	 * Switch the current tab to be the one named, possibly including a sub tab
	 * and then advise the user of the item to be done. generally the tab will
	 * handle this but a fallback of a dialog will be used if the tab can't do
	 * the advising.
	 *
	 * @param dest An arry of the tab name, the field name and optionally the
	 * sub tab name.
	 */
private void switchTabsAndAdviseTodo(String[] dest) {
    Tab tab = Tab.valueOf(dest[0]);
    String tabName = currentCharacter.getDataSet().getGameMode().getTabName(tab);
    Component selTab = null;
    for (int i = 0; i < getTabCount(); i++) {
        if (tabName.equals(getTitleAt(i))) {
            setSelectedIndex(i);
            selTab = getComponent(i);
            break;
        }
    }
    if (selTab == null) {
        //$NON-NLS-1$
        Logging.errorPrint("Failed to find tab " + tabName);
        return;
    }
    if (selTab instanceof JTabbedPane && dest.length > 2) {
        JTabbedPane tabPane = (JTabbedPane) selTab;
        for (int i = 0; i < tabPane.getTabCount(); i++) {
            if (dest[2].equals(tabPane.getTitleAt(i))) {
                tabPane.setSelectedIndex(i);
                //selTab = tab.getComponent(i);
                break;
            }
        }
    }
    if (selTab instanceof TodoHandler) {
        ((TodoHandler) selTab).adviseTodo(dest[1]);
    } else {
        //$NON-NLS-1$
        String message = LanguageBundle.getFormattedString("in_todoUseField", dest[1]);
        JOptionPane.showMessageDialog(selTab, message, //$NON-NLS-1$
        LanguageBundle.getString("in_tipsString"), JOptionPane.INFORMATION_MESSAGE);
    }
}
Also used : DisplayAwareTab(pcgen.gui2.util.DisplayAwareTab) Tab(pcgen.util.enumeration.Tab) JTabbedPane(javax.swing.JTabbedPane) Component(java.awt.Component)

Example 79 with JTabbedPane

use of javax.swing.JTabbedPane in project yyl_example by Relucent.

the class ToolMain method main.

/**
	 * 主函数
	 * @param args
	 */
public static void main(String[] args) {
    JFrame frame = new JFrame();
    Container container = frame.getContentPane();
    JTabbedPane tabbedPane = new JTabbedPane();
    container.add(tabbedPane);
    tabbedPane.add("数据转换1", new Content1().getContainer());
    frame.setBounds(100, 100, 500, 400);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("wxx计算器20030404");
    frame.setResizable(false);
    frame.setVisible(true);
}
Also used : Container(java.awt.Container) JFrame(javax.swing.JFrame) JTabbedPane(javax.swing.JTabbedPane)

Example 80 with JTabbedPane

use of javax.swing.JTabbedPane in project pcgen by PCGen.

the class MainAbout method buildCreditsPanel.

/**
	 * Construct the credits panel. This panel shows basic details
	 * about PCGen and lists all involved in it's creation.
	 *
	 * @return The credits panel.
	 */
private JPanel buildCreditsPanel() {
    JLabel versionLabel = new JLabel();
    JLabel dateLabel = new JLabel();
    JLabel javaVersionLabel = new JLabel();
    JLabel leaderLabel = new JLabel();
    JLabel helperLabel = new JLabel();
    JLabel wwwLink = new JLabel();
    JLabel emailLabel = new JLabel();
    JTextField version = new JTextField();
    JTextField releaseDate = new JTextField();
    JTextField javaVersion = new JTextField();
    JTextField projectLead = new JTextField();
    wwwSite = new JButton();
    mailingList = new JButton();
    JTabbedPane monkeyTabPane = new JTabbedPane();
    JPanel aCreditsPanel = new JPanel();
    aCreditsPanel.setLayout(new GridBagLayout());
    // Labels
    //$NON-NLS-1$
    versionLabel.setText(LanguageBundle.getString("in_abt_version"));
    GridBagConstraints gridBagConstraints1 = buildConstraints(0, 0, GridBagConstraints.WEST);
    gridBagConstraints1.weightx = 0.2;
    aCreditsPanel.add(versionLabel, gridBagConstraints1);
    //$NON-NLS-1$
    dateLabel.setText(LanguageBundle.getString("in_abt_release_date"));
    gridBagConstraints1 = buildConstraints(0, 1, GridBagConstraints.WEST);
    aCreditsPanel.add(dateLabel, gridBagConstraints1);
    //$NON-NLS-1$
    javaVersionLabel.setText(LanguageBundle.getString("in_abt_java_version"));
    gridBagConstraints1 = buildConstraints(0, 2, GridBagConstraints.WEST);
    aCreditsPanel.add(javaVersionLabel, gridBagConstraints1);
    //$NON-NLS-1$
    leaderLabel.setText(LanguageBundle.getString("in_abt_BD"));
    gridBagConstraints1 = buildConstraints(0, 3, GridBagConstraints.WEST);
    aCreditsPanel.add(leaderLabel, gridBagConstraints1);
    //$NON-NLS-1$
    wwwLink.setText(LanguageBundle.getString("in_abt_web"));
    gridBagConstraints1 = buildConstraints(0, 4, GridBagConstraints.WEST);
    aCreditsPanel.add(wwwLink, gridBagConstraints1);
    //$NON-NLS-1$
    emailLabel.setText(LanguageBundle.getString("in_abt_email"));
    gridBagConstraints1 = buildConstraints(0, 5, GridBagConstraints.WEST);
    aCreditsPanel.add(emailLabel, gridBagConstraints1);
    //$NON-NLS-1$
    helperLabel.setText(LanguageBundle.getString("in_abt_monkeys"));
    gridBagConstraints1 = buildConstraints(0, 6, GridBagConstraints.NORTHWEST);
    aCreditsPanel.add(helperLabel, gridBagConstraints1);
    // Info
    version.setEditable(false);
    String versionNum = PCGenPropBundle.getVersionNumber();
    if (StringUtils.isNotBlank(PCGenPropBundle.getAutobuildNumber())) {
        versionNum += " autobuild #" + PCGenPropBundle.getAutobuildNumber();
    }
    version.setText(versionNum);
    version.setBorder(null);
    version.setOpaque(false);
    gridBagConstraints1 = buildConstraints(1, 0, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints1.weightx = 1.0;
    aCreditsPanel.add(version, gridBagConstraints1);
    releaseDate.setEditable(false);
    String releaseDateStr = PCGenPropBundle.getReleaseDate();
    if (StringUtils.isNotBlank(PCGenPropBundle.getAutobuildDate())) {
        releaseDateStr = PCGenPropBundle.getAutobuildDate();
    }
    releaseDate.setText(releaseDateStr);
    releaseDate.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    releaseDate.setOpaque(false);
    gridBagConstraints1 = buildConstraints(1, 1, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    aCreditsPanel.add(releaseDate, gridBagConstraints1);
    javaVersion.setEditable(false);
    javaVersion.setText(System.getProperty("java.runtime.version") + " (" + System.getProperty("java.vm.vendor") + ")");
    javaVersion.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    javaVersion.setOpaque(false);
    gridBagConstraints1 = buildConstraints(1, 2, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    aCreditsPanel.add(javaVersion, gridBagConstraints1);
    projectLead.setEditable(false);
    projectLead.setText(PCGenPropBundle.getHeadCodeMonkey());
    projectLead.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    projectLead.setOpaque(false);
    gridBagConstraints1 = buildConstraints(1, 3, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    aCreditsPanel.add(projectLead, gridBagConstraints1);
    // Web site button
    wwwSite.setText(PCGenPropBundle.getWWWHome());
    wwwSite.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                Utility.viewInBrowser(wwwSite.getText());
            } catch (IOException ioe) {
                //$NON-NLS-1$
                Logging.errorPrint(LanguageBundle.getString("in_abt_browser_err"), ioe);
            }
        }
    });
    gridBagConstraints1 = buildConstraints(1, 4, GridBagConstraints.WEST);
    aCreditsPanel.add(wwwSite, gridBagConstraints1);
    // Mailing list button
    mailingList.setText(PCGenPropBundle.getMailingList());
    mailingList.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                Utility.viewInBrowser(mailingList.getText());
            } catch (IOException ioe) {
                //$NON-NLS-1$
                Logging.errorPrint(LanguageBundle.getString("in_abt_browser_err"), ioe);
            }
        }
    });
    gridBagConstraints1 = buildConstraints(1, 5, GridBagConstraints.WEST);
    aCreditsPanel.add(mailingList, gridBagConstraints1);
    // Monkey tabbed pane
    gridBagConstraints1 = buildConstraints(1, 6, GridBagConstraints.WEST);
    gridBagConstraints1.gridwidth = 2;
    gridBagConstraints1.weighty = 1.0;
    gridBagConstraints1.fill = GridBagConstraints.BOTH;
    aCreditsPanel.add(monkeyTabPane, gridBagConstraints1);
    monkeyTabPane.add(LanguageBundle.getString("in_abt_code_mky"), //$NON-NLS-1$
    buildMonkeyList(PCGenPropBundle.getCodeMonkeys()));
    monkeyTabPane.add(LanguageBundle.getString("in_abt_list_mky"), //$NON-NLS-1$
    buildMonkeyList(PCGenPropBundle.getListMonkeys()));
    monkeyTabPane.add(LanguageBundle.getString("in_abt_test_mky"), //$NON-NLS-1$
    buildMonkeyList(PCGenPropBundle.getTestMonkeys()));
    monkeyTabPane.add(LanguageBundle.getString("in_abt_eng_mky"), //$NON-NLS-1$
    buildMonkeyList(PCGenPropBundle.getEngineeringMonkeys()));
    // because there isn't one //$NON-NLS-1$
    monkeyTabPane.setToolTipTextAt(2, LanguageBundle.getString("in_abt_easter_egg"));
    return aCreditsPanel;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) IOException(java.io.IOException) JTextField(javax.swing.JTextField) ActionListener(java.awt.event.ActionListener) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

JTabbedPane (javax.swing.JTabbedPane)104 JPanel (javax.swing.JPanel)51 BorderLayout (java.awt.BorderLayout)33 JLabel (javax.swing.JLabel)26 JButton (javax.swing.JButton)25 JScrollPane (javax.swing.JScrollPane)23 Dimension (java.awt.Dimension)19 ActionEvent (java.awt.event.ActionEvent)18 ActionListener (java.awt.event.ActionListener)15 JCheckBox (javax.swing.JCheckBox)14 ChangeListener (javax.swing.event.ChangeListener)13 GridBagLayout (java.awt.GridBagLayout)12 BoxLayout (javax.swing.BoxLayout)12 ChangeEvent (javax.swing.event.ChangeEvent)12 GridBagConstraints (java.awt.GridBagConstraints)11 Insets (java.awt.Insets)11 ArrayList (java.util.ArrayList)10 JFrame (javax.swing.JFrame)10 JMenuItem (javax.swing.JMenuItem)10 JSplitPane (javax.swing.JSplitPane)10