我希望fillmeup
按钮低于JButtons
说 setBackground( new Color(130,50,40) );
setLayout( new BorderLayout(3,3) );
BlackjackCanvas board = new BlackjackCanvas();
add(board, BorderLayout.CENTER);
Panel buttonPanel = new Panel();
buttonPanel.setBackground(new Color(220,200,180));
add(buttonPanel, BorderLayout.SOUTH);
Panel buttonPane2 = new Panel();
buttonPane2.setBackground(new Color(220,200,180));
add(buttonPane2, BorderLayout.EAST);
Panel buttonPane3 = new Panel();
buttonPane3.setBackground(new Color(220,200,180));
add(buttonPane3, BorderLayout.WEST);
Button hit = new Button( "Hit!" );
hit.addActionListener(board);
hit.setBackground(Color.lightGray);
buttonPanel.add(hit);
Button stand = new Button( "Stand!" );
stand.addActionListener(board);
stand.setBackground(Color.lightGray);
buttonPanel.add(stand);
Button newGame = new Button( "New Game" );
newGame.addActionListener(board);
newGame.setBackground(Color.lightGray);
buttonPanel.add(newGame);
JLabel money = new JLabel( "Fill me up!" );
money.setBackground(Color.lightGray);
buttonPane2.add(money);
Button money1 = new Button( "A rare commodity" );
newGame.addActionListener(board);
newGame.setBackground(Color.lightGray);
buttonPane2.add(money1);
,但当我尝试添加按钮时,它会移到标签右侧而不是它下面。我正在使用applet并使用 private void setAlarm(Calendar targetCal) {
deleteCopy();
info.setText("\n\n***\n"
+ "Alarm is set @ " + targetCal.getTime() + "\n"
+ "***\n");
Intent intent = new Intent(getBaseContext(), AlarmReceiver.class);
pendingIntent = PendingIntent.getBroadcast(getBaseContext(), RQS_1, intent, 0);
alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(), pendingIntent);
Intent alarmIIntent = new Intent(this, AlarmReceiver.class);
Intent intent_ForResult = new Intent(TimeDateRem.this, MainActivity.class);
startActivity(intent_ForResult);}
public void deleteCopy() {
Cursor cursor = dba.getnameofAlarm(title.getText().toString());
if (cursor.moveToFirst()) {
final DatabaseActivity dba= new DatabaseActivity(getApplicationContext());
String titleData=(cursor.getString(cursor.getColumnIndex(Constants.COLUMN_NAME)));
if(title.getText().toString().matches(titleData)) {
AlertDialog.Builder builder = new AlertDialog.Builder(TimeDateRem.this);
builder.setTitle("Set Alarm");
builder.setMessage("By setting this alarm you will be deleting the previous one, is that OK?")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dba.deleteAlarm(title.getText().toString().trim());
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
cursor.close();
}
。任何建议将不胜感激。
The blackJack game I am trying to make
{{1}}
答案 0 :(得分:1)
我会考虑参考这里的文档Java Layout Options
将buttonPane2布局管理器设置为满足您需求的布局管理器。
这可以使用setLayout(new xxxLayout());
来完成