⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newticketauction.java

📁 这是手机下载网络图像源码 共初学者参考
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            }            // Jazz            if (selected[4]) {            }            // Classical            if (selected[5]) {            }            return s;        }        long stringToLong1000(String s) {            if (s == null || s.equals("")) {                return 0;            }            try {                int index = s.indexOf('.');                if (index == -1)                    return (long)1000*Integer.parseInt(s);                long integerPart = 		    1000*Integer.parseInt(s.substring(0, index));                String fracString = s.substring(index+1);                int multBy = 0;                switch (fracString.length()) {                case 0:                    multBy = 0;                    break;                case 1:                    multBy = 100;                    break;                case 2:                    multBy = 10;                    break;                case 3:                    multBy = 1;                    break;                }                long fractionalPart = multBy * Integer.parseInt(fracString);                return integerPart + fractionalPart;            } catch (NumberFormatException nfe) {                return 0;            }        }        String long1000ToString(long l) {            if (l == 0)                return "0";            String s = String.valueOf(l);            if (s.length() < 4)                return "0";            String newStr = s.substring(0, s.length()-3) +"."+                 s.substring(s.length()-2);            return newStr;        }    } // end  band    class RmBand extends List implements CommandListener {        RmBand() {            super("Remove Bands", Choice.MULTIPLE);            String[] list = band.getList();            for (int i = 0; i < list.length; i++) {                append(list[i], null);            }               addCommand(BACK_CMD);            addCommand(SAVE_CMD);            setCommandListener(this);        }        public void commandAction(Command c, Displayable s) {            if (c == SAVE_CMD) {                                  // Make the ChoiceGroup invisible before doing                // reconstruction                boolean[] ret = new boolean[size()];                getSelectedFlags(ret);                removeBandList(ret);                // go back to band_ticket_Form after save                display.setCurrent(savedMsg, band_ticket_Form);              } else if (c == BACK_CMD) {                display.setCurrent(band_ticket_Form);            }        }        void reset() {            reconstructList(this, band.getList());        }        void removeBandList(boolean[] t) {            int i = t.length;            while (--i >= 0) {                if (t[i]) {                    band.remove(i);                }            }            reconstructBandTicketForm(band.getList());            reconstructList(this, band.getList());        }    } // end rm band    class UpdateAlert {        String band = "", bid = "";         Alert soundAlert;        UpdateAlert() {            soundAlert = new Alert("Alert", "",                             null, AlertType.ALARM);            soundAlert.setTimeout(Alert.FOREVER);        }        void set(String band, String bid) {            this.band = band;            this.bid = bid;        }        boolean hasDataToUpdate() {            return ((band != null) && (band != "") &&                    (bid != null) && (bid != ""));        }        void show() {            // no-op if band & bid aren't set            if (hasDataToUpdate()) {                String s = new String(band + "\n" +                                   "ticket bids\n" +                                  "have reached\n" +                                  "$" + bid);                soundAlert.setString(s);                display.setCurrent(soundAlert);            }        }    }// end UpdateAlert     void updateBandList(String list) {        if (list.length() == 0) {            return;        }        Vector vec = new Vector();        int fidx = 0;        while (true) {            int idx = list.indexOf(',', fidx);            if (idx == -1) {                vec.addElement(list.substring(fidx));                break;            }            vec.addElement(list.substring(fidx, idx));            fidx = idx + 1;        }        for (int i = 0; i < vec.size(); i++) {            String str = (String)vec.elementAt(i);            int j = 0;            int len = str.length();            for (; j < len; j++) {                if (str.charAt(j) != ' ') {                    break;                }            }            if (j == len) {                continue;            }            if (j == 0) {                band.add(str);            } else {                band.add(str.substring(j));            }        }        reconstructBandTicketForm(band.getList());        rmBand.reset();    }    void reconstructBandTicketForm(String[] items) {        if (items == null || items.length == 0) {            bandCg.deleteAll();            auctionCg.setLabel(null);            auctionCg.deleteAll();            return;        }        reconstructList(bandCg, items);        bandCg.setSelectedIndex(0, true);        String bandName = band.getName(bandCg.getSelectedIndex());        auctionCg.setLabel(bandName + " Auctions:");        reconstructList(auctionCg, band.getTicketList(bandName));    }    void reconstructList(Choice list, String[] items) {        list.deleteAll();        for (int i = 0; i < items.length; i++) {            list.append(items[i], null);        }    }    class SetMenuForm extends Form         implements CommandListener, ItemStateListener {        Timer timerService = new Timer();        ChoiceGroup tickerCg, updatesCg;        Gauge gauge;        DateField dateTimeItem;        int updateChoice, volumeValue;        boolean musicChoice[];        boolean systemCurrentDate = true;        long setTimeMillisDelta, curTimeMillisDelta;        SetMenuForm() {            super("Settings");            tickerCg = new ChoiceGroup("Ticker Display", Choice.MULTIPLE);            tickerCg.append("Rock", null);            tickerCg.append("Pop", null);            tickerCg.append("Country", null);            tickerCg.append("Alternative", null);            tickerCg.append("Jazz", null);            tickerCg.append("Classical", null);            musicChoice = new boolean[] {false, false, false,                                          true, false, false};            append(tickerCg);            updatesCg = new ChoiceGroup("Updates", Choice.EXCLUSIVE);            updatesCg.append("Continuous", null);            updatesCg.append("15 minutes", null);            updatesCg.append("30 minutes", null);            updatesCg.append("1 hour", null);            updatesCg.append("3 hours", null);            updateChoice = 0;            append(updatesCg);            /* Set Number */            gauge = new Gauge(null, true, 40, 0);            volumeValue = 0;            append(gauge);            setItemStateListener(this);            setTimeMillisDelta = curTimeMillisDelta = 0;            dateTimeItem = new DateField("Set Date:", DateField.DATE_TIME) {                public void showNotify() {                    long millis = System.currentTimeMillis();                    if (curTimeMillisDelta != 0) {                        millis -= curTimeMillisDelta;                    }                    setDate(new java.util.Date(millis));                }            };            append(dateTimeItem);            settings(musicChoice, updateChoice,                      volumeValue, setTimeMillisDelta);            addCommand(BACK_CMD);            addCommand(SAVE_CMD);            setCommandListener(this);        }        public void settings(boolean musicChoice[], int updateChoice,                             int volumeValue, long curTimeMillisDelta) {            tickerCg.setSelectedFlags(musicChoice);            updatesCg.setSelectedIndex(updateChoice, true);            gauge.setValue(volumeValue);            gauge.setLabel("Set Alert Volume: " + volumeValue);            long millis = System.currentTimeMillis();            if (curTimeMillisDelta != 0) {                 millis -= curTimeMillisDelta;            }            dateTimeItem.setDate(new java.util.Date(millis));        }        public void commandAction(Command c, Displayable s) {            if (c == SAVE_CMD) {                tickerCg.getSelectedFlags(musicChoice);                String str = band.toTickerString(musicChoice);                if (str != null) {                    ticker.setString(str);                }                updateChoice = updatesCg.getSelectedIndex();                               volumeValue = gauge.getValue();                setTimeMillisDelta = curTimeMillisDelta;                if (updateAlert.hasDataToUpdate()) {                    int idx = updatesCg.getSelectedIndex();                    TimerTask timerClient = new TimerTask() {                        public final void run() {                          updateAlert.show();                        }                    };                    switch (idx) {                    case 0:                        timerService.schedule(timerClient, 3000);                        break;                    case 1:                        timerService.schedule(timerClient, 3000);                        break;                    case 2:                        timerService.schedule(timerClient, 3000);                        break;                    case 3:                        timerService.schedule(timerClient, 3000);                        break;                    case 4:                        timerService.schedule(timerClient, 3000);                        break;                    }                }                display.setCurrent(savedMsg, band_ticket_Form);            } else if (c == BACK_CMD) {                display.setCurrent(band_ticket_Form);                settings(musicChoice, updateChoice,                          volumeValue, setTimeMillisDelta);            }        }        public void itemStateChanged(Item item) {             if (item == gauge) {                int currentValue = gauge.getValue();                gauge.setLabel("Set Alert Volume: " +                                 String.valueOf(currentValue));            } else if (item == dateTimeItem) {                curTimeMillisDelta = System.currentTimeMillis() -                     dateTimeItem.getDate().getTime();            }        }    }    void deleteFormItem(Form f) {        int num = f.size();        while (--num >= 0) {            f.delete(num);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -