public void actionPerformed(ActionEvent ev) { if (collapsed) { if (label != null) { remove(label); } add(comp); moreOrLessButton.setIcon(collapseIcon); } else { remove(comp); if (valueLabelStr != null) { if (label == null) { label = new JLabel(Resources.format(Messages.CURRENT_VALUE, valueLabelStr)); } add(label); } moreOrLessButton.setIcon(expandIcon); } collapsed = !collapsed; JComponent container = (JComponent) getParent(); if (container != null && container.getLayout() instanceof VariableGridLayout) { ((VariableGridLayout) container.getLayout()).setFillRow(this, !collapsed); container.revalidate(); } }
public void setVisible(boolean bShow, String title) { if (bShow) { String strDir = ""; String strFreq = ""; String strTraynum = ""; m_strHelpFile = getHelpFile(title); String strSampleName = getSampleName(title); String frameBounds = getFrameBounds(title); StringTokenizer tok = new QuotedStringTokenizer(title); if (tok.hasMoreTokens()) strDir = tok.nextToken(); if (tok.hasMoreTokens()) strFreq = tok.nextToken(); if (tok.hasMoreTokens()) strTraynum = tok.nextToken(); else { try { Integer.parseInt(strDir); // if strdir is number, then strdir is empty, and the // strfreq is the number strTraynum = strFreq; strFreq = strDir; strDir = ""; } catch (Exception e) { } } try { setTitle(gettitle(strFreq)); m_lblSampleName.setText("3"); boolean bVast = isVast(strTraynum); CardLayout layout = (CardLayout) m_pnlSampleName.getLayout(); if (!bVast) { if (strSampleName == null) { strSampleName = getSampleName(strDir, strTraynum); } m_lblSampleName.setText(strSampleName); layout.show(m_pnlSampleName, OTHER); } else { m_strDir = strDir; setTrays(); layout.show(m_pnlSampleName, VAST); m_trayTimer.start(); } boolean bSample = bVast || !strSampleName.trim().equals(""); m_pnlSampleName.setVisible(bSample); m_lblLogin.setForeground(getBackground()); m_lblLogin.setVisible(false); m_passwordField.setText(""); m_passwordField.setCaretPosition(0); } catch (Exception e) { Messages.writeStackTrace(e); } setBounds(frameBounds); ExpPanel exp = Util.getActiveView(); if (exp != null) exp.waitLogin(true); } writePersistence(); setVisible(bShow); }
public Dimension getPreferredSize(JComponent c) { Dimension prefSize = (getFileChooser().getAccessory() != null) ? WITH_ACCELERATOR_PREF_SIZE : PREF_SIZE; Dimension d = c.getLayout().preferredLayoutSize(c); if (d != null) { return new Dimension( d.width < prefSize.width ? prefSize.width : d.width, d.height < prefSize.height ? prefSize.height : d.height); } else { return prefSize; } }
/** * If <code>c</code> is the <code>JOptionPane</code> the receiver is contained in, the preferred * size that is returned is the maximum of the preferred size of the <code>LayoutManager</code> * for the <code>JOptionPane</code>, and <code>getMinimumOptionPaneSize</code>. */ public Dimension getPreferredSize(JComponent c) { if (c == optionPane) { Dimension ourMin = getMinimumOptionPaneSize(); LayoutManager lm = c.getLayout(); if (lm != null) { Dimension lmSize = lm.preferredLayoutSize(c); if (ourMin != null) return new Dimension( Math.max(lmSize.width, ourMin.width), Math.max(lmSize.height, ourMin.height)); return lmSize; } return ourMin; } return null; }