fork download
  1.  
  2.  
  3. import java.awt.*;
  4.  
  5. import java.awt.event.*;
  6.  
  7.  
  8.  
  9.  
  10.  
  11. public class j1223_2 extends Frame{
  12.  
  13.  
  14.  
  15. j1223_2 frm;
  16.  
  17. Scrollbar scr1=new Scrollbar(Scrollbar.VERTICAL);;
  18.  
  19. Scrollbar scr2;
  20.  
  21. Scrollbar scr3;
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. void initial(){
  29.  
  30.  
  31.  
  32. frm=new j1223_2();
  33.  
  34.  
  35.  
  36. scr2=new Scrollbar(Scrollbar.HORIZONTAL);
  37.  
  38. scr3=new Scrollbar(Scrollbar.VERTICAL);
  39.  
  40. scr1.setValues(255,45,0,300);
  41.  
  42. scr2.setValues(255,45,0,300);
  43.  
  44. scr3.setValues(140,45,0,300);
  45.  
  46. br=new BorderLayout(5,5);
  47.  
  48. frm.setTitle("Display Color");
  49.  
  50. frm.setSize(200,150);
  51.  
  52. frm.setLayout(br);
  53.  
  54. frm.add(scr1,br.WEST);
  55.  
  56. frm.add(scr2,br.SOUTH);
  57.  
  58. frm.add(scr3,br.EAST);
  59.  
  60.  
  61.  
  62.  
  63.  
  64. scr1.addAdjustmentListener(new AdjustmentListener(){
  65.  
  66.  
  67.  
  68. public void adjustmentValueChanged(AdjustmentEvent e){
  69.  
  70.  
  71.  
  72. Graphics g=frm.getGraphics();
  73.  
  74. paint(g);
  75.  
  76.  
  77.  
  78. }
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92. });
  93.  
  94.  
  95.  
  96. scr2.addAdjustmentListener(new AdjustmentListener(){
  97.  
  98.  
  99.  
  100. public void adjustmentValueChanged(AdjustmentEvent e){
  101.  
  102.  
  103.  
  104. Graphics g=frm.getGraphics();
  105.  
  106. paint(g);
  107.  
  108.  
  109.  
  110. }
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124. });
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132. scr3.addAdjustmentListener(new AdjustmentListener(){
  133.  
  134.  
  135.  
  136. public void adjustmentValueChanged(AdjustmentEvent e){
  137.  
  138.  
  139.  
  140. Graphics g=frm.getGraphics();
  141.  
  142. paint(g);
  143.  
  144.  
  145.  
  146. }
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. });
  161.  
  162.  
  163.  
  164. frm.setVisible(true);
  165.  
  166.  
  167.  
  168.  
  169.  
  170. }
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178. public void paint(Graphics g){
  179.  
  180.  
  181.  
  182. int red=scr1.getValue();
  183.  
  184. int green=scr2.getValue();
  185.  
  186. int blue=scr3.getValue();
  187.  
  188. String str="Color("+red+","+green+","+blue+")";
  189.  
  190. g.setColor(new Color(red,green,blue));
  191.  
  192. g.fillRect(0,0,getWidth(),getHeight());
  193.  
  194. g.setColor(Color.BLACK);
  195.  
  196. g.drawString(str,45,80);
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204. }
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216. }
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226. class Test_2{
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234. public static void main(String [] args){
  235.  
  236.  
  237.  
  238. j1223_2 frame=new j1223_2();
  239.  
  240. frame.initial();
  241.  
  242.  
  243.  
  244.  
  245.  
  246. }
  247.  
  248.  
  249.  
  250.  
  251.  
  252. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:11: class j1223_2 is public, should be declared in a file named j1223_2.java
public class j1223_2 extends Frame{
       ^
1 error
stdout
Standard output is empty