下面列出了java.awt.Adjustable#getMaximum ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
public static void scrollAdjustable(Adjustable adj, int amount) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (adj == null) {
log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
// down
if (current + amount < upperLimit) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(upperLimit);
return;
}
}
else if (amount < 0 && current > adj.getMinimum()) { // still some room
// to scroll up
if (current + amount > adj.getMinimum()) {
adj.setValue(current + amount);
return;
}
else {
adj.setValue(adj.getMinimum());
return;
}
}
}
/**
* Check if a scroll bar is at its maximum value.
*
* @param bar scroll bar
* @return <code>true</code> if the scrollbar is at its maximum value
* location, <code>false</code>otherwise
*/
private boolean isAtMaximum(Adjustable bar) {
return (bar.getValue() + bar.getVisibleAmount() >= bar.getMaximum());
}