There are 63 code examples for javax.swing.JTextField.
The API names are highlighted below.
You can use
button
to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.
Project Name: druid Package: org.dlib.gui.treetable
Source Code: TreeTableCellEditor.java (Click to view .java file)
Method Code:
public void setComponent(Component c,int row){
for ( Component comp : getComponents()) remove(comp);
add("0,0,x",c);
if (c instanceof Container) {
Component c2=((Container)c).getComponent(0);
if (c2 instanceof JTextField) {
final JTextField txt=(JTextField)c2;
int x=table.getTreeView().getRowBounds(row).x;
setBorder(new EmptyBorder(1,x,0,0));
txt.setNextFocusableComponent(table);
SwingUtilities.invokeLater(new Runnable(){
public void run(){
txt.requestFocusInWindow();
}
}
);
}
}
}
Project Name: druid Package: org.dlib.gui.treetable
Source Code: TreeTableCellEditor.java (Click to view .java file)
Method Code:
public void run(){
txt.requestFocusInWindow();
}
Project Name: druid Package: org.dlib.gui.treeview
Source Code: TreeView.java (Click to view .java file)
Method Code:
public void startEditingAtSelectedPath(){
TreePath path=getSelectionPath();
if (path == null) return;
setSuperEditable(true);
startEditingAtPath(path);
String text=path.getLastPathComponent().toString();
Component c=getCellEditor().getTreeCellEditorComponent(this,text,false,false,false,0);
if (c instanceof Container) {
c=((Container)c).getComponent(0);
if (c instanceof JTextField) {
JTextField txt=(JTextField)c;
Caret car=txt.getCaret();
Document doc=txt.getDocument();
car.setDot(0);
car.moveDot(doc.getLength());
}
}
}
Project Name: jFreeChart Package: org.jfree.chart.editor
Source Code: DefaultAxisEditor.java (Click to view .java file)
Method Code:
/**
* Presents a tick label font selection dialog to the user.
*/
public void attemptTickLabelFontSelection(){
FontChooserPanel panel=new FontChooserPanel(this.tickLabelFont);
int result=JOptionPane.showConfirmDialog(this,panel,localizationResources.getString("Font_Selection"),JOptionPane.OK_CANCEL_OPTION,JOptionPane.PLAIN_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
this.tickLabelFont=panel.getSelectedFont();
this.tickLabelFontField.setText(this.tickLabelFont.getFontName() + " " + this.tickLabelFont.getSize());
}
}
Project Name: jFreeChart Package: org.jfree.chart.editor
Source Code: DefaultNumberAxisEditor.java (Click to view .java file)
Method Code:
/**
* Revalidate the range maximum.
*/
public void validateMaximum(){
double newMax;
try {
newMax=Double.parseDouble(this.maximumRangeValue.getText());
if (newMax <= this.minimumValue) {
newMax=this.maximumValue;
}
}
catch ( NumberFormatException e) {
newMax=this.maximumValue;
}
this.maximumValue=newMax;
this.maximumRangeValue.setText(Double.toString(this.maximumValue));
}
Project Name: jFreeChart Package: org.jfree.chart.editor
Source Code: DefaultTitleEditor.java (Click to view .java file)
Method Code:
/**
* If we are supposed to show the title, the controls are enabled.
* If we are not supposed to show the title, the controls are disabled.
*/
private void enableOrDisableControls(){
boolean enabled=(this.showTitle == true);
this.titleField.setEnabled(enabled);
this.selectFontButton.setEnabled(enabled);
this.selectPaintButton.setEnabled(enabled);
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui
Source Code: SearchFrame.java (Click to view .java file)
Method Code:
public void actionPerformed(ActionEvent ae){
String act=ae.getActionCommand();
if (act.equals("Add") || act.equals("Search")) {
String text=searchString.getText();
Searcher s=add((String)newType.getSelectedItem(),"New Search ",text,Constants.EBAY_SERVER_NAME);
_stm.fireTableDataChanged();
newType.setSelectedIndex(0);
searchString.setText("");
if (act.equals("Search")) {
if (JConfig.debugging) System.out.println("Doing a " + newType.getSelectedItem() + " for "+ text);
s.execute();
}
}
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui
Source Code: SearchInfoDialog.java (Click to view .java file)
Method Code:
private void setupUI(){
final JPanel panel3=new JPanel();
panel3.setLayout(new BorderLayout());
panel3.add(boxUp(getButtonOK(),getButtonCancel()),BorderLayout.EAST);
getBasicContentPane().add(panel3,BorderLayout.SOUTH);
final JLabel label1=new JLabel("Search Name: ");
searchNameField=new JTextField(12);
searchNameField.addMouseListener(JPasteListener.getInstance());
final JLabel label2=new JLabel(" Search Type: ");
searchTypeBox=new JComboBox(_search_types);
periodList=new JComboBox(_periods);
periodEnabled=new JCheckBox("Enable Repeated Search");
tabList=new JComboBox();
buildTabList();
currencyBox=new JComboBox();
buildCurrencyList(currencyBox);
final JLabel searchLabel=new JLabel("Search: ");
searchField=new JTextField(40);
searchField.addMouseListener(JPasteListener.getInstance());
final JLabel tabLabel=new JLabel("Destination Tab: ");
final JLabel curLabel=new JLabel("Currency: ");
JPanel form=new JPanel();
form.setLayout(new SpringLayout());
form.add(label1);
form.add(boxUp(boxUp(searchNameField,label2),searchTypeBox));
form.add(searchLabel);
form.add(searchField);
form.add(tabLabel);
form.add(tabList);
form.add(curLabel);
form.add(currencyBox);
form.add(new JLabel("Repeat every: "));
form.add(boxUp(periodList,periodEnabled));
SpringUtilities.makeCompactGrid(form,5,2,6,6,6,3);
getBasicContentPane().add(form,BorderLayout.CENTER);
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui
Source Code: JBidToolBar.java (Click to view .java file)
Method Code:
private JBidToolBar(){
mSelectBox=new SearchField("Select",SELECT_BOX_SIZE);
if (Platform.isMac()) {
mSelectBox.putClientProperty("Quaqua.TextField.style","search");
}
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui
Source Code: SnipeDialog.java (Click to view .java file)
Method Code:
private void setupUI(){
auctionInfo=new JLabel();
auctionInfo.setText("Auction Information");
getBasicContentPane().add(auctionInfo);
JPanel inputPane=new JPanel();
inputPane.setLayout(new BoxLayout(inputPane,BoxLayout.Y_AXIS));
snipeAmount=new JTextField(10);
snipeAmount.setText(mInitialValue);
quantityField=new JTextField(10);
quantityField.setEnabled(false);
quantityField.setText("1");
subtractShipping=new JCheckBox();
subtractShipping.setSelected(JConfig.queryConfiguration("snipe.subtract_shipping","false").equals("true"));
subtractShipping.setText("Auto-subtract shipping and insurance (p/p)");
JPanel promptPane=new JPanel(new SpringLayout());
JLabel snipeLabel;
promptPane.add(snipeLabel=new JLabel("How much do you wish to snipe?",JLabel.TRAILING));
snipeLabel.setLabelFor(snipeAmount);
promptPane.add(snipeAmount);
promptPane.add(quantityLabel=new JLabel("Quantity?",JLabel.TRAILING));
quantityLabel.setLabelFor(quantityField);
promptPane.add(quantityField);
SpringUtilities.makeCompactGrid(promptPane,2,2,6,6,6,3);
getBasicContentPane().add(promptPane);
getBasicContentPane().add(subtractShipping);
JPanel bottomPanel=new JPanel();
bottomPanel.setLayout(new BorderLayout());
bottomPanel.add(JConfigTab.makeLine(getButtonOK(),getButtonCancel()),BorderLayout.EAST);
getBasicContentPane().add(bottomPanel);
SpringUtilities.makeCompactGrid(getBasicContentPane(),4,1,6,6,6,6);
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui.config
Source Code: JConfigBrowserTab.java (Click to view .java file)
Method Code:
private JPanel buildOverridePreference(){
JPanel tp=new JPanel();
tp.setBorder(BorderFactory.createTitledBorder("Browser Command"));
tp.setLayout(new GridLayout(2,2));
JPanel buttonPanel=new JPanel();
JButton detectButton=new JButton("Detect Browser");
String overrideOn=JConfig.queryConfiguration("browser.override","false");
buttonPanel.setLayout(new BorderLayout());
overrideDefault=new JCheckBox("Override 'detected' browser");
overrideDefault.setSelected(overrideOn.equals("true"));
detectButton.addActionListener(new ActionListener(){
public void actionPerformed( ActionEvent ae){
if (ae.getActionCommand().equals("Detect Browser")) {
if (JConfig.getOS().equalsIgnoreCase("windows")) {
String browser;
browser=Browser.getBrowserCommand();
if (browser != null) {
windowsBrowserLaunchCommand.setText(browser);
}
else {
JOptionPane.showMessageDialog(null,"This Java Virtual Machine cannot detect the default browser type.\nUpgrading to a post-1.4 version of Java might help.","Cannot detect browser",JOptionPane.INFORMATION_MESSAGE);
}
}
else {
linuxBrowserLaunchCommand.setText(Browser.getBrowserCommand());
}
}
}
}
);
tp.add(buttonPanel,BorderLayout.WEST);
buttonPanel.add(detectButton,BorderLayout.WEST);
buttonPanel.add(buildTestButton(),BorderLayout.EAST);
tp.add(overrideDefault,BorderLayout.SOUTH);
return tp;
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui.config
Source Code: JConfigBrowserTab.java (Click to view .java file)
Method Code:
public void actionPerformed(ActionEvent ae){
if (ae.getActionCommand().equals("Detect Browser")) {
if (JConfig.getOS().equalsIgnoreCase("windows")) {
String browser;
browser=Browser.getBrowserCommand();
if (browser != null) {
windowsBrowserLaunchCommand.setText(browser);
}
else {
JOptionPane.showMessageDialog(null,"This Java Virtual Machine cannot detect the default browser type.\nUpgrading to a post-1.4 version of Java might help.","Cannot detect browser",JOptionPane.INFORMATION_MESSAGE);
}
}
else {
linuxBrowserLaunchCommand.setText(Browser.getBrowserCommand());
}
}
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui.config
Source Code: JConfigMyJBidwatcherTab.java (Click to view .java file)
Method Code:
public void actionPerformed(ActionEvent event){
boolean selected=mEnable.isSelected();
emailLabel.setEnabled(selected);
mEmail.setEnabled(selected);
mEmail.setEditable(selected);
passwordLabel.setEnabled(selected);
mPassword.setEnabled(selected);
mPassword.setEditable(selected);
mCreateOrUpdate.setEnabled(selected);
for ( JCheckBox cb : mEnabledMap.keySet()) {
if (cb != mEnable) cb.setEnabled(selected && JConfig.queryConfiguration(mEnabledMap.get(cb),"false").equals("true"));
}
for ( JCheckBox cb : mConfigurationMap.keySet()) {
if (cb != mEnable) cb.setSelected(selected && JConfig.queryConfiguration(mConfigurationMap.get(cb),"false").equals("true"));
}
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui.config
Source Code: JConfigAdvancedTab.java (Click to view .java file)
Method Code:
public void actionPerformed(ActionEvent ae){
if (ae.getActionCommand().equals("Set...")) {
if (((String)configKey.getSelectedItem()).length() != 0) {
JConfig.setConfiguration((String)configKey.getSelectedItem(),configValue.getText());
updateValues();
}
}
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui.config
Source Code: JConfigSnipeTab.java (Click to view .java file)
Method Code:
private JPanel buildSnipeSettings(){
JPanel tp=new JPanel();
JLabel jl=new JLabel("How close to snipe (in seconds):");
tp.setBorder(BorderFactory.createTitledBorder("Snipe Timing"));
tp.setLayout(new BorderLayout());
snipeTime=new JTextField();
snipeTime.addMouseListener(JPasteListener.getInstance());
snipeTime.setToolTipText("Number of seconds prior to auction end to fire a snipe.");
snipeTime.setEditable(true);
snipeTime.getAccessibleContext().setAccessibleName("Default number of seconds prior to auction end to fire a snipe.");
tp.add(jl,BorderLayout.NORTH);
tp.add(snipeTime,BorderLayout.SOUTH);
return (tp);
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui.config
Source Code: JConfigFilePathTab.java (Click to view .java file)
Method Code:
private JPanel buildFilePathSettings(){
JPanel tp=new JPanel();
JLabel jl=new JLabel("What is the path to the auctions save file:");
tp.setBorder(BorderFactory.createTitledBorder("Save File Path"));
tp.setLayout(new BorderLayout());
filePath=new JTextField();
filePath.addMouseListener(JPasteListener.getInstance());
filePath.setToolTipText("Full path and filename to load auctions save file from.");
updateValues();
filePath.setEditable(true);
filePath.getAccessibleContext().setAccessibleName("Full path and filename to load auctions save file from.");
tp.add(jl,BorderLayout.NORTH);
JPanel qp=new JPanel();
JButton browseButton=new JButton("Browse...");
qp.setLayout(new BoxLayout(qp,BoxLayout.Y_AXIS));
qp.add(filePath);
qp.add(browseButton);
browseButton.addActionListener(new ActionListener(){
public void actionPerformed( ActionEvent ae){
if (ae.getActionCommand().equals("Browse...")) {
JFileChooser jfc=new JFileChooser();
jfc.setCurrentDirectory(new File(JConfig.getHomeDirectory()));
jfc.setApproveButtonText("Choose");
int rval=jfc.showOpenDialog(null);
if (rval == JFileChooser.APPROVE_OPTION) {
try {
filePath.setText(jfc.getSelectedFile().getCanonicalPath());
}
catch ( IOException ioe) {
filePath.setText(jfc.getSelectedFile().getAbsolutePath());
}
}
}
}
}
);
tp.add(qp,BorderLayout.SOUTH);
return tp;
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui.config
Source Code: JConfigFilePathTab.java (Click to view .java file)
Method Code:
public void actionPerformed(ActionEvent ae){
if (ae.getActionCommand().equals("Browse...")) {
JFileChooser jfc=new JFileChooser();
jfc.setCurrentDirectory(new File(JConfig.getHomeDirectory()));
jfc.setApproveButtonText("Choose");
int rval=jfc.showOpenDialog(null);
if (rval == JFileChooser.APPROVE_OPTION) {
try {
filePath.setText(jfc.getSelectedFile().getCanonicalPath());
}
catch ( IOException ioe) {
filePath.setText(jfc.getSelectedFile().getAbsolutePath());
}
}
}
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui.config
Source Code: JConfigDatabaseTab.java (Click to view .java file)
Method Code:
private JPanel buildMySQLPanel(){
JPanel proxyPanel=new JPanel();
proxyPanel.setBorder(BorderFactory.createTitledBorder("MySQL Settings"));
proxyPanel.setLayout(new BoxLayout(proxyPanel,BoxLayout.Y_AXIS));
mysqlHost=new JTextField();
mysqlPort=new JTextField();
mysqlDatabase=new JTextField();
mysqlUser=new JTextField();
mysqlPassword=new JPasswordField();
adjustField(mysqlHost,"Host name or IP address of MySQL server",null);
adjustField(mysqlPort,"Port number for MySQL server (default: 3306)",null);
adjustField(mysqlDatabase,"The database on the server to use (default: jbidwatcher)",null);
adjustField(mysqlUser,"Username (if needed) for MySQL server",null);
adjustField(mysqlPassword,"Password (if needed) for MySQL server",null);
proxyPanel.add(makeLine(new JLabel("MySQL Host: "),mysqlHost));
proxyPanel.add(makeLine(new JLabel("MySQL Port: "),mysqlPort));
proxyPanel.add(makeLine(new JLabel("Database: "),mysqlDatabase));
proxyPanel.add(makeLine(new JLabel("Username: "),mysqlUser));
proxyPanel.add(makeLine(new JLabel("Password: "),mysqlPassword));
return proxyPanel;
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui.config
Source Code: JConfigFirewallTab.java (Click to view .java file)
Method Code:
private JPanel buildHTTPSProxyPanel(){
JPanel proxyPanel=new JPanel();
radioAction rad=new radioAction();
proxyPanel.setBorder(BorderFactory.createTitledBorder("HTTPS/Secure Proxy Settings"));
proxyPanel.setLayout(new BoxLayout(proxyPanel,BoxLayout.Y_AXIS));
httpsProxyHost=new JTextField();
httpsProxyPort=new JTextField();
setAllHTTPSStatus(false);
adjustField(httpsProxyHost,"Host name or IP address of HTTPS proxy server",firewallTextFieldListener);
adjustField(httpsProxyPort,"Port number that the HTTPS proxy server runs on",firewallTextFieldListener);
proxyHttps=new JCheckBox("Enable HTTPS (secure http) proxy?");
proxyHttps.addActionListener(rad);
JPanel checkboxPanel=new JPanel(new BorderLayout());
checkboxPanel.add(proxyHttps,BorderLayout.WEST);
proxyPanel.add(checkboxPanel);
proxyPanel.add(makeLine(new JLabel("HTTPS Host: "),httpsProxyHost));
proxyPanel.add(makeLine(new JLabel("HTTPS Port: "),httpsProxyPort));
return proxyPanel;
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui.config
Source Code: JConfigEbayTab.java (Click to view .java file)
Method Code:
private JPanel buildUsernamePanel(){
JPanel tp=new JPanel();
tp.setBorder(BorderFactory.createTitledBorder("eBay User ID"));
tp.setLayout(new BorderLayout());
username=new JTextField();
username.addMouseListener(JPasteListener.getInstance());
username.setText(JConfig.queryConfiguration(mSitename + ".user","default"));
username.setEditable(true);
username.getAccessibleContext().setAccessibleName("User name to log into eBay");
password=new JPasswordField(JConfig.queryConfiguration(mSitename + ".password"));
password.addMouseListener(JPasteListener.getInstance());
password.setEditable(true);
password.getAccessibleContext().setAccessibleName("eBay Password");
password.getAccessibleContext().setAccessibleDescription("This is the user password to log into eBay.");
Box userBox=Box.createVerticalBox();
userBox.add(makeLine(new JLabel("Username: "),username));
userBox.add(makeLine(new JLabel("Password: "),password));
JButton testButton=new JButton("Test Login");
testButton.addActionListener(new LoginTestListener(mSitename,username,password));
tp.add(testButton,BorderLayout.EAST);
tp.add(userBox);
return (tp);
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui.config
Source Code: LoginTestListener.java (Click to view .java file)
Method Code:
public void actionPerformed(ActionEvent ae){
if (ae.getActionCommand().equals("Test Login")) {
TT T=new TT("ebay.com");
mOldLoginListener=MQFactory.getConcrete("login").registerListener(this);
ebayLoginManager login=new ebayLoginManager(T,mSitename,mPasswordField.getText(),mUsernameField.getText(),false);
cj=login.getNecessaryCookie(true);
}
}
Project Name: jbidwatcher Package: com.jbidwatcher.ui.util
Source Code: JPasteListener.java (Click to view .java file)
Method Code:
public void mouseClicked(MouseEvent me){
int modifiers=me.getModifiers();
if (isHit(modifiers,MouseEvent.BUTTON2_MASK) && !Platform.isLinux()) {
JTextField jtfEvent=(JTextField)me.getComponent();
jtfEvent.paste();
}
else if (me.isPopupTrigger()) {
_me=me;
_jpm.show(me.getComponent(),me.getX(),me.getY());
}
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: MechSelectorDialog.java (Click to view .java file)
Method Code:
void filterUnits(){
RowFilter<MechTableModel,Integer> unitTypeFilter=null;
final int nType=comboType.getSelectedIndex();
final int nClass=comboWeight.getSelectedIndex();
final int nUnit=comboUnitType.getSelectedIndex();
try {
unitTypeFilter=new RowFilter<MechTableModel,Integer>(){
@Override public boolean include( Entry<? extends MechTableModel,? extends Integer> entry){
MechTableModel mechModel=entry.getModel();
MechSummary mech=mechModel.getMechSummary(entry.getIdentifier());
if (((nClass == EntityWeightClass.SIZE) || (mech.getWeightClass() == nClass)) && (!client.game.getOptions().booleanOption("canon_only") || mech.isCanon()) && ((nType == TechConstants.T_ALL) || (nType == mech.getType()) || ((nType == TechConstants.T_IS_TW_ALL) && ((mech.getType() <= TechConstants.T_IS_TW_NON_BOX) || (mech.getType() == TechConstants.T_INTRO_BOXSET)))|| ((nType == TechConstants.T_TW_ALL) && ((mech.getType() <= TechConstants.T_IS_TW_NON_BOX) || (mech.getType() <= TechConstants.T_INTRO_BOXSET) || (mech.getType() <= TechConstants.T_CLAN_TW)))|| ((nType == TechConstants.T_ALL_IS) && ((mech.getType() <= TechConstants.T_IS_TW_NON_BOX) || (mech.getType() == TechConstants.T_INTRO_BOXSET) || (mech.getType() == TechConstants.T_IS_ADVANCED)|| (mech.getType() == TechConstants.T_IS_EXPERIMENTAL)|| (mech.getType() == TechConstants.T_IS_UNOFFICIAL)))|| ((nType == TechConstants.T_ALL_CLAN) && ((mech.getType() == TechConstants.T_CLAN_TW) || (mech.getType() == TechConstants.T_CLAN_ADVANCED) || (mech.getType() == TechConstants.T_CLAN_EXPERIMENTAL)|| (mech.getType() == TechConstants.T_CLAN_UNOFFICIAL))))&& ((nUnit == UnitType.SIZE) || mech.getUnitType().equals(UnitType.getTypeName(nUnit)))&& ((searchFilter == null) || MechSearchFilter.isMatch(mech,searchFilter))) {
if (txtFilter.getText().length() > 0) {
String text=txtFilter.getText();
return mech.getName().toLowerCase().contains(text.toLowerCase());
}
return true;
}
return false;
}
}
;
}
catch ( java.util.regex.PatternSyntaxException e) {
return;
}
sorter.setRowFilter(unitTypeFilter);
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: MechSelectorDialog.java (Click to view .java file)
Method Code:
@Override public boolean include(Entry<? extends MechTableModel,? extends Integer> entry){
MechTableModel mechModel=entry.getModel();
MechSummary mech=mechModel.getMechSummary(entry.getIdentifier());
if (((nClass == EntityWeightClass.SIZE) || (mech.getWeightClass() == nClass)) && (!client.game.getOptions().booleanOption("canon_only") || mech.isCanon()) && ((nType == TechConstants.T_ALL) || (nType == mech.getType()) || ((nType == TechConstants.T_IS_TW_ALL) && ((mech.getType() <= TechConstants.T_IS_TW_NON_BOX) || (mech.getType() == TechConstants.T_INTRO_BOXSET)))|| ((nType == TechConstants.T_TW_ALL) && ((mech.getType() <= TechConstants.T_IS_TW_NON_BOX) || (mech.getType() <= TechConstants.T_INTRO_BOXSET) || (mech.getType() <= TechConstants.T_CLAN_TW)))|| ((nType == TechConstants.T_ALL_IS) && ((mech.getType() <= TechConstants.T_IS_TW_NON_BOX) || (mech.getType() == TechConstants.T_INTRO_BOXSET) || (mech.getType() == TechConstants.T_IS_ADVANCED)|| (mech.getType() == TechConstants.T_IS_EXPERIMENTAL)|| (mech.getType() == TechConstants.T_IS_UNOFFICIAL)))|| ((nType == TechConstants.T_ALL_CLAN) && ((mech.getType() == TechConstants.T_CLAN_TW) || (mech.getType() == TechConstants.T_CLAN_ADVANCED) || (mech.getType() == TechConstants.T_CLAN_EXPERIMENTAL)|| (mech.getType() == TechConstants.T_CLAN_UNOFFICIAL))))&& ((nUnit == UnitType.SIZE) || mech.getUnitType().equals(UnitType.getTypeName(nUnit)))&& ((searchFilter == null) || MechSearchFilter.isMatch(mech,searchFilter))) {
if (txtFilter.getText().length() > 0) {
String text=txtFilter.getText();
return mech.getName().toLowerCase().contains(text.toLowerCase());
}
return true;
}
return false;
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: AdvancedSearchDialog.java (Click to view .java file)
Method Code:
protected megamek.common.MechSearchFilter getMechSearchFilter(){
MechSearchFilter ret=new MechSearchFilter();
ret.sWalk=tWalk.getText();
ret.iWalk=cWalk.getSelectedIndex();
ret.sJump=tJump.getText();
ret.iJump=cJump.getSelectedIndex();
ret.iArmor=cArmor.getSelectedIndex();
ret.sWep1Count=tWeapons1.getText();
ret.sWep2Count=tWeapons2.getText();
ret.oWep1=cWeapons1.getSelectedItem();
ret.oWep2=cWeapons2.getSelectedItem();
ret.sStartYear=tStartYear.getText();
ret.sEndYear=tEndYear.getText();
ret.iWepAndOr=cOrAnd.getSelectedIndex();
ret.bCheckEquipment=chkEquipment.isSelected();
ret.oEquipment=cEquipment.getSelectedItem();
return ret;
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: BoardNewDialog.java (Click to view .java file)
Method Code:
public void actionPerformed(ActionEvent e){
if (e.getSource().equals(butOkay)) {
try {
xvalue=Integer.decode(texWidth.getText()).intValue();
yvalue=Integer.decode(texHeight.getText()).intValue();
}
catch ( NumberFormatException ex) {
System.err.println(ex.getMessage());
}
setVisible(false);
}
else if (e.getSource().equals(butCancel)) {
setVisible(false);
}
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: VibrabombSettingDialog.java (Click to view .java file)
Method Code:
public void actionPerformed(ActionEvent actionEvent){
if (actionEvent.getSource().equals(butOk)) {
String s=fldSetting.getText();
try {
if (s != null && s.length() != 0) {
setting=Integer.parseInt(s);
}
}
catch ( NumberFormatException e) {
JOptionPane.showMessageDialog(frame,Messages.getString("VibrabombSettingDialog.alert.Message"),Messages.getString("VibrabombSettingDialog.alert.Title"),JOptionPane.WARNING_MESSAGE);
return;
}
if ((setting < 20) || (setting > 100)) {
JOptionPane.showMessageDialog(frame,Messages.getString("VibrabombSettingDialog.alert.Message"),Messages.getString("VibrabombSettingDialog.alert.Title"),JOptionPane.WARNING_MESSAGE);
return;
}
}
setVisible(false);
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: Ruler.java (Click to view .java file)
Method Code:
private void setText(){
int h1=1, h2=1;
try {
h1=Integer.parseInt(height1.getText());
}
catch ( NumberFormatException e) {
}
try {
h2=Integer.parseInt(height2.getText());
}
catch ( NumberFormatException e) {
}
String toHit1="", toHit2="";
ToHitData thd;
if (flip) {
thd=LosEffects.calculateLos(client.game,buildAttackInfo(start,end,h1,h2)).losModifiers(client.game);
}
else {
thd=LosEffects.calculateLos(client.game,buildAttackInfo(end,start,h2,h1)).losModifiers(client.game);
}
if (thd.getValue() != TargetRoll.IMPOSSIBLE) {
toHit1=thd.getValue() + " = ";
}
toHit1+=thd.getDesc();
if (flip) {
thd=LosEffects.calculateLos(client.game,buildAttackInfo(end,start,h2,h1)).losModifiers(client.game);
}
else {
thd=LosEffects.calculateLos(client.game,buildAttackInfo(start,end,h1,h2)).losModifiers(client.game);
}
if (thd.getValue() != TargetRoll.IMPOSSIBLE) {
toHit2=thd.getValue() + " = ";
}
toHit2+=thd.getDesc();
tf_start.setText(start.toString());
tf_end.setText(end.toString());
tf_distance.setText("" + distance);
tf_los1.setText(toHit1);
tf_los2.setText(toHit2);
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: ConnectDialog.java (Click to view .java file)
Method Code:
public void actionPerformed(ActionEvent e){
if (!"cancel".equals(e.getActionCommand())) {
try {
playerName=yourNameF.getText();
serverAddr=serverAddrF.getText();
port=Integer.decode(portF.getText().trim()).intValue();
}
catch ( NumberFormatException ex) {
System.err.println(ex.getMessage());
}
PreferenceManager.getClientPreferences().setLastPlayerName(playerName);
PreferenceManager.getClientPreferences().setLastConnectAddr(serverAddr);
PreferenceManager.getClientPreferences().setLastConnectPort(port);
}
setVisible(false);
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: CommonSettingsDialog.java (Click to view .java file)
Method Code:
public void valueChanged(ListSelectionEvent event){
if (event.getSource().equals(keys)) {
value.setText(GUIPreferences.getInstance().getString("Advanced" + keys.getSelectedValue()));
keysIndex=keys.getSelectedIndex();
}
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: HostDialog.java (Click to view .java file)
Method Code:
public void actionPerformed(ActionEvent e){
if (!"cancel".equals(e.getActionCommand())) {
try {
playerName=yourNameF.getText();
serverPass=serverPassF.getText();
register=registerC.isSelected();
metaserver=metaserverF.getText();
port=Integer.parseInt(portF.getText());
}
catch ( NumberFormatException ex) {
System.err.println(ex.getMessage());
port=2346;
}
PreferenceManager.getClientPreferences().setLastPlayerName(playerName);
PreferenceManager.getClientPreferences().setLastServerPass(serverPass);
PreferenceManager.getClientPreferences().setLastServerPort(port);
PreferenceManager.getClientPreferences().setValue("megamek.megamek.metaservername",metaserver);
}
setVisible(false);
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: DialogOptionComponent.java (Click to view .java file)
Method Code:
public void resetToDefault(){
switch (option.getType()) {
case IOption.BOOLEAN:
checkbox.setSelected(((Boolean)option.getDefault()).booleanValue());
break;
case IOption.CHOICE:
choice.setSelectedIndex(0);
break;
default :
textField.setText(String.valueOf(option.getDefault()));
break;
}
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: GameOptionsDialog.java (Click to view .java file)
Method Code:
/**
* Update the dialog so that it is editable or view-only.
* @param editable - <code>true</code> if the contents of the dialog are
* editable, <code>false</code> if they are view-only.
*/
public void setEditable(boolean editable){
for (Enumeration<DialogOptionComponent> i=optionComps.elements(); i.hasMoreElements(); ) {
DialogOptionComponent comp=i.nextElement();
comp.setEditable(editable);
}
texPass.setEnabled(editable);
butOkay.setEnabled(editable);
butDefaults.setEnabled(editable);
this.editable=editable;
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: RandomMapDialog.java (Click to view .java file)
Method Code:
public void focusLost(FocusEvent fe){
if (fe.getSource() instanceof JTextField) {
JTextField tf=(JTextField)fe.getSource();
tf.select(0,0);
}
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: BotConfigDialog.java (Click to view .java file)
Method Code:
String getBotName(){
return namefield.getText();
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: ChatterBox.java (Click to view .java file)
Method Code:
public void setMessage(String message){
inputField.setText(message);
}
Project Name: megamek Package: megamek.client.ui.swing
Source Code: MapDimensionsDialog.java (Click to view .java file)
Method Code:
/**
* Applies the currently selected map size settings and refreshes the list
* of maps from the server.
*/
private void apply(){
int boardWidth;
int boardHeight;
int mapWidth;
int mapHeight;
try {
boardWidth=Integer.parseInt(texBoardWidth.getText());
boardHeight=Integer.parseInt(texBoardHeight.getText());
mapWidth=(Integer)spnMapWidth.getModel().getValue();
mapHeight=(Integer)spnMapHeight.getModel().getValue();
}
catch ( NumberFormatException ex) {
JOptionPane.showMessageDialog(client.frame,Messages.getString("BoardSelectionDialog.InvalidNumberOfmaps"),Messages.getString("BoardSelectionDialog.InvalidMapSize"),JOptionPane.ERROR_MESSAGE);
return;
}
if ((boardWidth <= 0) || (boardHeight <= 0) || (mapWidth <= 0)|| (mapHeight <= 0)) {
JOptionPane.showMessageDialog(client.frame,Messages.getString("BoardSelectionDialog.MapSizeMustBeGreateter0"),Messages.getString("BoardSelectionDialog.InvalidMapSize"),JOptionPane.ERROR_MESSAGE);
return;
}
mapSettings.setBoardSize(boardWidth,boardHeight);
mapSettings.setMapSize(mapWidth,mapHeight);
client.getClient().sendMapDimensions(mapSettings);
}
Project Name: rmoffice Package: net.sf.rmoffice.ui.editor
Source Code: MagicalFeatureTableCellEditor.java (Click to view .java file)
Method Code:
/**
* {@inheritDoc}
*/
@Override public Component getTableCellEditorComponent(JTable table,Object value,boolean isSelected,int row,int column){
if (value instanceof MagicalFeature) {
MagicalFeature mf=(MagicalFeature)value;
currentType=mf.getType();
switch (currentType) {
case STAT:
cbStat.setSelectedItem(mf.getStat());
return cbStat;
case SKILL:
Vector<ISkill> skills=new Vector<ISkill>();
skills.addAll(rmSheetAdapter.getBean().getSkills());
cbSkill.setModel(new DefaultComboBoxModel(skills));
cbSkill.setSelectedItem(rmSheetAdapter.getBean().getSkill(mf.getId()));
return cbSkill;
case RESISTANCE:
cbResistance.setSelectedItem(mf.getResistance());
return cbResistance;
case DESCRIPTION:
textfield.setText(mf.getDescription());
return textfield;
}
}
return textfield;
}
Project Name: rmoffice Package: net.sf.rmoffice.ui.panels
Source Code: ModifySkillDialog.java (Click to view .java file)
Method Code:
/**
*/
private void initComponents(ISkill skill,SkillType rankType){
setLayout(new GridBagLayout());
GridBagConstraints c=new GridBagConstraints();
c.gridx=0;
c.gridy=0;
c.fill=GridBagConstraints.BOTH;
c.insets=new Insets(2,3,2,3);
add(new JLabel(RESOURCE.getString("message.skills.modifyname") + ":"),c);
c.gridx++;
tfName=new JTextField(skill.getName());
add(tfName,c);
c.gridy++;
c.gridx=0;
add(new JLabel(RESOURCE.getString("message.skills.skilltype") + ":"),c);
c.gridx++;
SkillType[] choices=new SkillType[SkillType.values().length];
choices[0]=null;
choices[1]=SkillType.DEFAULT;
choices[2]=SkillType.EVERYMAN;
choices[3]=SkillType.OCCUPATIONAL;
choices[4]=SkillType.RESTRICTED;
DefaultComboBoxModel model=new DefaultComboBoxModel(choices);
cbSkillType=new JComboBox(model);
cbSkillType.setEditable(false);
cbSkillType.setRenderer(new ComboboxSkillTypeRenderer());
if (rankType != null) {
model.setSelectedItem(rankType);
}
add(cbSkillType,c);
}
Project Name: rmoffice Package: net.sf.rmoffice.ui.panels
Source Code: AbstractPanel.java (Click to view .java file)
Method Code:
private JTextField addTextField(String prop,int lblColIdx,int compColIdx,int row,PresentationModel<T> model,ValueHolder enabledValueHolder,ValueModel converter,PanelBuilder builder){
CellConstraints cc=new CellConstraints();
String resKey=getResKeyPrefix() + prop;
builder.addLabel(RESOURCE.getString(resKey),cc.xy(lblColIdx,row));
JTextField tf=new JTextField();
if (converter == null) {
Bindings.bind(tf,model.getModel(prop));
}
else {
Bindings.bind(tf,converter);
}
Bindings.bind(tf,"enabled",enabledValueHolder);
builder.add(tf,cc.xyw(compColIdx,row,3));
return tf;
}
Project Name: rmoffice Package: net.sf.rmoffice.ui.panels
Source Code: InfoPagePanel.java (Click to view .java file)
Method Code:
/**
* @param rmSheetAdapter the adapter of the {@link RMSheet}
*/
public InfoPagePanel(BeanAdapter<RMSheet> rmSheetAdapter){
super(new BorderLayout());
BeanAdapter<RMSheet>.SimplePropertyAdapter infoModel=rmSheetAdapter.getValueModel(RMSheet.PROPERTY_INFO_PAGES);
listModel=new SelectionInList<InfoPage>(infoModel);
ValueHolder enabledHolder=new ValueHolder(false);
JSplitPane pane=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
JPanel leftPanel=new JPanel(new BorderLayout());
JPanel buttonPanel=createButtons(enabledHolder);
leftPanel.add(buttonPanel,BorderLayout.NORTH);
JList list=new JList();
Bindings.bind(list,listModel);
leftPanel.add(new JScrollPane(list),BorderLayout.CENTER);
pane.setLeftComponent(leftPanel);
final BeanAdapter<InfoPage> beanAdapter=new BeanAdapter<InfoPage>(listModel);
beanAdapter.addBeanPropertyChangeListener(new PropertyChangeListener(){
@Override public void propertyChange( PropertyChangeEvent evt){
if (InfoPage.PROP_TITLE.equals(evt.getPropertyName()) && listModel.getSelectionIndex() > -1) {
listModel.fireSelectedContentsChanged();
}
}
}
);
BeanAdapter<InfoPage>.SimplePropertyAdapter contentValueModel=beanAdapter.getValueModel("content");
JTextArea textArea=BasicComponentFactory.createTextArea(contentValueModel,false);
Bindings.bind(textArea,"enabled",enabledHolder);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
BeanAdapter<InfoPage>.SimplePropertyAdapter titleValueModel=beanAdapter.getValueModel("title");
JTextField tfTitle=BasicComponentFactory.createTextField(titleValueModel,false);
JPanel rightPanel=new JPanel(new BorderLayout());
rightPanel.add(tfTitle,BorderLayout.NORTH);
Bindings.bind(tfTitle,"enabled",enabledHolder);
rightPanel.add(new JScrollPane(textArea),BorderLayout.CENTER);
pane.setRightComponent(rightPanel);
add(pane,BorderLayout.CENTER);
listModel.getSelectionIndexHolder().addValueChangeListener(new SelectionIndexToEnabledListener(enabledHolder));
}
Project Name: rmoffice Package: net.sf.rmoffice.ui.panels
Source Code: CoinsPanel.java (Click to view .java file)
Method Code:
private void create(JPanel panel,String labelResKey,String prop,GridBagConstraints col1,GridBagConstraints col2){
col1.gridy++;
panel.add(new JLabel(RESOURCE.getString(labelResKey)),col1);
JTextField tf=new JTextField(10);
Bindings.bind(tf,adapter.getValueModel(prop));
col2.gridy++;
panel.add(tf,col2);
}
Project Name: vfsjfilechooser Package: net.sf.vfsjfilechooser.accessories.bookmarks
Source Code: BookmarksEditorPanel.java (Click to view .java file)
Method Code:
private void resetFields(){
this.isPortTextFieldDirty=false;
bookmarkNameTextField.setText("");
hostnameTextField.setText("");
protocolList.setSelectedItem(Protocol.FTP);
usernameTextField.setText("");
passwordTextField.setText("");
defaultRemotePathTextField.setText("");
passiveFtpOption.setSelected(true);
}
Project Name: vfsjfilechooser Package: net.sf.vfsjfilechooser.accessories.connection
Source Code: ConnectionDialog.java (Click to view .java file)
Method Code:
private void resetFields(){
this.isPortTextFieldDirty=false;
hostnameTextField.setText("");
protocolList.setSelectedItem(Protocol.FTP);
usernameTextField.setText("");
passwordTextField.setText("");
defaultRemotePathTextField.setText("");
passiveFtpOption.setSelected(true);
}
Project Name: vfsjfilechooser Package: net.sf.vfsjfilechooser.demo
Source Code: Main.java (Click to view .java file)
Method Code:
public void actionPerformed(ActionEvent actionEvent){
RETURN_TYPE answer=fileChooser.showOpenDialog(Main.this);
if (answer == RETURN_TYPE.APPROVE) {
final FileObject aFileObject=fileChooser.getSelectedFile();
final String safeName=VFSUtils.getFriendlyName(aFileObject.toString());
filenameTextField.setText(safeName);
}
}
Project Name: vfsjfilechooser Package: net.sf.vfsjfilechooser.filepane
Source Code: VFSFilePane.java (Click to view .java file)
Method Code:
@Override public Component getTableCellEditorComponent(JTable table,Object value,boolean isSelected,int row,int column){
Component comp=super.getTableCellEditorComponent(table,value,isSelected,row,column);
if (value instanceof FileObject) {
tf.setText(getFileChooser().getName((FileObject)value));
tf.selectAll();
}
return comp;
}
Project Name: vfsjfilechooser Package: net.sf.vfsjfilechooser.plaf.metal
Source Code: MetalVFSFileChooserUI.java (Click to view .java file)
Method Code:
@Override public void setFileName(String filename){
if (fileNameTextField != null) {
fileNameTextField.setText(filename);
}
}
Project Name: weka Package: weka.classifiers.bayes.net
Source Code: GUI.java (Click to view .java file)
Method Code:
/**
* This method sets the node size that is appropriate considering the
* maximum label size that is present. It is used internally when custom
* node size checkbox is unchecked.
*/
protected void setAppropriateNodeSize(){
int strWidth;
FontMetrics fm=this.getFontMetrics(this.getFont());
int nMaxStringWidth=DEFAULT_NODE_WIDTH;
if (nMaxStringWidth == 0) for (int iNode=0; iNode < m_BayesNet.getNrOfNodes(); iNode++) {
strWidth=fm.stringWidth(m_BayesNet.getNodeName(iNode));
if (strWidth > nMaxStringWidth) nMaxStringWidth=strWidth;
}
m_nNodeWidth=nMaxStringWidth + 4;
m_nPaddedNodeWidth=m_nNodeWidth + PADDING;
m_jTfNodeWidth.setText("" + m_nNodeWidth);
m_nNodeHeight=2 * fm.getHeight();
m_jTfNodeHeight.setText("" + m_nNodeHeight);
}
Project Name: weka Package: weka.gui
Source Code: SimpleDateFormatEditor.java (Click to view .java file)
Method Code:
/**
* Responds to a change of the text field.
*/
public void formatChanged(){
m_FormatText.setText(m_Format.toPattern());
m_propSupport.firePropertyChange(null,null,null);
}
Project Name: weka Package: weka.gui
Source Code: SimpleCLIPanel.java (Click to view .java file)
Method Code:
/**
* Only gets called when return is pressed in the input area, which
* starts the command running.
* @param e a value of type 'ActionEvent'
*/
public void actionPerformed(ActionEvent e){
try {
if (e.getSource() == m_Input) {
String command=m_Input.getText();
int last=m_CommandHistory.size() - 1;
if ((last < 0) || !command.equals((String)m_CommandHistory.elementAt(last))) {
m_CommandHistory.addElement(command);
saveHistory();
}
m_HistoryPos=m_CommandHistory.size();
runCommand(command);
m_Input.setText("");
}
}
catch ( Exception ex) {
System.err.println(ex.getMessage());
}
}
Project Name: weka Package: weka.gui
Source Code: CostMatrixEditor.java (Click to view .java file)
Method Code:
/**
* Responds to a change in structure of the matrix being edited.
*/
public void matrixChanged(){
m_tableModel.fireTableStructureChanged();
m_classesField.setText("" + m_matrix.size());
}
Project Name: weka Package: weka.gui.beans
Source Code: ClassifierCustomizer.java (Click to view .java file)
Method Code:
public void customizerClosing(){
if (m_executionSlotsText.getText().length() > 0) {
int newSlots=Integer.parseInt(m_executionSlotsText.getText());
m_dsClassifier.setExecutionSlots(newSlots);
}
}
Project Name: weka Package: weka.gui.beans
Source Code: ClassValuePickerCustomizer.java (Click to view .java file)
Method Code:
private void setupTextBoxSelection(){
m_textBoxEntryMode=true;
JPanel holderPanel=new JPanel();
holderPanel.setLayout(new BorderLayout());
holderPanel.setBorder(BorderFactory.createTitledBorder("Specify class label"));
JLabel label=new JLabel("Class label ",SwingConstants.RIGHT);
holderPanel.add(label,BorderLayout.WEST);
m_valueTextBox=new JTextField(15);
m_valueTextBox.setToolTipText("Class label. /first, /last and /<num> " + "can be used to specify the first, last or specific index " + "of the label to use respectively.");
holderPanel.add(m_valueTextBox,BorderLayout.CENTER);
JPanel holder2=new JPanel();
holder2.setLayout(new BorderLayout());
holder2.add(holderPanel,BorderLayout.NORTH);
add(holder2,BorderLayout.CENTER);
String existingClassVal=m_classValuePicker.getClassValue();
if (existingClassVal != null) {
m_valueTextBox.setText(existingClassVal);
}
}
Project Name: weka Package: weka.gui.boundaryvisualizer
Source Code: BoundaryVisualizer.java (Click to view .java file)
Method Code:
/**
* Sets up the BoundaryPanel object so that it is ready for plotting.
* @return an error code:<br/>
* 0 - SUCCESS<br/>
* 1 - ERROR - Kernel bandwidth < 0<br/>
* 2 - ERROR - Kernel bandwidth >= number of training instances.
*/
public int setUpBoundaryPanel() throws Exception {
int returner=0;
int tempSamples=m_numberOfSamplesFromEachRegion;
try {
tempSamples=Integer.parseInt(m_regionSamplesText.getText().trim());
}
catch ( Exception ex) {
m_regionSamplesText.setText("" + tempSamples);
}
m_numberOfSamplesFromEachRegion=tempSamples;
m_boundaryPanel.setNumSamplesPerRegion(tempSamples);
tempSamples=m_generatorSamplesBase;
try {
tempSamples=Integer.parseInt(m_generatorSamplesText.getText().trim());
}
catch ( Exception ex) {
m_generatorSamplesText.setText("" + tempSamples);
}
m_generatorSamplesBase=tempSamples;
m_boundaryPanel.setGeneratorSamplesBase((double)tempSamples);
tempSamples=m_kernelBandwidth;
try {
tempSamples=Integer.parseInt(m_kernelBandwidthText.getText().trim());
}
catch ( Exception ex) {
m_kernelBandwidthText.setText("" + tempSamples);
}
m_kernelBandwidth=tempSamples;
m_dataGenerator.setKernelBandwidth(tempSamples);
if (m_kernelBandwidth < 0) returner=1;
if (m_kernelBandwidth >= m_trainingInstances.numInstances()) returner=2;
m_trainingInstances.setClassIndex(m_classAttBox.getSelectedIndex());
m_boundaryPanel.setClassifier(m_classifier);
m_boundaryPanel.setTrainingData(m_trainingInstances);
m_boundaryPanel.setXAttribute(m_xIndex);
m_boundaryPanel.setYAttribute(m_yIndex);
m_boundaryPanel.setPlotTrainingData(m_plotTrainingData.isSelected());
return returner;
}
Project Name: weka Package: weka.gui.experiment
Source Code: SimpleSetupPanel.java (Click to view .java file)
Method Code:
/**
* Lets user browse for a destination file..
*/
private void chooseDestinationFile(){
FileFilter fileFilter=null;
if (m_ResultsDestinationCBox.getSelectedItem() == DEST_CSV_TEXT) {
fileFilter=m_csvFileFilter;
}
else {
fileFilter=m_arffFileFilter;
}
m_DestFileChooser.setFileFilter(fileFilter);
int returnVal=m_DestFileChooser.showSaveDialog(this);
if (returnVal != JFileChooser.APPROVE_OPTION) {
return;
}
m_ResultsDestinationPathTField.setText(m_DestFileChooser.getSelectedFile().toString());
}
Project Name: weka Package: weka.gui.experiment
Source Code: ResultsPanel.java (Click to view .java file)
Method Code:
/**
* Carries out a t-test using the current configuration.
*/
protected void performTest(){
String sigStr=m_SigTex.getText();
if (sigStr.length() != 0) {
m_TTester.setSignificanceLevel((new Double(sigStr)).doubleValue());
}
else {
m_TTester.setSignificanceLevel(ExperimenterDefaults.getSignificance());
}
m_TTester.setShowStdDevs(m_ShowStdDevs.isSelected());
if (m_Instances.attribute(m_SortCombo.getSelectedItem().toString()) != null) m_TTester.setSortColumn(m_Instances.attribute(m_SortCombo.getSelectedItem().toString()).index());
else m_TTester.setSortColumn(-1);
int compareCol=m_CompareCombo.getSelectedIndex();
int tType=m_TestsList.getSelectedIndex();
String name=(new SimpleDateFormat("HH:mm:ss - ")).format(new Date()) + (String)m_CompareCombo.getSelectedItem() + " - "+ (String)m_TestsList.getSelectedValue();
StringBuffer outBuff=new StringBuffer();
outBuff.append(m_TTester.header(compareCol));
outBuff.append("\n");
m_History.addResult(name,outBuff);
m_History.setSingle(name);
m_TTester.setDisplayedResultsets(m_DisplayedList.getSelectedIndices());
m_TTester.setResultMatrix(m_ResultMatrix);
try {
if (tType < m_TTester.getNumResultsets()) {
outBuff.append(m_TTester.multiResultsetFull(tType,compareCol));
}
else if (tType == m_TTester.getNumResultsets()) {
outBuff.append(m_TTester.multiResultsetSummary(compareCol));
}
else {
outBuff.append(m_TTester.multiResultsetRanking(compareCol));
}
outBuff.append("\n");
}
catch ( Exception ex) {
outBuff.append(ex.getMessage() + "\n");
}
m_History.updateResult(name);
}
Project Name: weka Package: weka.gui.experiment
Source Code: RunNumberPanel.java (Click to view .java file)
Method Code:
/**
* Gets the current upper run number.
* @return the upper run number.
*/
public int getUpper(){
int result=1;
try {
result=Integer.parseInt(m_UpperText.getText());
}
catch ( Exception ex) {
}
return Math.max(1,result);
}
Project Name: weka Package: weka.gui.experiment
Source Code: HostListPanel.java (Click to view .java file)
Method Code:
/**
* Handle actions when text is entered into the host field or the
* delete button is pressed.
* @param e a value of type 'ActionEvent'
*/
public void actionPerformed(ActionEvent e){
if (e.getSource() == m_HostField) {
((DefaultListModel)m_List.getModel()).addElement(m_HostField.getText());
m_DeleteBut.setEnabled(true);
}
else if (e.getSource() == m_DeleteBut) {
int[] selected=m_List.getSelectedIndices();
if (selected != null) {
for (int i=selected.length - 1; i >= 0; i--) {
int current=selected[i];
((DefaultListModel)m_List.getModel()).removeElementAt(current);
if (((DefaultListModel)m_List.getModel()).size() > current) {
m_List.setSelectedIndex(current);
}
else {
m_List.setSelectedIndex(current - 1);
}
}
}
if (((DefaultListModel)m_List.getModel()).size() == 0) {
m_DeleteBut.setEnabled(false);
}
}
}
Project Name: weka Package: weka.gui.graphvisualizer
Source Code: GraphVisualizer.java (Click to view .java file)
Method Code:
/**
* This method sets the node size that is appropriate
* considering the maximum label size that is present.
* It is used internally when custom node size checkbox
* is unchecked.
*/
protected void setAppropriateNodeSize(){
int strWidth;
if (maxStringWidth == 0) for (int i=0; i < m_nodes.size(); i++) {
strWidth=fm.stringWidth(((GraphNode)m_nodes.elementAt(i)).lbl);
if (strWidth > maxStringWidth) maxStringWidth=strWidth;
}
nodeWidth=maxStringWidth + 4;
paddedNodeWidth=nodeWidth + 8;
jTfNodeWidth.setText("" + nodeWidth);
nodeHeight=2 * fm.getHeight();
jTfNodeHeight.setText("" + nodeHeight);
}
Project Name: weka Package: weka.gui.sql
Source Code: ConnectionPanel.java (Click to view .java file)
Method Code:
/**
* Lets the user select a props file for changing the database connection
* parameters.
*/
public void switchSetup(){
int retVal;
retVal=m_SetupFileChooser.showOpenDialog(this);
if (retVal != JFileChooser.APPROVE_OPTION) return;
m_DbUtils.initialize(m_SetupFileChooser.getSelectedFile());
m_URL=m_DbUtils.getDatabaseURL();
m_User=m_DbUtils.getUsername();
m_Password=m_DbUtils.getPassword();
m_TextURL.setText(m_URL);
}
Project Name: weka Package: weka.gui.streams
Source Code: InstanceLoader.java (Click to view .java file)
Method Code:
public String getArffFile(){
return m_FileNameTex.getText();
}
Project Name: weka Package: weka.gui.visualize
Source Code: MatrixPanel.java (Click to view .java file)
Method Code:
/**
* This method changes the Instances object of this class to a new one. It also does all the necessary
* initializations for displaying the panel. This must be called before trying to display the panel.
* @param newInst The new set of Instances
*/
public void setInstances(Instances newInst){
m_osi=null;
m_fastScroll.setSelected(false);
m_data=newInst;
setPercent();
setupAttribLists();
m_rseed.setText("1");
initInternalFields();
m_cp.setInstances(m_data);
m_cp.setCindex(m_classIndex);
m_updateBt.doClick();
}
Project Name: weka Package: weka.gui.visualize
Source Code: PrintableComponent.java (Click to view .java file)
Method Code:
/**
* displays a save dialog for saving the panel to a file.
* Fixes a bug with the Swing JFileChooser: if you entered a new
* filename in the save dialog and press Enter the <code>getSelectedFile</code>
* method returns <code>null</code> instead of the filename.<br>
* To solve this annoying behavior we call the save dialog once again s.t. the
* filename is set. Might look a little bit strange to the user, but no
* NullPointerException! ;-)
*/
public void saveComponent(){
int result;
JComponentWriter writer;
File file;
JComponentWriterFileFilter filter;
m_FileChooserPanel.setDialogTitle(getSaveDialogTitle());
do {
result=m_FileChooserPanel.showSaveDialog(getComponent());
if (result != JFileChooser.APPROVE_OPTION) return;
}
while (m_FileChooserPanel.getSelectedFile() == null);
try {
filter=(JComponentWriterFileFilter)m_FileChooserPanel.getFileFilter();
file=m_FileChooserPanel.getSelectedFile();
writer=filter.getWriter();
if (!file.getAbsolutePath().toLowerCase().endsWith(writer.getExtension().toLowerCase())) file=new File(file.getAbsolutePath() + writer.getExtension());
writer.setComponent(getComponent());
writer.setFile(file);
writer.setScale(getXScale(),getYScale());
writer.setUseCustomDimensions(m_CustomDimensionsCheckBox.isSelected());
if (m_CustomDimensionsCheckBox.isSelected()) {
writer.setCustomWidth(Integer.parseInt(m_CustomWidthText.getText()));
writer.setCustomHeight(Integer.parseInt(m_CustomHeightText.getText()));
}
else {
writer.setCustomWidth(-1);
writer.setCustomHeight(-1);
}
writer.toOutput();
}
catch ( Exception e) {
e.printStackTrace();
}
}