java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.OptionPaneUI
javax.swing.plaf.basic.BasicOptionPaneUI
- See Also:
- Top Examples, Source Code
protected void addButtonComponents(Container container,
Object[] buttons,
int initialIndex)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void addIcon(Container top)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void addMessageComponents(Container container,
GridBagConstraints cons,
Object msg,
int maxll,
boolean internallyCreated)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public BasicOptionPaneUI()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void burstStringInto(Container c,
String d,
int maxll)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean containsCustomComponents(JOptionPane op)
- See Also:
- OptionPaneUI
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected ActionListener createButtonActionListener(int buttonIndex)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Container createButtonArea()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected LayoutManager createLayoutManager()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Container createMessageArea()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected PropertyChangeListener createPropertyChangeListener()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Container createSeparator()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static ComponentUI createUI(JComponent x)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Object[] getButtons()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Icon getIcon()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Icon getIconForType(int messageType)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected int getInitialValueIndex()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected int getMaxCharactersPerLineCount()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Object getMessage()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Dimension getMinimumOptionPaneSize()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Dimension getPreferredSize(JComponent c)
- See Also:
LayoutManager.preferredLayoutSize(java.awt.Container)
, JComponent.getPreferredSize()
, ComponentUI
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected boolean getSizeButtonsToSameWidth()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected boolean hasCustomComponents
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Component initialFocusComponent
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected JComponent inputComponent
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void installComponents()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void installDefaults()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void installKeyboardActions()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void installListeners()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void installUI(JComponent c)
- See Also:
JComponent.updateUI()
, JComponent.setUI(javax.swing.plaf.ComponentUI)
, ComponentUI
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int MinimumHeight
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected Dimension minimumSize
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static final int MinimumWidth
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected JOptionPane optionPane
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected PropertyChangeListener propertyChangeListener
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void resetInputValue()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[813]Create JFrame with WindowListener, ActionListener
By Anonymous on 2004/06/21 05:11:03 Rate
package kpi;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import com.sun.tools.corba.se.idl.constExpr.Negative;
public class KPIFrame
extends JFrame
implements WindowListener, ActionListener {
protected double target;
protected double minV;
protected double maxV;
protected double minA;
protected double maxA;
protected double maxB;
protected double vA;
protected JTextField txtTarget;
protected JTextField txtvA;
protected JTextField txtminV;
protected JTextField txtmaxV;
protected JTextField txtminA;
protected JTextField txtmaxA;
protected JTextField txtmaxB;
protected JPanel pnlEast;
protected JPanel pnlResults;
protected JLabel lblIcon;
protected JPanel pnlIcon;
protected double num;
public static void main ( String [ ] args ) {
KPIFrame kpiFrame = new KPIFrame ( ) ;
kpiFrame.show ( ) ;
}
public KPIFrame ( ) {
super ( "KPI" ) ;
setSize ( 800, 600 ) ;
this.addWindowListener ( this ) ;
// design components
JPanel pnlCenter = new JPanel ( ) ;
pnlCenter.setLayout ( null ) ;
JLabel lblTarget = new JLabel ( "Target" ) ;
lblTarget.setBounds ( 50, 50, 200, 30 ) ;
pnlCenter.add ( lblTarget ) ;
txtTarget = new JTextField ( ) ;
txtTarget.setBounds ( 250, 50, 200, 30 ) ;
pnlCenter.add ( txtTarget ) ;
JLabel lblvA = new JLabel ( "Valore attuale" ) ;
lblvA.setBounds ( 50, 100, 200, 30 ) ;
pnlCenter.add ( lblvA ) ;
txtvA = new JTextField ( ) ;
txtvA.setBounds ( 250, 100, 200, 30 ) ;
pnlCenter.add ( txtvA ) ;
JLabel lblminV = new JLabel ( "Minimo valido" ) ;
lblminV.setBounds ( 50, 150, 200, 30 ) ;
pnlCenter.add ( lblminV ) ;
txtminV = new JTextField ( ) ;
txtminV.setBounds ( 250, 150, 200, 30 ) ;
pnlCenter.add ( txtminV ) ;
JLabel lblmaxV = new JLabel ( "Massimo valido" ) ;
lblmaxV.setBounds ( 50, 200, 200, 30 ) ;
pnlCenter.add ( lblmaxV ) ;
txtmaxV = new JTextField ( ) ;
txtmaxV.setBounds ( 250, 200, 200, 30 ) ;
pnlCenter.add ( txtmaxV ) ;
JLabel lblminA = new JLabel ( "Minimo accettabile" ) ;
lblminA.setBounds ( 50, 250, 200, 30 ) ;
pnlCenter.add ( lblminA ) ;
txtminA = new JTextField ( ) ;
txtminA.setBounds ( 250, 250, 200, 30 ) ;
pnlCenter.add ( txtminA ) ;
JLabel lblmaxA = new JLabel ( "Massimo accettabile" ) ;
lblmaxA.setBounds ( 50, 300, 200, 30 ) ;
pnlCenter.add ( lblmaxA ) ;
txtmaxA = new JTextField ( ) ;
txtmaxA.setBounds ( 250, 300, 200, 30 ) ;
pnlCenter.add ( txtmaxA ) ;
JButton btnReset = new JButton ( "Reset" ) ;
btnReset.setBounds ( 300, 500, 100, 50 ) ;
btnReset.addActionListener ( this ) ;
btnReset.setActionCommand ( "btnResetPressed" ) ;
pnlCenter.add ( btnReset ) ;
JButton btnExe = new JButton ( "Aggiorna" ) ;
btnExe.setBounds ( 300, 400, 100, 50 ) ;
btnExe.addActionListener ( this ) ;
btnExe.setActionCommand ( "btnExePressed" ) ;
pnlCenter.add ( btnExe ) ;
pnlEast = new JPanel ( new BorderLayout ( ) ) ;
pnlEast.setMinimumSize ( new Dimension ( 200, 500 ) ) ;
pnlEast.setPreferredSize ( new Dimension ( 200, 500 ) ) ;
pnlEast.setLayout ( new BorderLayout ( ) ) ;
pnlResults = new JPanel ( ) ;
pnlResults.setMinimumSize ( new Dimension ( 200, 400 ) ) ;
pnlResults.setPreferredSize ( new Dimension ( 200, 400 ) ) ;
pnlResults.setLayout ( new BorderLayout ( ) ) ;
pnlEast.add ( pnlResults, BorderLayout.NORTH ) ;
lblIcon = new JLabel ( ) ;
pnlResults.add ( lblIcon, BorderLayout.CENTER ) ;
// add
this.getContentPane ( ) .add ( pnlCenter, BorderLayout.CENTER ) ;
this.getContentPane ( ) .add ( pnlEast, BorderLayout.EAST ) ;
}
public Color getColor ( double _vA ) {
Color color = null;
if ( ( _vA > = minV ) && ( _vA < = maxV ) ) {
color = Color.GREEN;
}
else if ( ( ( _vA > = minA ) && ( _vA < minV ) ) || ( _vA < = maxA ) && ( _vA > maxV ) ) {
color = Color.YELLOW;
}
else {
color = Color.RED;
}
return color;
}
// metodo immissione icona
public ImageIcon getIcon ( double _vA ) {
ImageIcon icon = null;
if ( ( _vA > = minV ) && ( _vA < = maxV ) ) {
icon = new ImageIcon ( "posit.gif" ) ;
}
else if ( ( ( _vA > = minA ) && ( _vA < minV ) ) || ( _vA < = maxA ) && ( _vA > maxV ) ) {
icon = new ImageIcon ( "giall.gif" ) ;
}
else {
icon = new ImageIcon ( "negat.gif" ) ;
}
return icon;
}
// WindowListener interface
public void windowActivated ( WindowEvent windowEvent ) {
}
public void windowClosed ( WindowEvent windowEvent ) {
}
public void windowClosing ( WindowEvent windowEvent ) {
System.out.println ( "close KPIFrame.." ) ;
dispose ( ) ;
}
public void windowDeactivated ( WindowEvent windowEvent ) {
}
public void windowDeiconified ( WindowEvent windowEvent ) {
}
public void windowIconified ( WindowEvent windowEvent ) {
}
public void windowOpened ( WindowEvent windowEvent ) {
}
// ActionListener interface
public void actionPerformed ( ActionEvent _actionEvent ) {
System.out.println ( "actionPerformed" ) ;
if ( _actionEvent.getActionCommand ( ) .equals ( "btnExePressed" ) ) {
updateKpiFrame ( ) ;
}
else if ( _actionEvent.getActionCommand ( ) .equals ( "btnResetPressed" ) ) {
resetInputValue ( ) ;
}
}
// METODI
// metodo ricalcolo colore
public void updateKpiFrame ( ) {
// get input values
String strTarget = txtTarget.getText ( ) ;
target = Double.valueOf ( strTarget ) .doubleValue ( ) ;
//valore di input
String strvA = txtvA.getText ( ) ;
vA = Double.valueOf ( strvA ) .doubleValue ( ) ;
String strminV = txtminV.getText ( ) ;
minV = Double.valueOf ( strminV ) .doubleValue ( ) ;
String strmaxV = txtmaxV.getText ( ) ;
maxV = Double.valueOf ( strmaxV ) .doubleValue ( ) ;
String strminA = txtminA.getText ( ) ;
minA = Double.valueOf ( strminA ) .doubleValue ( ) ;
String strmaxA = txtmaxA.getText ( ) ;
maxA = Double.valueOf ( strmaxA ) .doubleValue ( ) ;
//
Color colore = getColor ( vA ) ;
pnlResults.setBackground ( colore ) ;
ImageIcon icone = getIcon ( vA ) ;
lblIcon.setIcon ( icone ) ;
}
}
public void selectInitialValue(JOptionPane op)
- See Also:
- OptionPaneUI
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void uninstallComponents()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void uninstallDefaults()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void uninstallKeyboardActions()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected void uninstallListeners()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void uninstallUI(JComponent c)
- See Also:
JComponent.updateUI()
, ComponentUI.installUI(javax.swing.JComponent)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples