•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 455,962 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,578 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1218 | Replies: 1
![]() |
•
•
Join Date: Nov 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
Hi Everybody,
I wrote below codes which check textfiled and comco box for equals. But i want write a integer in textfiled and check it with combobox;
For example
When i write in texfiled 10 in the 10. on combobox is Balıkesir so if i select Balıkesir it's true but another it's false like that
Also i try this but notthing work.
give me an error like this
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems:
Type mismatch: cannot convert from int to boolean
Type mismatch: cannot convert from String to int
Can you help me for this Subject. And sorry for my English.
I wrote below codes which check textfiled and comco box for equals. But i want write a integer in textfiled and check it with combobox;
For example
When i write in texfiled 10 in the 10. on combobox is Balıkesir so if i select Balıkesir it's true but another it's false like that
Also i try this but notthing work.
String te; te = tf.getText(); int te2 = Integer.parseInt(te);
give me an error like this
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems:
Type mismatch: cannot convert from int to boolean
Type mismatch: cannot convert from String to int
Can you help me for this Subject. And sorry for my English.
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
public class source extends JFrame{
/**
*
*/
private static final long serialVersionUID = 1L;
String plaka[] = {
"Adana", "Adıyaman", "Afyon", "Ağrı", "Amasya", "Ankara", "Antalya","Artvin", "Aydın", "Balıkesir", "Bilecik", "Bingöl", "Bitlis", "Bolu",
"Bolu", "Burdur", "Bursa", "Çanakkale", "Çankırı", "Çorum", "Denizli","Diyarbakır", "Edirne", "Elazığ", "Erzincan", "Erzurum", "Eskişehir", "Gaziantep",
"Giresun", "Gümüşhane", "Hakkari", "Hatay", "Isparta", "İçel", "İstanbul","İzmir", "Kars", "Kastamonu", "Kayseri", "Kırklareli", "Kırşehir", "Kocaeli",
"Kütahya", "Malatya", "Manisa", "Kahramanmaraş", "Mardin", "Muğla", "Muş","Nevşehir", "Niğde", "Ordu", "Rize", "Sakarya", "Samsun", "Siirt",
"Sinop", "Sivas", "Tekirdağ", "Tokat", "Trabzon", "Tunceli", "Şanlıurfa","Uşak", "Van", "Yozgat", "Zonguldak", "Aksaray", "Bayburt", "Karaman",
"Kırıkkale", "Batman", "Şırnak", "Bartın", "Ardahan", "Iğdır", "Yalova","Karabük", "Kilis", "Osmaniye", "Düzce"
};
JComboBox plakaCB = new JComboBox(plaka);
JTextField tf = new JTextField(23);
public static void main(String[] args) { // main
source ar = new source();
}
public source(){ // Constructor
JScrollPane tf1 = new JScrollPane( tf );
JButton showB = new JButton("Kontrol");
showB.addActionListener( new BtnListener() );
JPanel content = new JPanel( new FlowLayout() );
content.add( tf1 );
content.add( plakaCB);
content.add(showB);
setContentPane( content );
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
setVisible(true);
pack();
}
class BtnListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
int index = plakaCB.getSelectedIndex();
if (plakaCB.getItemAt(index).equals(tf.getText())) {
JOptionPane.showMessageDialog(null, "True");
}
else{
JOptionPane.showMessageDialog(null, "wrong");
}
}
}
}
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Function to convert integer to single char. (C)
- How to change integer to word in vb.net (VB.NET)
- Determening load average. (Shell Scripting)
- passing data around (C)
- Is there a simplest way to work this array problem? (C++)
- Cannot incorporate equals method for a yes or no answer. (Java)
Other Threads in the Java Forum
- Previous Thread: Java program help!.please
- Next Thread: Java Applet Triangle, Need Help Please



Linear Mode