|
Member 10449243 wrote: so please tell me about that source code about that main window in auto mobile spare part in java project
You do this in the following order
1 - Gather requirements, figure out what the 'main' window does.
2 - Learn basic java programming
3 - In general learn about web/internet server functionality how it works (presumably that is the goal)
4 - Learn the basics of implementing a web application in java
5 - Probably will need to learn about databases and how to access them in java
6 - Starting with 1, use what you learned in 2-5 to implement a java solution.
7 - Test it until there are no more bugs (or ones you can live with.)
|
|
|
|
|
tell me any advice about the mcs studies and how i can make my self good in developing
|
|
|
|
|
|
I'm not able to see content on JFrame ,when JFrame shows up.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class GraphicUse extends JPanel
{
public void PaintComponent(Graphics gr)
{
super.paintComponents(gr);
this.setBackground(Color.BLUE);
gr.setColor(Color.WHITE);
gr.fillRect(50, 50, 100, 100);
gr.setColor(new Color(139,38,190));
gr.fillRect(50, 70, 100, 100);
gr.setColor(Color.RED);
gr.drawString("This is a new String", 50, 90);
}
public static void main(String[] args)
{
}
}
And displaying it in another class which extends Frame
JFrame newframe = new JFrame("Color Frame");
newframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GraphicUse gu = new GraphicUse();
newframe.add(gu);
newframe.setSize(250,300);
newframe.setVisible(true);
|
|
|
|
|
Why does your main method not do anything?
Veni, vidi, abiit domum
|
|
|
|
|
I'm calling this class from another class so it is using that main class main method.
modified 5-Dec-13 6:26am.
|
|
|
|
|
Well you need to provide some more detail about your problem.
Veni, vidi, abiit domum
|
|
|
|
|
what other details you need?
|
|
|
|
|
No idea; but you need to provide enough to help people to understand the problem. Remember, we have never seen your code before so we cannot guess what each part is supposed to do or how it fits together. Having a blank main method in the code you showed above just serves to confuse.
Veni, vidi, abiit domum
|
|
|
|
|
Your frame is covered by a gray frame thats why paint method do not show anything.
|
|
|
|
|
Hello,
I have a code which checks some variable which has to be changed from false to true in other class, but, even if it changes it does not appears.
More details, I have the code:
ms.isDataReady = false;
...
while(!ms.isDataReady);
the loop while waits forever in my main method even if
ms.isDataReady becomes true in
ms 's appropriate method.
What I should do?
|
|
|
|
|
How can it change to true if the loop is running?
Veni, vidi, abiit domum
|
|
|
|
|
It changes somewhere else but it doesn't affects the change in while in other words it doesn't appears changed, unless I use a tricky solution so instead of
while(!ms.isDataReady);
I put
while(!ms.isDataReady) Thread.sleep(1);
|
|
|
|
|
Your while statement is not the best way to wait for something to happen, as it will just lock the processor, spinning on that statement.
Veni, vidi, abiit domum
|
|
|
|
|
What do you suggest instead ... ?
|
|
|
|
|
Well that depends on what you are trying to do. What is the interaction between these two threads and what is the first one waiting for?
Veni, vidi, abiit domum
|
|
|
|
|
Here are the details of the problem:
I have a class MISPSerial (instance named ms) which deals for stream of bytes to arrive via serial port. In my class which contains the main method I wait for the variable (ms.isDataReady) in MISPSerial which tells that the stream is received completely. So my main method waits for the stream to be received and then continues with instructions that follow. What would you suggest?
|
|
|
|
|
Run the class in the main thread; why do you need multiple threads when the main thread is always blocked on the other one?
Veni, vidi, abiit domum
|
|
|
|
|
Please Helping me to draw using Graphics2D libraries a shape that shape has a path which taken from .svg file, the points are: how to draw same shape by java and display it on awt JFrame
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<path
d="m 422.25764,974.44618
c 0.62138,-0.0746 1.75771,1.06129 2.36421,2.98433 0.0315,0.0766 -0.68474,0.41009 -0.71114,0.46361 -0.6326,1.05467 -1.52406,1.83533 -2.77441,2.6392 -0.43509,-0.91104 -0.52393,-1.70072 -0.74833,-2.34191 -0.22902,-0.63165 -0.396,-1.06757 -0.39844,-1.44283 0,-0.33371 0.0997,-0.64158 0.45974,-1.16655 0.51629,-0.74482 1.31804,-1.13113 1.80835,-1.13585 z
m -11.5102,6.90547 c 0.0229,-8e-4 0.0412,-8e-4 0.062,0 0.73295,0.0149 1.65189,1.1421 2.29485,2.45383 -2.29545,0.51575 -3.9309,-0.30763 -3.96949,-0.8076 0.0101,-0.58284 0.91061,-1.60082 1.61259,-1.64623 z
m 21.36555,2.05104 c -1.86343,2.56739 -4.27572,3.04759 -6.5439,2.34948 -1.50641,-0.48472 -2.57444,-1.53726 -3.19873,-3.11172 1.64954,-1.39373 3.61989,-3.29628 3.92443,-4.71392 0.52453,-2.48987 -0.16567,-4.46323 -1.63761,-6.00404 -0.35259,-0.35247 -1.30924,-0.43838 -1.6946,-0.48474 -0.1445,-0.0174 -0.28454,-0.0175 -0.4291,0 -1.01192,0.12268 -2.8825,1.24733 -3.3388,2.25388 -1.0821,2.29486 -0.3907,5.39846 0.61719,7.66014 -1.49231,0.82723 -3.54904,1.68049 -5.07543,2.12491 -0.42938,-1.40319 -0.40783,-3.34993 -1.59908,-4.79196 -1.10233,-1.27046 -4.03902,-0.91215 -4.83829,0.13925 -1.84471,2.44015 -0.42587,6.12024 0.18454,7.0005 1.10044,1.43715 3.56705,1.14657 5.36503,0.77653 -4.24788,9.44304 -8.82131,9.07212 -14.99561,7.87582 -0.66344,-0.11985 -4.40582,1.34024 -3.93038,1.63229 3.08618,1.61186 10.21392,1.93 13.59247,0.27118 3.11258,-1.52841 6.11964,-5.0517 6.82676,-10.28314 2.23997,-0.70968 3.61646,-1.4293 5.34317,-2.34788 0.96569,2.59279 1.77306,4.25088 4.20863,5.00135 3.22983,0.93748 6.13624,-0.68258 7.55088,-2.89928 0.49523,-0.75937 0.68396,-0.86212 1.10163,-0.14973 1.57462,3.09971 6.01007,4.16902 9.97479,2.19814 3.53094,1.26362 6.0483,-0.0626 7.92272,-1.72344 0.66597,0.9248 3.51732,2.03386 4.25958,1.90197 0.77891,-0.16324 1.25413,-1.39941 2.0732,-3.05771 1.99421,0.92835 5.26838,1.89896 5.93368,1.59911 1.85777,-0.8827 1.14978,-5.75424 0.93422,-7.61268 -0.41355,-3.48893 -1.64863,-8.65527 -2.31934,-13.0189 0.39135,-0.51705 0.75416,-2.32899 0.96414,-2.88175 0.17001,-0.73891 -1.48785,-0.52761 -1.8962,-2.01039 -0.0315,-0.10994 -0.10857,-0.17231 -0.19636,-0.17573
l -10e-5,6.8e-4
c -0.0877,-8.8e-4 -0.18678,0.053 -0.25997,0.17921 -0.35245,0.71415 -1.04154,1.7466 -1.22807,2.32933 -0.0546,0.15679 -0.038,0.26225 0.0253,0.40466 0.23266,0.49058 0.82733,1.44531 1.05249,1.93305 0.92658,5.88179 2.59257,14.07191 2.92942,16.8167 -0.55397,1.43149 -3.90406,0.16127 -4.93765,-0.19112 0.75112,-2.27612 -0.58221,-2.57166 -0.83417,-2.04915 -0.43621,0.98873 -0.47361,3.44977 -1.3941,4.58227 -0.11381,0.13924 -0.1691,0.16479 -0.32704,0.13609 -0.90655,-0.16515 -2.64734,-0.57452 -3.38522,-1.02327 0.31022,-0.58754 0.95892,-1.83649 1.02784,-2.6788 0.02,-0.86167 -1.32769,-0.59889 -1.54538,-0.0499 -1.15034,3.2856 -3.5553,4.6267 -6.91502,4.71419 1.14692,-1.54038 1.40236,-2.68829 1.54054,-4.17257 0.0651,-0.76121 -1.31386,-0.69932 -1.54602,-0.0283 -1.08257,2.53934 -1.55895,3.4161 -4.00178,3.9282 -2.2239,0.41552 -4.55677,0.0724 -6.91153,-2.45669 -0.97599,-1.17409 -1.67598,-0.77109 -2.37317,0.10785 z"
/>
</svg>
Thanks
Mohammad Ahmed
|
|
|
|
|
|
Thanks for that..
I really want to know how can i use relative path in Java Graphics2D, the curveTo method in GeneralPath class in Java Graphics2D works for absolute path only..
Helping Please
Thanks
|
|
|
|
|
ابو عبدالله wrote: Graphics2D works for absolute path only As do most graphics packages. You need to calculate the absolute points from the relative ones.
Veni, vidi, abiit domum
|
|
|
|
|
How to calculate those points ?
|
|
|
|
|
what do you mean? It's just a matter of adding numbers together, based on your starting point.
Veni, vidi, abiit domum
|
|
|
|
|
Thanks, i solved that problem of relative and absolute points, now i want to know how to put them in array to read them all at once instead of substitute each curve individually the code is :
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.util.*;
import javax.swing.*;
public class Dal extends Frame {
public static void main(String[] a){
(new Dal()).setVisible(true);
GeneralPath g=new GeneralPath();
}
Dal(){
super("Test");
setSize(500, 500);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
@SuppressWarnings("unused")
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
GeneralPath path=new GeneralPath();
path.moveTo(457.61616,470.82943 );
path.curveTo(458.41016,425.70843 ,427.74316,392.55343 ,403.93516,370.91243 );
path.curveTo(399.48516,366.83843 ,398.54916,368.02743 ,397.41516,372.27043 );
path.curveTo(394.75116,382.25643 ,392.96616,392.69543 ,391.09516,402.03043 );
path.curveTo(390.35916,405.62343 ,389.79116,406.92443 ,392.62616,409.52743 );
path.curveTo(406.00316,421.83343 ,442.19716,458.07143 ,444.89016,482.76843 );
path.curveTo(431.76716,528.31343 ,393.39116,574.56743 ,350.22516,594.56743 );
path.curveTo(316.63916,610.12643 ,278.88716,614.34043 ,242.18316,610.35243 );
path.curveTo(232.12112,609.27843 ,228.38012,619.29143 ,238.47016,621.92243 );
path.curveTo(274.01216,631.28543 ,320.32416,637.73643 ,356.57416,628.91043 );
path.curveTo(420.03416,613.46343 ,456.48216,533.71643 ,457.61616,470.82943);
path.closePath();
g2d.draw(path);
g2d.fill(path);
}
}
|
|
|
|
|