在swing中绑定combobox

我正在使用Eclipse IDE开发桌面(swing)应用程序。 我有三个combobox(国家,州和城市),我需要在选择新的国家或省时自动更新数据。 我搜索了很多信息,但我发现的所有实现都是在Ajax或NetBeans中的豆类绑定框架上完成的。 我尝试了ItemEvent的解决方案,但我在启动应用程序时遇到问题,它加载了国家/地区列表而不是其他列表。 通过选择一个国家/地区,将收取州名单,但不包括城市列表。 我的代码: jComboBoxCountries.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { jComboBoxStates.setModel(new javax.swing.DefaultComboBoxModel( statesOf(evt.getItem()).toArray() )); } }); jComboBoxStates.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { jComboBoxCities.setModel(new javax.swing.DefaultComboBoxModel( citiesOf(evt.getItem()).toArray()) ); } }); jComboBoxCountries.setModel(new javax.swing.DefaultComboBoxModel( countryList.toArray()));

char类型可以归类为整数吗?

刚才我读到“char是Java中唯一的无符号整数原始类型”。 这是否意味着char是Java中不可或缺的类型之一? 与C中相同,最近我读过C类型包括标量类型,函数类型,联合类型,聚合类型,标量类型包括指针类型和算术类型,然后算术类型包括整数类型和浮点类型,整数类型包括枚举类型和字符类型。 char类型真的可以归类为Java和C中的整数吗?

阻止从登录默认消息传递应用程序发送SMS

