我正在尝试用信息hashmap填充vaadin7的组合框.我创建了一个返回HashMap的类,当我得到返回时,我使用a来为每个组合框填充这个组合框,但确实只向我显示数字而不是hashmap的键和值.
我正在尝试这个.
/** states of brasil class */
public class EstadosBrasil {
private static final HashMap<String, String> uf = new HashMap();
/** return all states of brasil */
public static HashMap<String, String> getEstados(){
uf.put("AC", "AC");
uf.put("AL", "AL");
uf.put("AM", "AM");
uf.put("AP", "AP");
uf.put("BA", "BA");
uf.put("CE", "CE");
uf.put("DF", "DF");
uf.put("ES", "ES");
uf.put("FN", "FN");
uf.put("GO", "GO");
uf.put("MA", "MA");
uf.put("MG", "MG");
uf.put("MS", "MS");
uf.put("MT", "MT");
uf.put("PA", "PA");
uf.put("PB", "PB");
uf.put("PE", "PE");
uf.put("PI", "PI");
uf.put("PR", "PR");
uf.put("RJ", "RJ");
uf.put("RN", "RN");
uf.put("RO", "RO");
uf.put("RR", "RR");
uf.put("RS", …Run Code Online (Sandbox Code Playgroud) 我正在阅读关于vaadin的第8章,我无法理解如何为每个组件定义css样式.我在styles.scss上进行了自定义,但所有自定义都转到了所有组件,我不想这样做.
例
HorizontalLayout hLayout = new HorizontalLayout();
HorizontalLayout hMainLayout = new HorizontalLayout();
Run Code Online (Sandbox Code Playgroud)
我希望hLayout有一个背景图片,hMainLayout没有.
我试试这个,但不行.
.v-horizontallayout-hLayout {
background:url("myimage.jpg");
}
.v-horizontallayout-hMainLayout {
background: none;
}
Run Code Online (Sandbox Code Playgroud)
任何的想法 ?
我正在尝试用JodaTime添加月份.我有几个月的付款计划,例如:一个月,两个月,三个月和六个月.
当我在DateTime添加六个月时不起作用并返回异常.
我正在尝试这个.
/** cria data vencimento matricula */
public void getDataVencimento(Integer dia, Integer planoPagamento){
//monta data para JodaTime
DateTime data = new DateTime();
Integer ano = data.getYear();
Integer mes = data.getMonthOfYear() + 6; //here 6 month
//monta a data usando JodaTime
DateTime dt = new DateTime(ano, mes, dia, 0, 0);
//convert o datetime para date
Date dtVencimento = dt.toDate();
System.out.println(df.format(dtVencimento));
//retorna a proxima data vencimento
// return dtVencimento;
}
/** exception */
Exception in thread "AWT-EventQueue-0" org.joda.time.IllegalFieldValueException: Value 14 …Run Code Online (Sandbox Code Playgroud) 我正在尝试用SoundPool执行一个mp3文件.我用SoundPool.load加载了mp3,但是当我尝试使用SoundPool.play不起作用而且没有抛出任何异常.我正在使用API21.
我该如何解决?
我正在尝试这个.
public class CustomSoundPool {
//SDK Version
public SoundPool getSoundPool(){
SoundPool sounds = null;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
AudioAttributes attributes = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_GAME)
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.build();
sounds = new SoundPool.Builder()
.setAudioAttributes(attributes)
.build();
}else{
sounds = new SoundPool(5,AudioManager.STREAM_MUSIC,0);
}
return sounds;
}
}
/** play sound with error or success */
private void playSound(){
SoundPool sound = new CustomSoundPool().getSoundPool();
if(resposta.getValor() == 1){
int soundId = sound.load(getView().getContext(), R.raw.sucesso, 1);
sound.play(soundId, 1, 1, 0, 0, 1);
}else{
int soundId = sound.load(getView().getContext(), R.raw.erro, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 ActionMap 和 InputMap 为我的 JFrame 创建快捷方式。但还是做不到这个工作。我使用 AbstractAction 创建了 ActionMap 来创建操作,并在创建了 InputMap 来注册事件之后,但不起作用
private void acoesTela(){
JPanel painel = (JPanel)this.getContentPane();
ActionMap actionMap = painel.getActionMap();
actionMap.put("consultaProdutos", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent evt) {
System.out.println("F3 is pressed");
}
});
/** registra acoes */
InputMap imap = painel.getInputMap(JPanel.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), "consultaProdutos");
}
Run Code Online (Sandbox Code Playgroud) 我有一个ImageView,我想得到图像的路径,并添加一个String.我想这样做是因为我需要将它发送到我的webservice,就像默认图像一样
我该怎么做 ?
ImageView的
<ImageView
android:id="@+id/ivPerfil"
android:padding="5dp"
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@drawable/icon_usuario"
android:scaleType="fitXY"
/>
Run Code Online (Sandbox Code Playgroud)
走这条路
ivPerfil = (ImageView)findViewById(R.id.ivPerfil);
Drawable img = getResources().getDrawable(R.drawable.icon_usuario);
String pathImage = img.toString();
Run Code Online (Sandbox Code Playgroud) 我正在寻找任何方式创建database并tables与NHibernate和FluentNHibernate。
我该怎么办?
试。
private static ISessionFactory createConnection()
{
if (session != null)
return session;
//database configs
FluentConfiguration _config = Fluently.Configure().Database(
MySQLConfiguration.Standard.ConnectionString(
x => x.Server(HOST).
Username(USER).
Password(PASSWORD).
Database(DB)
))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<PerfilMap>())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<ModuloMap>())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<PermissaoMap>())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<UsuarioMap>())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<CategoriaMap>())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<SubcategoriaMap> ())
.ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(false, true));
session = _config.BuildSessionFactory();
return session;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用bean验证器验证我的bean.问题是我不知道验证需要哪些库(jar).
我正在使用.
Vaadin 7,BeanFieldGroup和EclipseLink
/** class of MyBean */
public class MyBean{
@Id
@GeneratedValue
private Long id;
@NotNull
@NotEmpty
@Size(min=5, max=50, message="Min = 5 and Max = 50, this field is not empty")
private String name;
@Email
@NotEmpty
private String email;
}
Run Code Online (Sandbox Code Playgroud)
任何的想法 ?
我有一个使用JPA的项目J2SE.在一些JDialogs中,我会getResultList()在类的构造函数中返回并填充JTable,JComboBox,JList等.
因此,当我为这些对话框创建任何实例时,有时会很慢.
我认为使用SwingWorker和JProgressbar创建一个(加载)打开JDialogs是一个很好的解决方案,但我不知道该怎么做.
我正在尝试这个.
//
JProgressbar progress = new JProgressBar();
//custommer dialog
JDialog custommer = new JDialog(); //here slow because I have List<Customer> and others lists
custommer.setModal(true);
private void openDialogs(JDialog dialog){
progress.setVisible(true);
progress.setIndeterminate(true);
SwingWorker sw = new SwingWorker(){
protected Object doInBackground(){
//opening dialog
dialog.setVisible(true);
return null;
}
}
//after opened
protected void done(){
progress.setVisible(false);
}
}
Run Code Online (Sandbox Code Playgroud)
如何打开JDialog并创建一个用SwingWorker和JProgressbar打开的加载?
我正在尝试更改JLabel的颜色字符文本.
我有一个JLabel文字:"JLABEL",我想要只改变颜色字符"L".在更改之后,我想要更改字符"L"的显示文本"JLABEL".
我怎样才能做到这一点 ?
我正在尝试这个:
private void characterFormat(){
jlabel.setText("JLABEL");
char[] t = jlabel.getText().toCharArray();
String txtFormat = "";
for(int x = 0; x < t.length; x++){
if(t[x] == 'L'){
txtFormat += String.format("<html><font color=RED>%s</font></html>", t[x]);
}
}
jlabel.setText(txtFormat);
}
Run Code Online (Sandbox Code Playgroud) 我正在寻找使用JodaTime每月创建固定日期的任何方式。我有一个JSpinner来设置整数值,我想获取此值并创建日期。例如:JSpinner的有15个,我想创建之日起2016-09-15,2016-10-15,2016-11-15。
如何使用JodaTime做到这一点?
java ×8
swing ×3
vaadin ×3
vaadin7 ×3
android ×2
jodatime ×2
c# ×1
date ×1
frameworks ×1
html ×1
jdialog ×1
jframe ×1
jlabel ×1
jpa ×1
jprogressbar ×1
netbeans ×1
nhibernate ×1
soundpool ×1
swingworker ×1