More elegant timing solution
Hi all.
Im am looking for some advice regarding a GUI that I am developing using netbeans.
When a particular button is clicked on the interface I have a series of jPanels which I wish to make visisble with a delay in between each one.
I currently have a solution posted here using a Timer and a switch statement within the timer class but it all seems a little cumbersome and basic. I just wondered if anyone had any ideas for a more elegant solution.
Thanks
int listCount =1;
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
timer = new Timer(2500, new ListAction());
timer.start();
class ListAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
switch (listCount) {
case 1: jLabel32.setVisible(true);
jLabel33.setVisible(true);
jLabel34.setVisible(true);
jLabel35.setVisible(true);
jLabel36.setVisible(true);
jLabel37.setVisible(true);
jLabel38.setVisible(true);
listCount++;
break;
case 2:
jLabel32.setBackground(new Color(241,114,114));
listCount++;
break;
case 3:
jLabel32.setBackground(new Color(240,240,240));
jLabel33.setBackground(new Color(241,114,114));
listCount++;
break;
case 4:
jLabel33.setBackground(new Color(240,240,240));
jLabel34.setBackground(new Color(241,114,114));
jLabel35.setBackground(new Color(241,114,114));
jLabel28.setVisible(true);
jLabel29.setVisible(true);
jLabel41.setVisible(true);
jLabel30.setVisible(true);
jLabel30.setText("NULL");
listCount++;
break;
case 5:
jLabel34.setBackground(new Color(240,240,240));
jLabel35.setBackground(new Color(240,240,240));
jLabel36.setBackground(new Color(241,114,114));
listCount++;
break;
case 6:
jLabel30.setText("12");
jLabel31.setVisible(true);
listCount++;
break;
case 7:
jLabel42.setVisible(true);
jLabel43.setVisible(true);
jLabel44.setVisible(true);
listCount++;
break;
case 8:
jLabel45.setVisible(true);
jLabel46.setVisible(true);
listCount++;
break;
case 9:
jLabel36.setBackground(new Color(240,240,240));
jLabel37.setBackground(new Color(241,114,114));
listCount++;
break;
case 10:
jLabel30.setText("");
jLabel31.setText("");
listCount++;
break;
case 11:
jLabel30.setText("21");
jLabel31.setText("NEXT");
jLabel43.setText("NULL");
jLabel44.setVisible(false);
jLabel45.setVisible(false);
jLabel46.setVisible(false);
listCount++;
break;
case 12:
jLabel37.setBackground(new Color(240,240,240));
jLabel38.setBackground(new Color(241,114,114));
listCount++;
break;
case 13:
jLabel38.setBackground(new Color(240,240,240));
listCount=1;
timer.stop();
break;
default: System.out.println("Invalid");break;
}
Create an Interface. Something like:
interface PropertyChanger
public void changeProperty();
}Then implement the interface for each property. Something like:
public class VisiblePropertyChanger
private JComponent compoennt;
private boolean visibility;
public VisiblePropertyChanger(JComponent component, boolean visibility)
this.component = component;
this. visibility = visibility;
public void changeProperty()
component.setVisible( visibility );
}Now your Timer will need an ArrayList of ArrayLists to store all the property changes:
ArrayList main = new ArrayList();
Add property changes information to an array list for each interval
ArrayList interval1 = new ArrayList();
interval1.add( new VisiblePropertyChanger(label32, true) );
interval1.add( new VisiblePropertyChanger(label33. true) );
main.add(interval1);
ArrayList interval2 = new ArrayList();
interval2.add( new BackgroundPropertyChanger(label32, new Color(...)) );
main.add(interval2);
...Now the code in the actionPerformed would need to be change to get the "interval" array list from the main. Then you iterate through each PropertyChanger and invoke the changeProperty() method.
Similar Messages
-
More elegant solution for error "Current version of data in database..."
When two users try to manipulate the same record in a form, one of them gets the "Current version of data in database has changed since user initiated update process." when updating.
I'd like a more elegant solution (or prevention) of this situation by disabling the update button on the form of the second user who opens the record and display a message on the page that the record is currently opened by another user, so it is only available in "read-only mode" by the other user.
How can I do something like this? Or what are the multi user policies that other apex developers on the forum use and how are they implemented?I don't think I would disable anything, as you need to consider the situation where someone opens a record, then goes to lunch.
You might update 2 columns such as "last_opened_on" and "last_opened_by" for the row. Then when the 2nd person opens it you could display a prominent indicator (red+bold) if it was opened by someone else in the last 10 min, as well as showing who opened it last. If it hasn't been opened in over 8 hours, you could basically de-emphasize that indicator by making it light gray or something. The goal is not to lock or disable anything, but warn a user when they open a record that was recently opened. If logistically possible, this gives them the opportunity to call / IM each other to coordinate.
Tyler Muth
http://tylermuth.wordpress.com
[Applied Oracle Security: Developing Secure Database and Middleware Environments|http://sn.im/aos.book] -
More elegant solution to reporting query?
I was recently asked to produce a one-time report that would identify any products that were or are currently being sold/stocked out of two different locations (821,822) at once, and where the product is currently is in stock at both. The table layout is basically like this:
Sales_Staging
Location_ID
Product_ID
Sales_Current
Sales_1ago
Sales_2ago
Sales_72ago
On_Hand_Current
On_Hand_1ago
On_Hand_62ago
(sales/OH stored horizontally on table, shifted once a week)
I wanted to produce a report of the products selling out of the two location IDs (821,822)--a list ordered by product, showing the historical sales/inventory at each location side-by-side. For example:
Location Product Sales_Current Sales_1ago ... On_Hand_Current ...
821 ABC 0 1 3
822 ABC 0 1 4
821 DEF
822 DEFTo get results turned around quickly, I used this ugly SQL below. The Sales_Staging table has millions of records, and the query plodded. I feel like I'm asking Oracle to process the same data for each location twice.
I'm working in 10gR2. For my own education and future reference, I figured I'd see if the experts had a more elegant solution? Thanks in advance.
SELECT location_id, product_id, sales..., on_hand...
FROM Sales_Staging
WHERE location_id = 821
AND on_hand_current > 0
AND (sales_current + sales_1ago + sales_2ago + ... + on_hand_1ago + ...) > 0
AND product_id in
(SELECT product_id
FROM Sales_Staging
WHERE location_id = 822
AND on_hand_current > 0
AND (sales_current + sales_1ago + sales_2ago + ... + on_hand_1ago + ...) > 0)
UNION
SELECT location_id, product_id, sales..., on_hand...
FROM Sales_Staging
WHERE location_id = 822
AND on_hand_current > 0
AND (sales_current + sales_1ago + sales_2ago + ... + on_hand_1ago + ...) > 0
AND product_id in
(SELECT product_id
FROM Sales_Staging
WHERE location_id = 821
AND on_hand_current > 0
AND (sales_current + sales_1ago + sales_2ago + ... + on_hand_1ago + ...) > 0)
ORDER BY product_id, location_idThe below query is obviously untested, but at least it shows a different approach to this problem
with subset_of_sales_staging as
( select *
from sales_staging
where location_id in (821,822)
and on_hand_current > 0
and ( sales_current + ... ) > 0
select distinct s1.*
from subset_of_sales_staging s1
, subset_of_sales_staging s2
where s1.product_id = s2.product_id
and ( s1.location_id = 821 and s2.location_id = 822
or s1.location_id = 822 and s2.locatino_id = 821
order by product_id
, location_idChances are good that this query will operate on smaller subsets than your original query. But this depends of course on the data volumes and distributions, which I don't know.
Regards,
Rob. -
IPod touch - more elegant way to sync to a new library?
I recently had to change the motherboard in my machine, and took the opportunity to upgrade the machine and put on a fresh install of the OS. I had expected my iPod touch to work like every other device I've had and just sync with a new install of iTunes (ie pull everything off the device and onto the host machine and be up and running without further action required), but unfortunately it gives me an error saying:
This iPod "..." is synced with another iTunes library. Do you want to erase this iPod and sync with this iTunes library?
When I click cancel it lets me do most of what I'd like, but unfortunately it won't let me do a firmware update (from 4.3.4 to 5.1.1) as it says that:
There are purchased items on the iPod "..." that have not been transferred to your iTunes library...
I have done a backup of the device successfully, so I'm guessing that I can say yes to the 'erase the iPod' prompt and then just restore it when complete, but before I do that I want to be 100% sure that this process will back everything on the device up (ie after the process will the device function identically to what it is doing now). Unfortunately the backup process just completes without providing any details, so I have no way to verify that and would appreciate more detail on this front (or if it will restore the link to the old iTunes library as well, at which point I will have just wasted my time)? As such, I havn't been confident enough in this process to go about risking the erasure.
The other thing I am wondering is whether the syncrhonization process and/or backup functionality store system level settings as well or just the data? For instance, entering my WPA2 key was a royal PITA when I first got the device as the UI isn't really well designed to handle long, cryptic encryption keys (no way to show the characters as you enter it (ie can't double check it before clicking okay), no way to paste it from an email, etc.) and I don't particularly want to go through that process again.
Ideally, I'd like to find a more elegant way around this (ie I'd really like to avoid having to wipe the device) as this is kind of a ridiculous process to have to go through for such a simple task. If it helps, I still have all of the old files (the new OS and iTunes were installed on a new HDD, so the old iTunes folder/data is still on the old HDD (can't boot to it on the new hardware, but Ican access the raw files)) so if there is some way to convince iTunes to just load up those files and be done with it I'd be very appreciative.You need to:
Transfer iTunes purchases by:
http://support.apple.com/kb/HT1848?viewlocale=en_USiTunes Store: Transferring purchases from your iOS device or iPod to a computer
- Transfer othre music by using a third-party program like one of those discussed here:
Copy music
- To retain app data and other information, connect the iPod to yur computer and make a backup by right clciking on the iPod under Devices in iTunes and select Back Up
- Restore the iPod from that backup
Note that the Backup that iTunes makes does not include synced media like apps and music. -
More than one Solution Manager
Hi,
We have 3 data centres around the world and each have a number of SAP systems, ABAP, JAVA and ABAP+Java. At present we have one central Solution Manager that is configured primarily for ASAP, change management etc and not really configured for CEN or RCA.
So my question is, has anyone setup more than one Solution Manager when they have multiple data centres around the world or is everyone just using a central Solution Manager?
Any advise would be greatly appreciated.
Regards
BrianThank you for your reply. Our Central Solution Manager is already 4p/8c with 20Gb on Windows Server 2003 and when we connect all our SAP instances, some 120 of them then the Solman basically stops. So I am curious, very eager to find out if anyone has setup more than one Solman to handle large numbers of SAP instances and handle geographic separation of SAP instances.
But thanks for your reply.
Brian -
Searching for a more elegant way to write my where clause.
Hi,
I have a table T which has two columns : X(Varchar2(100)), and Y(Varchar2(100)).I want to know all the rows in the table T for which two conditions are simultaneously true: the first condition is X is not null or Y is not null, and the second condition is not(X is not null and Y is not null). So I write my query like below:
select *
from T
where (X is not null or Y is not null) and not(X is not null and Y is not null)But the way I formulate my where clause doesn't seem elegant to me. Please, could I obtain the same result with a more elegant where clause?
Thanks.<font face="courier">
where (X is not null or Y is not null) and <font color="red">not(X is not null and Y is not null)</font><br>
<font color="red">De Morgan</font><br>
where ((X is not null) or (Y is not null)) and (<font color="red">not(X is not null) or not(Y is not null)</font>)<br><br>
where ((X is not null) or (Y is not null)) and (<b>not(X is not null)</b> or <b>not(Y is not null)</b>)<br>
<b>double negation</b><br>
where ((X is not null) or (Y is not null)) and (<b>(X is null)</b> or <b>(Y is null)</b>)<br><br>
where (<font color="green">(X is not null) <b>or</b> (Y is not null)</font>) <font color="blue"><b>and</b> ((X is null) or (Y is null))</font><br>
Distributivity of <font color="blue"><b>and</b></font> over <font color="green"><b>or</b></font><br>
where (<font color="green">(X is not null)</font> <font color="blue"><b>and</b> ((X is null) or (Y is null))</font>) <font color="green"><b>or</b></font> (<font color="green">(Y is not null)</font> <font color="blue"><b>and</b> ((X is null) or (Y is null))</font>)<br><br>
where (<font color="red">(X is not null) <b>and</b></font> <font color="magenta">((X is null) <b>or</b> (Y is null))</font>) or (<b>(Y is not null) and ((X is null) or (Y is null))</b>)<br>
Distributivity of <font color="red"><b>and</b></font> over <font color="magenta"><b>or</b></font> applied to the <b>second term</b> too<br>
where ((<font color="red">(X is not null) <b>and</b></font> <font color="magenta">(X is null)</font>) <font color="magenta"><b>or</b></font> (<font color="red">(X is not null) <b>and</b></font> <font color="magenta">(Y is null)</font>)) or <br> ((<b>(Y is not null) and (X is null)</b>)<b> or </b>(<b>(Y is not null) and (Y is null)</b>))<br><br>
<font color="green"><b>Negation</b></font><br>
where ((<font color="green"><strike>(X is not null)</strike> <b>not(Y is null)</b></font> and (X is null)) or ((X is not null) and (Y is null))) or <br> (((Y is not null) and (X is null)) or (<font color="green"><strike>(Y is not null)</strike> <b>not(Y is null)</b>)</font> and (Y is null)))<br><br>
where ((<font color="blue">not(X is null) and (X is null)</font>) or ((X is not null) and (Y is null))) or <br> (((Y is not null) and (X is null)) or (<font color="blue">not(Y is null) and (Y is null)</font>))<br>
<font color="blue">Complementation</font><br>
where ((<font color="blue">false</font>) or ((X is not null) and (Y is null))) or <br> (((Y is not null) and (X is null)) or (<font color="blue">false</font>))<br><br>
<b>where ((X is not null) and (Y is null)) or ((Y is not null) and (X is null))</b><br><br>
preferring clarity (in the eye of beholder as always) over efficiency<br><br>
<b>where x || y in (x,y)</b><br><br>
Regards
Etbin
</font>
Edited by: Etbin on 28.8.2011 11:45
steps separated with empty lines, negation enhanced -
Make this query more elegant?
can anybody tell me how to make this subquery more elegant?
select 1 lfdidx from dual union
select 2 lfdidx from dual union
select 49 lfdidx from dual union
select 50 lfdidx from dual
Thanks in advanceSergey, thanks, that's what I hoped for.
http://www.sqlsnippets.com/en/topic-11821.html has some additional info concerning this.
Regards, Thomas -
Making code faster smaller and more elegant
hi just like yesterday I�m new to java. first of all I want to get familiar with the basics. I wrote a little game therefore. with some help. within the code are no mistakes, compiling errors or such. but now my question is why is my CPU usage nearly 75% when I run it. when the �h� ( Thread.sleep(h); ) is about 5 which makes the game faster but the CPU usage is 100%. Are there any possibilities to make the code faster? next question. are there any tricks to make the code more elegant or smaller? you know what I mean? it�s quite difficult for me to express what I want cause my English isn�t the best�
what ever here is the code
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class BricksGame extends JFrame implements MouseListener, MouseMotionListener{
private int mouseX, mouseY;
double a = -3;
int delta = 1;
int beta = -3;
int x_max = 288;
int y_max = 320;
int x_min = 0;
int y_min = 0;
int x = 5;
int y = 5;
int b = y_max;
int h = 15;
int y_block = 80;
int i;
int x_point;
int y_point =0;
int punkte = 0;
double k ;
double r;
int zahl = 1;
boolean changed = true;
boolean gameNotOver = true;
JPanel panelOben = new MyPanel();
JPanel panelUnten = new JPanel();
JLabel labelU1 = new JLabel();
JLabel labelU2 = new JLabel("Punktestand: 0");
JButton b1 = new JButton("restart");
public BricksGame(){
setSize(400,600);
setLocation(100,200);
Dimension full = getSize();
mouseX = full.width/2;
mouseY = full.height/2;
addMouseMotionListener(this);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
panelOben.setLayout(null);
//Ausrichtung der Elemente
panelOben.setBounds(50, 50, 400, 500);
panelUnten.addMouseMotionListener(this);
panelUnten.setLayout(null);
//Ausrichtung der Elemente
panelUnten.setSize(300, 100);
panelUnten.setBounds(50, 500, 300, 100);
labelU1.setBounds(100,380,130,25);
labelU2.setBounds(150,430,130,25);
b1.setBounds(150,500, 80, 30);
b1.addMouseListener(this);
ImageIcon ii2 = new ImageIcon(getClass().getResource("TW1.gif"));
labelU1.setIcon(ii2);
//Hinzuf�gen der Elemente
panelUnten.add(labelU1);
panelUnten.add(labelU2);
panelUnten.add(b1);
getContentPane().add(panelOben);
getContentPane().add(panelUnten);
setResizable(false);
(new Mover()).start();
setVisible(true);
validate();
public static void main (String[]args){
BricksGame object = new BricksGame();
public void mousePressed (MouseEvent e) {}
public void mouseReleased (MouseEvent e) {}
public void mouseClicked (MouseEvent e) {
restart();
public void mouseEntered (MouseEvent e) {}
public void mouseExited (MouseEvent e) {}
public void mouseDragged (MouseEvent e) { }
public void mouseMoved (MouseEvent e) {
mouseX = e.getX();
if (mouseX <= 85){
mouseX = 85;
}else if (mouseX >= 319){
mouseX = 319;
labelU1.setBounds(mouseX -35 ,380,70,25);
* @author Haferberger
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
class Mover extends Thread{
public void run(){
while (gameNotOver){
try {Thread.sleep(h);}
catch (Exception e) {
// TODO: handle exception
repaint();
* @author Haferberger
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
class MyPanel extends JPanel{
public void paint(Graphics g){
if (y <= y_min && !changed){
// System.out.println("up");
//wie oft oben gegen
i++;
//Koordinaten des G�nen Punktes
x_point =x_max -x;
y_point =0;
//Nach 5 mal oben gegen wird der Winkel ge�ndert
if (i%5==0){
zZahl();
alpha();
//Richtungs�nderung
a = -a;
b = (int)(y_min - a*x);
changed = true;
}else if (y >= y_max && !changed){
// System.out.println("down");
//Bei Ber�hrung unten wird der Block verschoben
if (y_block == 221){
beta = -beta;
}else if (y_block == 80){
beta = -beta;
y_block+= beta;
//Betimmen wo der Ball aufkommt
if (x + 5 >= mouseX - 84 && x + 5 <= mouseX -27 ){
// System.out.println("Mitte");
}else if(x + 5 >= mouseX - 95 && x + 5 <= mouseX -85 ){
// System.out.println("au�en links");
if(delta > 0){
delta = -delta;
a = -a;
b = (int)(y_min - a*x);
}else if(x + 5 <= mouseX -16 && x + 5 >= mouseX -26 ){
// System.out.println("au�en rechts");
if(delta < 0){
delta = -delta;
a = -a;
b =(int)(y_min - a*x);
}else{
System.out.println("daneben");
gameNotOver=false;
a = -a;
b = (int)(y_max - a*x);
changed = true;
}else if (x >= x_max && !changed){
// System.out.println("right");
a = -a;
b = (int)(y - a*x_max);
delta = -delta;
changed = true;
}else if (x <= x_min && !changed){
// System.out.println("left");
a = -a;
b = (int)(y - a*x_min);
delta = -delta;
changed = true;
}else if (y == y_block && x>72 && x<216 && !changed){
// System.out.println("Balken unten");
a = -a;
b = (int)(y - a*x);
changed = true;
}else if (y == y_block+20 && x>72 && x<216 && !changed){
// System.out.println("Balken oben");
a = -a;
b = (int)(y - a*x);
changed = true;
}else{
changed = false;
g.setColor(Color.cyan);
g.fillRect(0, 0, 300, 330);
x+= delta;
y = (int)(a*x + b);
g.setColor(Color.red);
g.fillOval(x,y+5,10,10);
g.setColor(Color.magenta);
g.fillRect(72, y_block,144,20);
y_point+=2;
if(y_point==310){
y_point=500;
if(x_point + 5 >= mouseX - 94 && x_point + 5 <= mouseX -20 ){
punkte+=50;
g.setColor(Color.green);
g.fillOval(x_point,y_point,20,20);
labelU2.setText("Punktestand: " + punkte);
labelU2.validate();
public void zZahl(){
r = (Math.random() * 10);
zahl = (int)r%5 + 1;
public void alpha(){
switch(zahl){
case 4:
if (a<0){
a=-1;
}else if (a>0){
a=1;
if (delta<0){
delta=-4;
}else if (delta>0){
delta=4;
break;
case 3:
if (a<0){
a=-2;
}else if(a>0){
a=2;
if (delta<0){
delta=-4;
}else if(delta>0){
delta=4;
break;
case 5:
if (a<0){
a=-3;
}else if (a>0){
a=3;
if (delta<0){
delta=-1;
}else if (delta>0){
delta=1;
break;
case 2:
if (a<0){
a=-0.5;
}else if (a>0){
a=0.5;
if (delta<0){
delta=-4;
}else if (delta>0){
delta=4;
break;
case 1:
if (a<0){
a=-0.2;
}else if (a>0){
a=0.2;
if (delta<0){
delta=-5;
}else if (delta>0){
delta=5;
break;
public void restart(){
gameNotOver=true;
y_block=80;
beta = -3;
x=mouseX;
(new Mover()).start();
punkte = 0;
labelU2.validate();
}thanksFirst of all, big friendly advice: split your code into few classes and methods. Currently your code looks very ugly.
And one simple question: what is happening with Mover instance after restart? I don't see anything that stops old Mover thread instance before starting a new one...
And so on...
It is much simpler to answer your question when code is splited in small parts - problems then are located in small pieces of code. -
More elegant implementation?
Here is some working code: Two dice are drawn on the screen; new values are shown whenever the user clicks on the panel.
Is there a cleaner way to implement this? Any redundant code? I believe this is the most straightforward implementation, but it would be another, possibly useful exercise to make it more elegant (whence more confusing?)
/* File TwoDicePanel.java */
import javax.swing.*;
import java.awt.*;
import java.awt.Graphics;
import java.awt.event.*;
import java.lang.Math;
public class TwoDicePanel extends JPanel implements MouseListener {
private int value;
public TwoDicePanel() {
addMouseListener(this);
public void paintComponent(Graphics g) {
// Assign initial values.
value = (int)(Math.random()*6+1);
drawDie(g, value, 10, 10);
value = (int)(Math.random()*6+1);
drawDie(g, value, 10 + 60 + 10, 10 + 60 + 10);
g.dispose();
public void mousePressed(MouseEvent evt) { };
public void mouseReleased(MouseEvent evt) { };
public void mouseClicked(MouseEvent evt) {
Graphics g = getGraphics();
// First die.
value = (int)(Math.random()*6+1);
drawDie(g, value, 10, 10);
// Second die.
value = (int)(Math.random()*6+1);
drawDie(g, value, 10 + 60 + 10, 10 + 60 + 10);
g.dispose();
public void mouseEntered(MouseEvent evt) { };
public void mouseExited(MouseEvent evt) { };
/** Draws a six-sided die.
* Precondition : `val' is in range; `x' and `y' lie within the
* panel.
* Postcondition: One face showing the value rolled is drawn.
* @param g Graphics context.
* @param val A natural number in the range [1, 6].
* @param x Abscissa for dice anchor point referred to the panel's coordinate system.
* @param y Ordinate for dice anchor point referred to the panel's coordinate system.
void drawDie(Graphics g, int val, int x, int y) {
// Dice are 60 pixels on a side;
// indentations are black and have a 10-pixel diameter.
g.setColor(Color.WHITE);
g.fillRect(x, y, 60, 60);
// Apply a blue border.
g.setColor(Color.BLUE);
g.drawRect(x - 1, y - 1, 62, 62);
g.setColor(Color.BLACK);
// Translate the indentations as a group up and left along
// the downward diagonal of the face. This centers the image.
x -= 5;
y -= 5;
switch( val ) {
case 1:
g.fillOval(x + 60/2, y + 60/2, 10, 10);
break;
case 2:
g.fillOval(x + 60/4, y + 60/4, 10, 10);
g.fillOval(x + 3*60/4, y + 3*60/4, 10, 10);
break;
case 3:
g.fillOval(x + 60/4, y + 60/4, 10, 10);
g.fillOval(x + 60/2, y + 60/2, 10, 10);
g.fillOval(x + 3*60/4, y + 3*60/4, 10, 10);
break;
case 4:
g.fillOval(x + 60/4, y + 60/4, 10, 10);
g.fillOval(x + 3*60/4, y + 60/4, 10, 10);
g.fillOval(x + 60/4, y + 3*60/4, 10, 10);
g.fillOval(x + 3*60/4, y + 3*60/4, 10, 10);
break;
case 5:
g.fillOval(x + 60/4, y + 60/4, 10, 10);
g.fillOval(x + 60/2, y + 60/2, 10, 10);
g.fillOval(x + 3*60/4, y + 3*60/4, 10, 10);
g.fillOval(x + 60/4, y + 3*60/4, 10, 10);
g.fillOval(x + 3*60/4, y + 60/4, 10, 10);
break;
case 6:
g.fillOval(x + 60/4, y + 60/4, 10, 10);
g.fillOval(x + 60/2, y + 60/4, 10, 10);
g.fillOval(x + 3*60/4, y + 60/4, 10, 10);
g.fillOval(x + 60/4, y + 3*60/4, 10, 10);
g.fillOval(x + 60/2, y + 3*60/4, 10, 10);
g.fillOval(x + 3*60/4, y + 3*60/4, 10, 10);
} // End switch
} // End drawDie()
} // End class TwoDicePanel
/* File TwoDice.java */
import javax.swing.JFrame;
public class TwoDice {
public static void main(String[] args) {
JFrame window = new JFrame("Dice Roller");
TwoDicePanel content = new TwoDicePanel();
window.setContentPane(content);
window.setLocation(100, 100);
window.setSize(180, 180);
window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
window.setVisible(true);
} // End main()
} // End class TwoDiceMore
Trouble with an anonymous class.
The goal is to roll the dice with a button now (which is the only source in the program). I'm running into problems with this block:
<identifier> expected
rollButton.addActionListener( new ActionListener() {
^in
rollButton.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Rolls the dice when "Roll" button is
// clicked.
Graphics g = getGraphics();
// First die.
value1 = (int)(Math.random()*6+1);
drawDie(g, value1, 10, 10);
// Second die.
value2 = (int)(Math.random()*6+1);
drawDie(g, value2, 10 + 60 + 10, 10 + 60 + 10);
g.dispose();
} ); -
Just playing about with Java 5.0. Running a large loop, so I wanted to show a progress cursor. I came up with the following:
private static char[] progress = { '-', '\\', '|', '/' };
int p = 0;
while (true) {
// do something
System.out.printf("%c\b", progress[p]);
p = (++p % progress.length);
}Any more elegant suggestions? Cheers, NeilOh, sorry Neil. I think this is a nice CL cursor:
:LEKKDj. .,itjji
:LEGGGGft: .::,,iWEGGGDKWGDDLji;tEL
.ED: :;jDEDGGGGLE#DGGGGDGE#i ;#i
t#, . GWGGGKWK#WWKDf;itjfWf
fK. EKGGGKWWKGGGGE#KEDDKWt
t#Li iKEDDDK#EGGGGD#WEGGGEK.
:KK, :jffjitKKEEKW#KWGGGWG
LK: ,tG#DDDGGEW#,
t#; iDKKKEf;EG
DD .:. i#,
:KL. ijG#Dfjf
jfjfKKfj: iEG: ;DD, ..;#i
tW, L#W, .. j##i .tD#Lt;:
,jfK#L, .EDGK, iWj.::.
fKtti ;jji tEWKi.
.ifGDWf, .tEEi;jLj.
.fi. :jGDGji,: .,ijGDf;
.ifKWD##WKKGLLLLLLLGGDEEWWE#Wf;.
;GEGGtLWKGGGKEjjjjfffGWEGGDWKjjDDKL,
,GDfEGjL#KGDDGGEKKDGGEKWDGGDGGWKjjGGfEL.
,Kj ;D#KGKftEDGGGDDDDGGGKLtGEGW#L, .GE.
fD GWGGKfjDDGGGGGGGGGGKGtDEGD#t ,Wt
iKt. ;#DGGGGDGGGGGGGGGGGGGGDGGGGKE. :LK:
,fGLLKWGGGGGGGGGGGGGGGGGGGGGGGGGD#ELGGt.
EKGGGGGGGGGGGGGGGGGGGGGGGGGG#f
E#KKKKKKKKKKKKWKKKKKKKKKKKKW#f
DG.:,,,,,,,;;;DL;;;,,,,,,::,Wf
jK: Gt i#;
.GEi: .;KD, .,jKj
,jLGGGGGGGGLijGGGGGGGGGLj: -
I currently have a select that performs the equivalent query on my sample below. Given only the ID, is there a more elegant method of obtaining the same result set?
Thanks!
ID AREA
10 1
11 1
12 1
20 2
21 2
22 2
select id where area in (
select area from table
where id = 10
output
10
11
12SQL> create table mytable (id,area)
2 as
3 select 10, 1 from dual union all
4 select 11, 1 from dual union all
5 select 12, 1 from dual union all
6 select 20, 2 from dual union all
7 select 21, 2 from dual union all
8 select 22, 2 from dual
9 /
Tabel is aangemaakt.
SQL> exec dbms_stats.gather_table_stats(user,'mytable')
PL/SQL-procedure is geslaagd.
SQL> set serveroutput off
SQL> var target_id number
SQL> exec :target_id := 10
PL/SQL-procedure is geslaagd.
SQL> select /*+ gather_plan_statistics */ id
2 from mytable
3 where area in
4 ( select area
5 from mytable
6 where id = :target_id
7 )
8 /
ID
12
11
10
3 rijen zijn geselecteerd.
SQL> select * from table(dbms_xplan.display_cursor(null,null,'iostats last'))
2 /
PLAN_TABLE_OUTPUT
SQL_ID 9dfysw8h43f2t, child number 0
select /*+ gather_plan_statistics */ id from mytable where area in
( select area from mytable where id =
:target_id )
Plan hash value: 725385859
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
| 0 | SELECT STATEMENT | | 1 | | 3 |00:00:00.01 | 7 |
|* 1 | HASH JOIN SEMI | | 1 | 6 | 3 |00:00:00.01 | 7 |
| 2 | TABLE ACCESS FULL| MYTABLE | 1 | 6 | 6 |00:00:00.01 | 3 |
|* 3 | TABLE ACCESS FULL| MYTABLE | 1 | 1 | 1 |00:00:00.01 | 4 |
Predicate Information (identified by operation id):
1 - access("AREA"="AREA")
3 - filter("ID"=:TARGET_ID)
23 rijen zijn geselecteerd.
SQL> SELECT /*+ gather_plan_statistics */ dst.id
2 FROM mytable dst
3 JOIN mytable src ON dst.area = src.area
4 WHERE src.id = :target_id
5 /
ID
10
11
12
3 rijen zijn geselecteerd.
SQL> select * from table(dbms_xplan.display_cursor(null,null,'iostats last'))
2 /
PLAN_TABLE_OUTPUT
SQL_ID 26z8j9udwf1yk, child number 0
SELECT /*+ gather_plan_statistics */ dst.id FROM mytable dst JOIN
mytable src ON dst.area = src.area WHERE src.id = :target_id
Plan hash value: 2666611345
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
| 0 | SELECT STATEMENT | | 1 | | 3 |00:00:00.01 | 7 |
|* 1 | HASH JOIN | | 1 | 3 | 3 |00:00:00.01 | 7 |
|* 2 | TABLE ACCESS FULL| MYTABLE | 1 | 1 | 1 |00:00:00.01 | 3 |
| 3 | TABLE ACCESS FULL| MYTABLE | 1 | 6 | 6 |00:00:00.01 | 4 |
Predicate Information (identified by operation id):
1 - access("DST"."AREA"="SRC"."AREA")
2 - filter("SRC"."ID"=:TARGET_ID)
22 rijen zijn geselecteerd.
SQL> SELECT /*+ gather_plan_statistics */ ID
2 FROM mytable a
3 WHERE EXISTS (SELECT 1
4 FROM mytable b
5 WHERE b.ID = :target_id AND a.area = b.area)
6 /
ID
12
11
10
3 rijen zijn geselecteerd.
SQL> select * from table(dbms_xplan.display_cursor(null,null,'iostats last'))
2 /
PLAN_TABLE_OUTPUT
SQL_ID 6hf6nyqa6az6q, child number 0
SELECT /*+ gather_plan_statistics */ ID FROM mytable a WHERE EXISTS
(SELECT 1 FROM mytable b WHERE b.ID =
:target_id AND a.area = b.area)
Plan hash value: 725385859
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
| 0 | SELECT STATEMENT | | 1 | | 3 |00:00:00.01 | 7 |
|* 1 | HASH JOIN SEMI | | 1 | 6 | 3 |00:00:00.01 | 7 |
| 2 | TABLE ACCESS FULL| MYTABLE | 1 | 6 | 6 |00:00:00.01 | 3 |
|* 3 | TABLE ACCESS FULL| MYTABLE | 1 | 1 | 1 |00:00:00.01 | 4 |
Predicate Information (identified by operation id):
1 - access("A"."AREA"="B"."AREA")
3 - filter("B"."ID"=:TARGET_ID)
23 rijen zijn geselecteerd.
SQL> select /*+ gather_plan_statistics */ id
2 from ( select id
3 , min(decode(id,:target_id,id,:target_id+1)) over (partition by area) min_id
4 from mytable
5 )
6 where min_id = :target_id
7 /
ID
10
11
12
3 rijen zijn geselecteerd.
SQL> select * from table(dbms_xplan.display_cursor(null,null,'iostats last'))
2 /
PLAN_TABLE_OUTPUT
SQL_ID 6yn18nkw72hg8, child number 0
select /*+ gather_plan_statistics */ id from ( select id
, min(decode(id,:target_id,id,:target_id+1)) over (partition by area)
min_id from mytable ) where min_id = :target_id
Plan hash value: 229100860
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
| 0 | SELECT STATEMENT | | 1 | | 3 |00:00:00.01 | 3 |
|* 1 | VIEW | | 1 | 6 | 3 |00:00:00.01 | 3 |
| 2 | WINDOW SORT | | 1 | 6 | 6 |00:00:00.01 | 3 |
| 3 | TABLE ACCESS FULL| MYTABLE | 1 | 6 | 6 |00:00:00.01 | 3 |
Predicate Information (identified by operation id):
1 - filter("MIN_ID"=:TARGET_ID)
22 rijen zijn geselecteerd.Regards,
Rob. -
Comment to "How do I get a memo onto my iPhone?" -- more elegant solution
Since I can't post a reply or comment to my archived post, I thought this might be an alternative.
Even though Tamara had a solution, software now available for the Mac and iPhone gives a more general solution.
iPhone Explorer lets you use an iPhone or iPod touch as a USB or pen drive. You can create, delete, and rename files and folders, and use drag-and-drop. OS X 10.5 or later. From www.iphone-explorer.com (myPodApps) It's free.
Good Reader is one solution to read those files and many others (like e-books and PDFs) on your iPhone. It's in the app store. Normally $4.99, was on sale (may still be) for $0.99.
I've started to use both. I have no financial interest in either product.
Hope this helps someone else.
harv47Well that's Cool.
Here's what usually pixxes me off.
Apple promotes a app, and they never tested it.
Some tried almost made it out the window at 90.
So, I think this is commendable that an app that's needed and tested at the same time deserves an automatic star magnet for the fridge.
Unless you can't fine the door handle anymore.
Cheers -
Using more than one Solution Manager for different usages
Dear all,
we are using a solution manager system with >100 connected systems.
The system should primarily be used as service desk system, but is also used for BC issues (e.g. MOPZ,...) at the moment.
We have to implement a central monitoring system (CEN) using the CCMS infrastructure.
It is recommended to use a seperate system for this issue, because of high performance requirement and the requirement to have the newest support packages for CEN+MOPZ.
Because of that recommendation we are thinking about installation of a second solution manager system which should handle all BC and Monitoring (CEN+SolutionManager-Monitoring) issues.
Do you have any experience with such a landscape? Are there known problems respectively is such a landscape possible/workable? How should the systems be connected? ( client system<=>solman / solman<=>solman )
I regret that I could not find any official landscape recommendations from SAP for big landscapes (VAR environment)?
If you know any applicable documents, please let me know.
Thank you for your help.
Best regards,
SaschaHi Sascha
Technically Solution Manager is being billed as the Central system for everything Service Desk, MOPZ and CCMS - one central location for all scenarios
One of the reasons for this is lifecycle management -- monitoring or EWA scenario finds a problem, service desk raises the issue, charm or mopz implements the solution and it is tested and distributed and the whole lifecycle is documented one system. Indeed I am aware of no functionality to integrate scenarios between Solution Manager systems - each Solution Manager system in your proposal will be standalone for each scenario
I can't provide guarantees because SAP recommend 1 Solman PRD only, but it might be possible to use another PRD Solution Manager system (or client) for scenarios that not already setup in the existing Solution Manager system - this certainly is the most possible way to have 2 PRD Solution Manager systems (or clients) running in parallel.
The key thing to be aware of is RFC conflicts - as each scenario usually has its own RFC this might be avoided - however
do watch out for situations where scenarios share RFCs or you if find RFCs existing with the same name OR client and SID in any systems in the following landscape
Landscape 1 - Satellite System 1 to Solman System 1 Service Desk, MOPZ
Landscape 2 - Satellite System 1 to Solman System 2 CCMS, EWA
Best wishes
Stuart -
More than one solution active ?
Hello Everyone,
I have some enhancements to Opportunity, Accounts and Activity. These enhancements are part of different solutions. That is, Opportunity Extensions are part of one solution, Accounts extensions are part of another and activity in another. When I log-in to the UI, I only see extensions related the last activated solution all other extensions from other solutions are not visible. Can only one solution be active at a time or is there a way I can make all enhancements made in all solutions visible.
Regards,
SrikanthHello Srikantha,
Please have a look at this discussion: http://scn.sap.com/thread/3581543
It explains a little bit how and why.
HTH,
Horst -
Update 7.3.1 causing more problems than solutions?
I'm not sure what the new update was meant to do but once I updated to 7.3.1, my transfer rate lowered drastically
I used to have 4-6 MB/s originally before the update
But on the same day, once I updated it and nothing else changed, it lowered to less than 1 MB/s
Can someone tell me what's so great about the update and if I could downgrade this machine?Change your wireless channel, 9 or 3 are usually good. What kind of internet do you have, you may need it in bridged mode. Your issue is issolated to your network if you had two of them with issues because mine works fine and so do about 990,000 more. Hard reset the base station, use WPA2 encryption, channel 9, and disable both SNMP and configuration over WAN. All of these settings can be easily found within Manual setup if you play around a little... or just call AppleCare, the mac genious's are there to help to. See if it has the same problem in a different environment, I'd bet it has something to do with your settings, possibly a double nat.
Maybe you are looking for
-
if you have a large document and you add two returns at the end of every major section or group but one of the two returns goes to next page, how do you keep that return so it doesn't mess up spacing if something is added earlier in document but get
-
IMovie will only import short videos from my camera.
Hello, I recently bought a Sony CyberShot DSC-HX50 camera. I filled one 8 GB memory card and have half-filled a 16 GB card (I was overseas and couldn't download photos to my MacBook Pro, which was at home). I have the most recent version of iMovi
-
March 2013: I updated US Maps - it shows wrong tow...
I had the Nokia USA maps installed in my C6-01. It showd a lot of update and it finished with an error. Then I realized that there is no US maps on my smartphone. So installed it again via PC. Now it shows wrong town name but correct ZIP code What
-
What is the difference between logical and physical standby databases? Is standby database and data guard is same ?
-
Forte 6 update 2: Compile errors
When I tried to recompile (using Forte C++ update 2) a project that was built fine under Workshop 4.2, Here are some of the errors that I received: Making CList.o... cc -g -Xc -I/usr/dt/include -I/usr/openwin/include -c CList.c "./XmI.h", line 113: (