我有一个自动回复我建立的Android应用程序,我不希望自动回复(发送短信)显示在默认的消息应用程序中。 我搜索并搜索过,找不到答案。 有没有办法绕过将发送的短信写入默认的短信应用程序? 这是我的BroadcastReciever,我用它来获取数据并发送消息 public class SmsReceiver extends BroadcastReceiver { ParseUser user = ParseUser.getCurrentUser(); // Auto reply message composed of the current reply and url from that business String msg = user.getString(“myCurrentReply”) + ” ” + user.getString(“couponUrlChosen”); List smsFromList = user.getList(“smsFrom”); String userName = (String) user.get(“username”); @Override public void onReceive(final Context context, Intent intent) { […]

如何在从多种语言中读取数据时避免使用垃圾/垃圾字符?

我正在解析来自10多种不同语言的RSS新闻源。 所有解析都是在java中完成的,数据存储在MySQL中,然后我用PHP编写的API响应客户端。 当我读取数据时,我经常遇到垃圾字符。 我试过了什么: 我已将MySQL配置为存储utf-8数据。 我的db,table甚至列都有UTF8作为它们的默认字符集。 连接我的数据库时,我将字符集结果设置为utf-8 当我手动运行jar文件以插入数据时,角色看起来很好。 但是当我为同一个jar文件设置一个cronjob时,我又开始面对这个问题了。 在英语中,我特别面对像这样的问题,在其他本地语言中,这个角色看起来完全是垃圾,我甚至无法识别单个角色。 有什么我想念的吗? 样本垃圾字符: 古吉拉特语 :“રેàªààªμેàªàà«àªàààààà«àªàà€ààààªààààààààààààààààààààààààààààààààà««àà€« ¤à«<મળશેàªμળતર!“ Malyalam :“à’ààμ‡à’ªàμà’ªà’¾à’³à’¿à’²àμ‡à’ààμà’àààààààààààààààààààààààààà’àà’àà ‘°à’•àμà’•àμà’ààμà’±à’šàμà’šàμ“ 英语 :银行局局扩大金融部门PSU的范围

如何在Spring MVC中实现HTTP字节范围请求

我的网站上有video倒带的问题。 我找出了http标题的问题。 我当前的控制器方法返回video: @RequestMapping(method = RequestMethod.GET, value = “/testVideo”) @ResponseBody public FileSystemResource testVideo(Principal principal) throws IOException { return new FileSystemResource(new File(“D:\\oceans.mp4”)); } 如何用字节范围支持重写以下代码? PS 我见过以下示例http://balusc.blogspot.in/2009/02/fileservlet-supporting-resume-and.html 但是这段代码看起来很难,我无法理解。 我希望在springmvc存在方式更简单。

如何解决通过Wi-Fi(android API)发现其他设备?

最近我按照Developer.Android.Com给出的步骤进行操作 但似乎我在那里有一些运气。 我试图发现附近可用的同伴,把他们放入arraylist但似乎没有运气。 我没有得到任何东西。 我的实际2设备实际上是Android 4.1和4.2由于Wifi Direct基于API等级14,这是Android 4.0+所以我认为我的真实设备不是问题。 我使用的概念是使用1个活动和1个BroadCast接收器。 请看看我的代码,我是错误地写了还是忘记了什么? Chat1Activity.java package com.example.androtut; import java.util.ArrayList; import others.MyBroadcastReceiver; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.IntentFilter; import android.net.wifi.p2p.WifiP2pDeviceList; import android.net.wifi.p2p.WifiP2pManager; import android.net.wifi.p2p.WifiP2pManager.Channel; import android.net.wifi.p2p.WifiP2pManager.PeerListListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Chat1Activity extends Activity { private final IntentFilter mintentFilter = new IntentFilter(); private […]

PIG – 找到接口org.apache.hadoop.mapreduce.JobContext,但是类是预期的

我试图从蜂巢中加载一个表。 我正在使用Hcatalog。 我使用登录hive pig -useHCatalog 我从蜂巢和hadoop出口几乎所有的jar子 register ‘hdfs://localhost:8020/user/pig/jars/hive-jdbc-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-exec-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-common-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-metastore-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/mysql-connector-java-5.1.28-bin.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-beeline-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-builtins-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-cli-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-contrib-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-hbase-handler-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-hwi-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-metastore-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-pdk-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-serde-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-service-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hive-shims-0.10.0-cdh4.5.0.jar’; register ‘hdfs://localhost:8020/user/pig/jars/antlr-2.7.7.jar’; register ‘hdfs://localhost:8020/user/pig/jars/antlr-runtime-3.4.jar’; register ‘hdfs://localhost:8020/user/pig/jars/avro-1.7.4.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hcatalog-core-0.5.0-incubating.jar’; register ‘hdfs://localhost:8020/user/pig/jars/hcatalog-pig-adapter-0.5.0-incubating.jar’; register ‘hdfs://localhost:8020/user/pig/jars/avro-ipc-1.7.4-tests.jar’; register ‘hdfs://localhost:8020/user/pig/jars/avro-mapred-1.7.4-hadoop2.jar’; register ‘hdfs://localhost:8020/user/pig/jars/commons-cli-1.2.jar’; register […]

更改JFrame标题

这段代码编译,我只是无法在标题栏上更改名称。 import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.JTextField; public class VolumeCalculator extends JFrame implements ActionListener { private JTabbedPane jtabbedPane; private JPanel options; JTextField poolLengthText, poolWidthText, poolDepthText, poolVolumeText, hotTub, hotTubLengthText, hotTubWidthText, hotTubDepthText, hotTubVolumeText, temp, results, myTitle; JTextArea labelTubStatus; public VolumeCalculator() { setSize(400, 250); […]

在任何屏幕分辨率中定位图像

我的程序有问题。 每当我更改屏幕分辨率时,我的图像就会开始移动到位置之外。 有关如何使我的图像保持在同一位置的任何建议,即使我更改为任何其他分辨率? p2 = new JPanel(); p2.setLayout(new FlowLayout()); ImageIcon img2 = new ImageIcon(“C:\\Drum\\Invisible4.png”); jbtn2 = new JLabel(img2); p2.add(jbtn2); add(jbtn2); jbtn2.setSize(jbtn2.getPreferredSize()); jbtn2.setLocation(140, 380);

如何在Spring Boot中以编程方式创建bean?

我有一个应用程序,其中包含application.properties中列出的许多数据源设置。 我有一个@ConfigurationProperties类来加载这些设置。 现在我想从这个ConfigurationProperties类中获取值,并使用它们即时创建DataSource bean。 我尝试过使用@PostConstruct并实现BeanFactoryPostProcessor 。 但是,使用BeanFactoryPostProcessor ,处理似乎很早就发生了 – 在我的ConfigurationProperties类已经填充之前。 如何使用Spring Boot快速读取属性并创建DataSource bean? 这是我的application.properties的样子: ds.clients[0]=client1|jdbc:db2://server/client1 ds.clients[1]=client2,client3|jdbc:db2://server/client2 ds.clients[2]=client4|jdbc:db2://server/client4 ds.clients[3]=client5|jdbc:db2://server/client5 我的ConfigurationProperties类: @Component @ConfigurationProperties(prefix = “ds”) public class DataSourceSettings { public static Map CLIENT_DATASOURCES = new LinkedHashMap(); private List clients = new ArrayList(); public List getClients() { return clients; } public void setClients(List clients) { this.clients = clients; […]