Skinning combobox rectBorder class... only!
preface: I have experience skinning components.
Issue: trying to change the rectBorder class ONLY on the
combobox instances. no others. can anyone help me with this? I've
changed the rectBorder for entire documents before, but have never
been able to target it to one type of component.
any guidance, links or heckling is appreciated!
Setting of contentBackgroundAlpha for the combobox worked.
Similar Messages
-
Why wait and notify kept in object class only
why wait and notify kept in object class only. is it maintain locks while doing wait and notify . please explain internals,
What do you mean in Object class "only"? If they're in Object, then they're in ALL classes.
They're in Object because any Object can serve as a lock.
For details of how to use them, see a Java threading tutorial such as http://java.sun.com/docs/books/tutorial/essential/threads/ -
Why is the Executable class only available in Script Task and not in Script Component.
Why is the Executable class only available in Script Task and not in Script Component.
Here is a link to the Executable class documentation.
http://technet.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.executable.aspx
Mr ShawBecause Executables are available only in Control Flow. Script Task is a control flow component whreas Script Component is a data flow component. It works on data buffer and rows and not on executables.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Skinned ComboBox has no custom skin if exported on frame other than 1
I have skinned the combo box (mainly the up/down arrows) - it
all works if I export classes on the first frame, but I need to do
it on some other frame for progressive downloading.
I have checked the linkage of everything related to this, I
think, and they all have "export in first frame" unchecked, and I
set my global settings "export frame for classes = 2", and then the
combo box component is in the third frame or later, but it doesn't
work...
Example:
ComboBox Assets MovieClip is set to "export in first frame"
Global is set to "export frame for classes = 1"
ComboBox component is in frame 3.
It works.
ComboBox Assets MovieClip is set to "export in first frame"
unchecked
Global is set to "export frame for classes = 2"
ComboBox component is in frame 3.
No skins...
Any ideas? Thanks.Since no one was able to help with this, both here and at
some other Flash forums, I thought I would post the answer, in case
it can help someone else. After fooling around with this for
multiple hours, I found somewhat of a solution.
The assets for the custom-skinned combo box look like this in
my library:
ComboBoxAssets (folder)
....ComboBoxAssets (MovieClip)
....Elements (folder)
........ComboArrow (graphic)
........ComboShape2 (graphic)
........ComboGrad1 (graphic)
........ComboShape1 (graphic)
........ComboThemeColor (MovieClip)
........ComboThemeColor1 (MovieClip)
....States (folder)
........ComboDownArrowOver (MovieClip)
........ComboDownArrowDown (MovieClip)
........ComboDownArrowUp (MovieClip)
........ComboDownArrowDisabled (MovieClip)
The ComboBoxAssets MovieClip contains all of the other stuff,
basically - all 4 of the states from the States folder are inside
it.
I found, that in order to make this work (for exporting on
some other frame but 1), the only way I can get it to work so far,
is this:
1. ComboBox (component) -> uncheck "Export in first frame"
2. ComboBoxAssets (MovieClip)- > uncheck "Export in first
frame"
3. ComboDownArrowOver (MovieClip) ->
CHECK "Export in first frame"
4. ComboDownArrowDown (MovieClip) ->
CHECK "Export in first frame"
5. ComboDownArrowUp (MovieClip) ->
CHECK "Export in first frame"
6. ComboDownArrowDisabled (MovieClip) ->
CHECK "Export in first frame"
The 6 pieces in the Elements folder all have nothing checked.
This makes no sense to me, but as soon as you uncheck "Export
in first frame" on any one of 3,4,5,6 above (which are nested
MovieClips inside ComboBoxAsset), then that part of the custom skin
will not appear in the compiled movie. The main Assets clip must
export in some other frame, but the other nested clips of it must
be set to export in the first frame.
I don't know if this is a bug, or a feature, or what...
One of the weird things is, that even when set like the
above, there is indeed nothing in the first frame according to the
Bandwidth Profiler (like you want). Weird. Anyway, that's how I got
it to work. -
gooday all
i am try skinning the Combobox component
follows the Help file, dragged the
MMDefault>>ComboBoxAssets folder to my fla
however when i compile, it tells me below :
The class or interface 'ComboBase' could not be loaded.
any idea??
thankyouSetting of contentBackgroundAlpha for the combobox worked.
-
My class only compiles in Java 1.6 and not in Java 1.5
Hi, my java class wont compile in java 1.5, it only compiles in Java 1.6. How can i compile the following?
import java.util.*;
public class ShoppingBasket
Vector products;
public ShoppingBasket() { products = new Vector(); }
public void addProduct(Product product)
boolean flag = false;
for(Enumeration e = getProducts(); e.hasMoreElements();)
{ Product item = (Product)e.nextElement();
if(item.getId().equals(product.id))
{flag = true; item.quantity++; break; }
if(!flag){ products.addElement(product);}
public void deleteProduct(String str)
for(Enumeration e=getProducts();
e.hasMoreElements();)
{ Product item = (Product)e.nextElement();
if(item.getId().equals(str))
{products.removeElement(item); break; }
public void emptyBasket(){products = new Vector();}
public int getProductNumber(){ return products.size();}
public Enumeration getProducts() { return products.elements(); }
public double getTotal()
Enumeration e = getProducts();
double total; Product item;
for(total=0.0D;e.hasMoreElements(); total+= item.getTotal())
{item = (Product)e.nextElement(); }
return total;
}It should link with a class called Product which compiles fine... the errors i get are below:
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:6: cannot find symbol
symbol : class Product
location: class ShoppingBasket
public void addProduct(Product product)
^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:10: cannot find symbol
symbol : class Product
location: class ShoppingBasket
{ Product item = (Product)e.nextElement();
^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:10: cannot find symbol
symbol : class Product
location: class ShoppingBasket
{ Product item = (Product)e.nextElement();
^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:20: cannot find symbol
symbol : class Product
location: class ShoppingBasket
{ Product item = (Product)e.nextElement();
^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:20: cannot find symbol
symbol : class Product
location: class ShoppingBasket
{ Product item = (Product)e.nextElement();
^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:35: cannot find symbol
symbol : class Product
location: class ShoppingBasket
double total; Product item;
^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:36: inconvertible types
found : <nulltype>
required: double
for(total=0.0D;e.hasMoreElements(); total+= item.getTotal())
^
K:\jakarta-tomcat-5.0.18\webapps\ROOT\WEB-INF\classes\ShoppingBasket\ShoppingBas
ket.java:37: cannot find symbol
symbol : class Product
location: class ShoppingBasket
{item = (Product)e.nextElement(); }
^
8 errorsfahafiz wrote:
ah, so should i put the classes into the folder which the classpath is assigned to?More likely you should assign your classpath to whatever folder your classes are in.
Put your files where they make sense, and then fill in classpath accordingly:
javac -classpath classpath MyFile.java(I think, it's been a while since I compiled from the command-line, see http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html) -
12 classes, only need 1 at a time, array?how? HELP!
Below i have made up the months of the year but as you can see the gridlayout changes for each one which is why i made them up like so.
I want to make up an array to hold them and only call them when needed.
The problem is that if i do that my code will be to long, is their a way of croping them down as 12 methods plus extra decades :-(
I have thought of making up extra java files to hold each 12 months but i not sure how to call them in, I think i use import mar.*;
To be truthfull i'm a bit losed
public void mar(){
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(6,7));
for(int x=0;x<5;x++){
JLabel blank = new JLabel("");
days.add(blank);
int i =1;
for(int x =0; x < 31; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.addActionListener(this);
days.add(nextButton);
++i;
for(int x=0;x<6;x++){
JLabel blank = new JLabel("");
days.add(blank);
control2panel.add(days);
getContentPane().add(control2panel,"Center");
pack();
public void apr(){
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(5,7));
for(int x=0;x<1;x++){
JLabel blank = new JLabel("");
days.add(blank);
int i =1;
for (int x =0; x < 30; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.addActionListener(this);
days.add(nextButton);
++i;
control2panel.add(days);
getContentPane().add(control2panel,"Center");
pack();
}Thanks for the help vanangrani, your info is ok.
This is a small bit of the code that i'm working on, have a look at the month methods. I have embedded one for show you how it should look but its static, I need to make up a method to load one month method only when selected from the menuItem.
He's the code anyway.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test2 extends JFrame implements ActionListener{
String[] months ={"January","February","March","April","May","June",
"July","August","September","October","November","December"};
String[] years ={"02","03","04","05","06","07","08","09","2010"};
JLabel text, monthlabel;
JMenu menu, menu2;
JMenuBar menuBar = new JMenuBar();
JMenuItem menuItem;
int monthIndex = 0;
public static void main(String[] args){
try {
UIManager.setLookAndFeel(
UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) { }
try {
UIManager.put("Button.select", Color.blue);
} catch (Exception e) {
e.printStackTrace();
Test2 test = new Test2();
test.init();
public void init(){
// Create the menu bar.
menuBar = new JMenuBar();
setJMenuBar(menuBar);
// First menu in the menu bar for Editing.
menu = new JMenu("select a year");
menu.setMnemonic(KeyEvent.VK_Y);
menuBar.add(menu);
// Group of Editing tools in JMenuItems
int y = 0;
for(int x = 0; x < 9 ; x++){
menuItem = new JMenuItem(years[y]);
menuItem.addActionListener(this);
menu.add(menuItem);
++y;
// Second menu for months.
menu2 = new JMenu("Months of the Year");
menu2.setMnemonic(KeyEvent.VK_M);
menuBar.add(menu2);
// Group of months in JMenuItems
int m = 0;
for(int x = 0; x < 12 ; x++){
menuItem = new JMenuItem(months[m]);
menuItem.addActionListener(this);
menu2.add(menuItem);
++m;
JPanel controlpanel = new JPanel();
controlpanel.setLayout(new GridLayout(2,1,1,1));
JPanel month = new JPanel();
month.setLayout(new GridLayout(2,1));
monthlabel = new JLabel(months[monthIndex], JLabel.CENTER);
month.add(monthlabel);
getContentPane().add(menuBar,"North");
getContentPane().add(month,"Center");
/********* below is the static method ***********/
jan();
pack();
JPanel weekdays = new JPanel();
weekdays.setLayout(new GridLayout(1,7));
weekdays.add(new JLabel("Sun", JLabel.CENTER));
weekdays.add(new JLabel("Mon", JLabel.CENTER));
weekdays.add(new JLabel("Tue", JLabel.CENTER));
weekdays.add(new JLabel("Wed", JLabel.CENTER));
weekdays.add(new JLabel("Thu", JLabel.CENTER));
weekdays.add(new JLabel("Fri", JLabel.CENTER));
weekdays.add(new JLabel("Sat", JLabel.CENTER));
controlpanel.add(weekdays);
getContentPane().add(controlpanel,"North");
pack();
show();
public void actionPerformed(ActionEvent e) {
Toolkit.getDefaultToolkit().beep();
String actionstring = e.getActionCommand();
for (int i = 0;i<12;i++){
if (actionstring.compareToIgnoreCase(months) == 0){
JOptionPane.showMessageDialog(this,"You selected "
+ e.getActionCommand() + " 2002"); // this works
monthlabel.setText(months[i]);
/* 12 methods for the months of the year */
public void jan(){
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(5,7));
for(int x=0;x<2;x++){
JLabel blank = new JLabel("");
days.add(blank);
int i =1;
for(int x =0; x < 31; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.setForeground(Color.red);
nextButton.addActionListener(this);
days.add(nextButton);
++i;
control2panel.add(days);
getContentPane().add(control2panel,"Center");
pack();
public void feb(){
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(5,7));
for(int x=0;x<5;x++){
JLabel blank = new JLabel("");
days.add(blank);
int i =1;
for (int x =0; x < 28; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.addActionListener(this);
days.add(nextButton);
++i;
control2panel.add(days);
getContentPane().add(control2panel,"Center");
pack();
public void mar(){ // must add extra
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(6,7));
for(int x=0;x<5;x++){
JLabel blank = new JLabel("");
days.add(blank);
int i =1;
for(int x =0; x < 31; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.addActionListener(this);
days.add(nextButton);
++i;
for(int x=0;x<6;x++){
JLabel blank = new JLabel("");
days.add(blank);
control2panel.add(days);
getContentPane().add(control2panel,"Center");
pack();
public void apr(){
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(5,7));
for(int x=0;x<1;x++){
JLabel blank = new JLabel("");
days.add(blank);
int i =1;
for (int x =0; x < 30; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.addActionListener(this);
days.add(nextButton);
++i;
control2panel.add(days);
getContentPane().add(control2panel,"Center");
pack();
public void may(){
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(5,7));
for(int x=0;x<3;x++){
JLabel blank = new JLabel("");
days.add(blank);
int i =1;
for (int x =0; x < 31; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.addActionListener(this);
days.add(nextButton);
++i;
control2panel.add(days);
getContentPane().add(control2panel,"Center");
pack();
public void jun(){
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(6,7));
for(int x=0;x<6;x++){
JLabel blank = new JLabel("");
days.add(blank);
int i =1;
for (int x =0; x < 30; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.addActionListener(this);
days.add(nextButton);
++i;
for(int x=0;x<6;x++){
JLabel blank = new JLabel("");
days.add(blank);
control2panel.add(days);
getContentPane().add(control2panel,"Center");
public void jul(){
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(5,7));
for(int x=0;x<1;x++){
JLabel blank = new JLabel("");
days.add(blank);
int i =1;
for (int x =0; x < 31; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.addActionListener(this);
days.add(nextButton);
++i;
control2panel.add(days);
getContentPane().add(control2panel,"Center");
pack();
public void aug(){
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(5,7));
for(int x=0;x<4;x++){
JLabel blank = new JLabel("");
days.add(blank);
int i =1;
for (int x =0; x < 31; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.addActionListener(this);
days.add(nextButton);
++i;
control2panel.add(days);
getContentPane().add(control2panel,"Center");
pack();
public void sep(){
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(5,7));
int i =1;
for (int x =0; x < 30; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.addActionListener(this);
days.add(nextButton);
++i;
for(int x=0;x<5;x++){
JLabel blank = new JLabel("");
days.add(blank);
control2panel.add(days);
getContentPane().add(control2panel,"Center");
pack();
public void oct(){
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(5,7));
for(int x=0;x<2;x++){
JLabel blank = new JLabel("");
days.add(blank);
int i =1;
for (int x =0; x < 31; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.addActionListener(this);
days.add(nextButton);
++i;
control2panel.add(days);
getContentPane().add(control2panel,"Center");
pack();
public void nov(){
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(5,7));
int i =1;
for (int x =0; x < 30; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.addActionListener(this);
days.add(nextButton);
++i;
control2panel.add(days);
getContentPane().add(control2panel,"Center");
pack();
public void dec(){
JPanel control2panel = new JPanel();
JPanel days =new JPanel();
days.setLayout(new GridLayout(5,7));
int i =1;
for (int x =0; x < 31; x++){
JButton nextButton = new JButton(String.valueOf(i));
nextButton.addActionListener(this);
days.add(nextButton);
++i;
for(int x=0;x<4;x++){
JLabel blank = new JLabel("");
days.add(blank);
control2panel.add(days);
getContentPane().add(control2panel,"Center");
pack(); -
Spark skinning - combobox transparent background issue
Hi,
I have a custom combobox component whose background is transparent when it is in a titlewindow , but looks opaque in a cell of a datagrid. The code for background for combobox is
<!--- Defines the appearance of drop-down list's background fill. -->
<s:Rect id="background" left="1" right="1" top="1" bottom="1" >
<s:fill>
<!---@private
The color of the drop down's background fill.
The default color is 0xFFFFFF.
-->
<s:SolidColor id="bgFill" color="0xFFFFFF"/>
</s:fill>
</s:Rect>
The code for background fill of titlewindow is
<!-- layer 2: background fill -->
<!--- Defines the appearance of the TitleWindowSkin class's background. -->
<s:Rect id="background" left="1" top="1" right="1" bottom="1">
<s:fill>
<!--- Defines the TitleWindowSkin class's background fill. The default color is 0xFFFFFF. -->
<s:SolidColor id="backgroundFill" color="#FFFFFF"/>
</s:fill>
</s:Rect>
Though setting the alpha to 1 in either code did not work. Please help.Setting of contentBackgroundAlpha for the combobox worked.
-
Help skinning ComboBox and Button......
Hi
I've been skinning some components and am having trouble
changing the colours of the button in media playback component and
the white and grey border round the listbox (i've included a
closeup of this in the image to illustrate and highlighted the
problems in red).
Any help would be much appreciated as i am going mad.
Thanks
http://img.photobucket.com/albums/v337/Hampco01/player-test.gif
I've tried creating a new theme and looked at the as files in
the classes folder but nothing i change seems to work.
HELP!Anyone with ideas?
-
ER: ADF Faces Skins: "Unknown pseudo class:alias"
Hi,
I'm trying to create an ADF Faces Skin, by overriding aliases in my own CSS file.
The code editor, however, is hilighting the word "alias" every time I use it (as in ".AFDarkBackground:alias") in red, and the error "Unknown pseudo class:alias" appears both on a popup and in the Structure Pane under "CSS Errors." Is Can I ignore this, or am I doing something wrong? Do I need to import some base CSS that defines the pseudo class? The sample from the HowTo doesn't seem to, but then it shows up with the same CSS Errors.
Best,
Avrom
Message was edited by:
[email protected]
Changed topic title to reflect request for enhancement farther down.Thanks!
I think I'll edit the title of this to contain ER: ... it would be very nice if it were possible to turn off this bit of validation. I can imagine varying degrees of "smartness" for such a feature--from a manual "accept simple desktop pseudoclasses" option to automatically checking to see if the CSS is listed in an adf-faces-skins.xml file or is imported by any CSS files that are. -
How to load Class only once...
hi all,
i am using the Class.forName() to load the class.
the code looks like as follows :
for loop.....{
Class.forName("classA");
inside the for loop , is there any possiblity of knowing that the class is already loaded or not. i can load the class the outside the for loop . but i am curious to know how we can check whether the classA is already loaded or not for the next iteration of the loop.
tia,
dhanasekaran.Class.forName() will only load a class that has not been previously loaded. Whether or not a class is already loaded is totally transparent to a Java application. It will be loaded as soon as it is referred to for the first time, be it instantiation or access to static members or a call to Class.forName().
-
Swapping pointers on classes, only one works..
I have a mostly functional program now, that draws a class essentially.. Now I have an array of class shapes which is size 10 that is supposed to shuffle and draw all, but I only get the newest one shapes[0] to draw. Here's the relevant code, and much thanks to anyone who helps me here.
drawShapes is called by my Panel class which will for resons unbenowest to me draw only the first indice (shapes[0]) no matter how many shapes I draw... I tried putting in long coding instead of loops (e.g.
shapes[1]=shapes[0];but I still only got my newest shape to draw..
Heres relevant material
public void drawShapes(Graphics g)
sortShapes();
drawAllShapes(g);
public void sortShapes()//supposed to order shapes
for(int t=8; t>=0; t--)
shapes[t+1]=shapes[t];
shapes[0]=newshape;
public void drawAllShapes(Graphics g)//calls predefined draw method
for(int i=9; i>=0; i--)
shapes.drawShape(g);I think I added something to only draw once, but now it throws a null pointer exception for probably some stupid reason I don't know. Changes are only really made in classes except Prog4 part except to add panelListener to my Data class.
Summarized....
1. Data has reference to panelListener
2. PanelListener sets a local boolean to true when mouse is clicked twice.
3.Data accesses it, and sets a local boolean to it. If this boolean is true then it sorts the shapes, and sets the local bool to false, and the one in panelListener to false.
4.Gets null exception error for unknown reason.
error is this (new code follows)
5. Sorry to have so much to go through, and thanks for the help so far.
java.lang.NullPointerException
at MyPanel.paintComponent(Prog4.java:497)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JLayeredPane.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
at java.awt.Container.paint(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Prog4 extends JApplet implements ActionListener
//private MainPanel drawingpanel;
private JPanel top;
private JPanel left;
private JPanel bottom;
private JPanel bottomleft,bottommiddletop,bottommiddle,bottomright;
//top buttons created
private JButton first,next,previous,last,help;
//bottom buttons created
private JButton custom;
private JButton white,gray,red,purple,blue,green,yellow,orange;
private JButton black,darkgray,darkred,darkpurple,darkblue,darkgreen,darkyellow,darkorange;
private JButton rect,oval,line,solid,hollow,erase;
private CardLayout drawingscreens;
private MyShape [] shapes=new MyShape[10];
private MyShape newshape=new MyShape();
private Data information;//=new Data(newshape, shapes);
private MyPanel temp;//=new MyPanel(information);
private int thiscard;
public int x,y;
//Holder Variable to hold info about shape to be drawn
int [] colors=new int[3];
int shape;
int fill;
int draw;
int tx,ty,bx,by;
public void init()
Container window=getContentPane();
window.setLayout(new FlowLayout(0,0,FlowLayout.LEFT));
//Top Button Setup
first=new JButton("First");
first.addActionListener(this);
first.setPreferredSize(new Dimension(100,40));
next=new JButton("Next");
next.addActionListener(this);
next.setPreferredSize(new Dimension(100,40));
previous=new JButton("Previous");
previous.addActionListener(this);
previous.setPreferredSize(new Dimension(100,40));
last=new JButton("Last");
last.addActionListener(this);
last.setPreferredSize(new Dimension(100,40));
help=new JButton("Help");
help.addActionListener(this);
help.setPreferredSize(new Dimension(100,40));
//TOP PANEL SETUP
top=new JPanel();
top.setLayout(new FlowLayout(0,0,FlowLayout.LEFT));
top.setPreferredSize(new Dimension(800,40));
top.setOpaque(true);
top.setBackground(Color.white);
top.add(first);
top.add(next);
top.add(previous);
top.add(last);
top.add(help);
window.add(top);
//Left Buttons Setup
rect=new JButton("Rectangle");
rect.setPreferredSize(new Dimension(100,40));
rect.addActionListener(this);
oval=new JButton("Oval");
oval.setPreferredSize(new Dimension(100,40));
oval.addActionListener(this);
line=new JButton("Line");
line.setPreferredSize(new Dimension(100,40));
line.addActionListener(this);
solid=new JButton("Solid");
solid.setPreferredSize(new Dimension(100,40));
solid.addActionListener(this);
hollow=new JButton("Hollow");
hollow.setPreferredSize(new Dimension(100,40));
hollow.addActionListener(this);
erase=new JButton("Erase");
erase.setPreferredSize(new Dimension(100,40));
erase.addActionListener(this);
//Left Panel Setup
left=new JPanel();
left.setLayout(new FlowLayout(0,0,FlowLayout.LEFT));
left.setPreferredSize(new Dimension(200,600));
left.add(rect);
left.add(oval);
left.add(line);
left.add(solid);
left.add(hollow);
left.add(erase);
window.add(left);// FlowLayout.LEFT);
//Middle Setup
temp=new panel();
temp.setPreferredSize(new Dimension(600,600));
temp.setOpaque(true);
temp.setBackground(Color.red);
temp.addMouseListener(this);
window.add(temp);
//Panel Listener Initailization
for(int i=0; i<shapes.length; i++)
shapes=new MyShape();
temp=new MyPanel(information);
Listener panelListener=new Listener(temp, newshape);//shapes
window.add(temp);
temp.addMouseListener(panelListener);
information=new Data(newshape, shapes, panelListener);
//Bottom Buttons Setup
int bsize=20; //Int for horz/vert size of buttons
//Left Setup, creates a JPanel which displays the current color
bottomleft=new JPanel();
bottomleft.setPreferredSize(new Dimension(2*bsize,2*bsize));
bottomleft.setLayout(new FlowLayout(0,0, FlowLayout.LEFT));
bottomleft.setOpaque(true);
//Middle Setup creates buttons for each pregenerated color in the top row
black=new JButton();
black.setPreferredSize(new Dimension(bsize,bsize));
black.setOpaque(true);
black.setBackground(new Color(0,0,0));
black.addActionListener(this);
darkgray=new JButton();
darkgray.setPreferredSize(new Dimension(bsize,bsize));
darkgray.setOpaque(true);
darkgray.setBackground(new Color(70,70,70));
darkgray.addActionListener(this);
darkred=new JButton();
darkred.setPreferredSize(new Dimension(bsize,bsize));
darkred.setOpaque(true);
darkred.setBackground(new Color(180,0,0));
darkred.addActionListener(this);
darkpurple=new JButton();
darkpurple.setPreferredSize(new Dimension(bsize,bsize));
darkpurple.setOpaque(true);
darkpurple.setBackground(new Color(185,0,185));
darkpurple.addActionListener(this);
darkblue=new JButton();
darkblue.setPreferredSize(new Dimension(bsize,bsize));
darkblue.setOpaque(true);
darkblue.setBackground(new Color(0,0,150));
darkblue.addActionListener(this);
darkgreen=new JButton();
darkgreen.setPreferredSize(new Dimension(bsize,bsize));
darkgreen.setOpaque(true);
darkgreen.setBackground(new Color(0,140,0));
darkgreen.addActionListener(this);
darkyellow=new JButton();
darkyellow.setPreferredSize(new Dimension(bsize,bsize));
darkyellow.setOpaque(true);
darkyellow.setBackground(new Color(176,176,0));
darkyellow.addActionListener(this);
darkorange=new JButton();
darkorange.setPreferredSize(new Dimension(bsize,bsize));
darkorange.setOpaque(true);
darkorange.setBackground(new Color(170,85,0));
darkorange.addActionListener(this);
//Adds each button to a Panel
bottommiddletop=new JPanel();
bottommiddletop.setLayout(new FlowLayout(0,0,FlowLayout.LEFT));
bottommiddletop.setPreferredSize(new Dimension(8*bsize,bsize));
bottommiddletop.add(black);
bottommiddletop.add(darkgray);
bottommiddletop.add(darkred);
bottommiddletop.add(darkpurple);
bottommiddletop.add(darkblue);
bottommiddletop.add(darkgreen);
bottommiddletop.add(darkyellow);
bottommiddletop.add(darkorange);
//Bottom Middle Creates bottom row of colors like top
white=new JButton();
white.setPreferredSize(new Dimension(bsize,bsize));
white.setOpaque(true);
white.setBackground(new Color(255,255,255));
white.addActionListener(this);
gray=new JButton();
gray.setPreferredSize(new Dimension(bsize,bsize));
gray.setOpaque(true);
gray.setBackground(new Color(192,192,192));
gray.addActionListener(this);
red=new JButton();
red.setPreferredSize(new Dimension(bsize,bsize));
red.setOpaque(true);
red.setBackground(new Color(255,0,0));
red.addActionListener(this);
purple=new JButton();
purple.setPreferredSize(new Dimension(bsize,bsize));
purple.setOpaque(true);
purple.setBackground(new Color(213,0,213));
purple.addActionListener(this);
blue=new JButton();
blue.setPreferredSize(new Dimension(bsize,bsize));
blue.setOpaque(true);
blue.setBackground(new Color(0,0,255));
blue.addActionListener(this);
green=new JButton();
green.setPreferredSize(new Dimension(bsize,bsize));
green.setOpaque(true);
green.setBackground(new Color(0,255,0));
green.addActionListener(this);
yellow=new JButton();
yellow.setPreferredSize(new Dimension(bsize,bsize));
yellow.setOpaque(true);
yellow.setBackground(new Color(255,255,0));
yellow.addActionListener(this);
orange=new JButton();
orange.setPreferredSize(new Dimension(bsize,bsize));
orange.setOpaque(true);
orange.setBackground(new Color(244,122,0));
orange.addActionListener(this);
//Attaches buttons to a panel
bottommiddle=new JPanel();
bottommiddle.setLayout(new FlowLayout(0,0,FlowLayout.LEFT));
bottommiddle.setPreferredSize(new Dimension(8*bsize,bsize));
bottommiddle.add(white);
bottommiddle.add(gray);
bottommiddle.add( red);
bottommiddle.add(purple);
bottommiddle.add(blue);
bottommiddle.add(green);
bottommiddle.add(yellow);
bottommiddle.add(orange);
//Creates middle panel for bottom
bottom=new JPanel();
bottom.setLayout(new FlowLayout(0,0,FlowLayout.LEFT));
bottom.setPreferredSize(new Dimension(8*bsize,2*bsize));
bottom.add(bottommiddletop);
bottom.add(bottommiddle);
//This is for a button on buttom right to make custom colors.
//Right Setup creates a button which allows you to make your own color
custom=new JButton("More");
custom.setPreferredSize(new Dimension(4*bsize,2*bsize));
custom.setOpaque(true);
bottomright=new JPanel();
bottomright.setLayout(new FlowLayout(0,0,FlowLayout.LEFT));
bottomright.setPreferredSize(new Dimension(4*bsize,2*bsize));
bottomright.add(custom);
//The Panel containing current color is added first
//Then the two colors panels are added
//Then the panel with a custom button is added
window.add(bottomleft);
window.add(bottom);
window.add(bottomright);
public void actionPerformed(ActionEvent e)
//Buttons to change colors
if(e.getSource()==black)
bottomleft.setBackground(new Color(0,0,0));
newshape.setColor(0,0,0);
if(e.getSource()==darkgray)
bottomleft.setBackground(new Color(70,70,70));
newshape.setColor(70,70,70);
if(e.getSource()==darkred)
bottomleft.setBackground(new Color(180,0,0));
newshape.setColor(180,0,0);
if(e.getSource()==darkpurple)
bottomleft.setBackground(new Color(185,0,185));
newshape.setColor(185,0,185);
if(e.getSource()==darkblue)
bottomleft.setBackground(new Color(0,0,150));
newshape.setColor(0,0,150);
if(e.getSource()==darkgreen)
bottomleft.setBackground(new Color(0,140,0));
newshape.setColor(0,140,0);
if(e.getSource()==darkyellow)
bottomleft.setBackground(new Color(176,176,0));
newshape.setColor(176,176,0);
if(e.getSource()==darkorange)
bottomleft.setBackground(new Color(170,85,0));
newshape.setColor(170,85,0);
if(e.getSource()==white)
bottomleft.setBackground(new Color(255,255,255));
newshape.setColor(255,255,255);
if(e.getSource()==blue)
bottomleft.setBackground(new Color(0,0,255));
newshape.setColor(0,0,255);
if(e.getSource()==red)
bottomleft.setBackground(new Color(255,0,0));
newshape.setColor(255,0,0);
if(e.getSource()==green)
bottomleft.setBackground(new Color(0,255,0));
newshape.setColor(0,255,0);
if(e.getSource()==purple)
bottomleft.setBackground(new Color(213,0,213));
newshape.setColor(213,0,213);
if(e.getSource()==yellow)
bottomleft.setBackground(new Color(255,255,0));
newshape.setColor(255,255,0);
if(e.getSource()==orange)
bottomleft.setBackground(new Color(244,122,0));
newshape.setColor(244,122,0);
if(e.getSource()==gray)
bottomleft.setBackground(new Color(192,192,192));
newshape.setColor(192,192,192);
//Code for setting shape to draw
if(e.getSource()==rect)
rect.setBackground(Color.blue);
newshape.setShape(1);
if(e.getSource()==line)
newshape.setShape(0);
line.setBackground(Color.blue);
if(e.getSource()==oval)
newshape.setShape(2);
oval.setBackground(Color.blue);
//Code for setting to fill or not
if(e.getSource()==solid)
solid.setBackground(Color.blue);
hollow.setBackground(Color.gray);
newshape.setFill(1);
if(e.getSource()==hollow)
hollow.setBackground(Color.blue);
solid.setBackground(Color.gray);
newshape.setFill(0);
public void setShapes()
rect.setBackground(Color.gray);
oval.setBackground(Color.gray);
line.setBackground(Color.gray);
class Data
private MyShape newshape;
private MyShape [] shapes;
private Listener panelListener;
private boolean dosort;
public Data(MyShape a, MyShape [] b, Listener c)
newshape=a;
shapes=b;
panelListener=c;
public void drawShapes(Graphics g)
sortShapes();
drawAllShapes(g);
public void sortShapes()
dosort=panelListener.sortonce();
if(dosort==true)
for(int t=8; t>=0; t--)
shapes[t+1]=shapes[t];
shapes[0]=newshape;
dosort=false;
panelListener.dontresort(dosort);
public void drawAllShapes(Graphics g)
for(int i=9; i>=0; i--)
shapes[i].drawShape(g);
class MyPanel extends JPanel
private int[] loc=new int[4];
//loc=panelListener.location();
private Data information;
public MyPanel(Data a)
information=a;
setPreferredSize(new Dimension(600,600));
setBackground(Color.blue);
public void paintComponent(Graphics g)
super.paintComponent(g);
g.drawString(loc[0]+" "+loc[1]+" "+loc[2]+" "+loc[3],200,200);
information.drawShapes(g);
public void setLoc(int [] l)
loc=l;
class Listener extends MouseAdapter
int x,y;
private int [] loc=new int[4];
int horzL, vertL;
private boolean clicked=false;
private boolean sortonce;
private MyPanel temp;
private MyShape newshape;
private int xt,yt,xl,yl;
public Listener(MyPanel d, MyShape b)
temp=d;
temp.setLoc(loc);
newshape=b;
public void mouseClicked(MouseEvent e)
if(clicked==false)
x=e.getX();
y=e.getY();
clicked=true;
else
if(clicked==true)
mouseloc(x,y,e.getX(),e.getY());
sortonce=true;
temp.repaint();
clicked=false;
newshape.doDraw(true);
public boolean sortonce()
return sortonce;
public void dontresort(boolean local)
sortonce=local;
public void mouseloc(int xt,int yt,int xl,int yl)
loc[0]=xt;
loc[1]=yt;
loc[2]=xl;
loc[3]=yl;
newshape.setLoc(xt,yt,xl,yl);
class MyShape
int xL, yL, xR, yR; //Local location ints for this class;
int red, blue, green; //Local ints defining this color;
int shape,fill; //Local info about shape
boolean draw=false; // Determines if Shape will draw
public void MyShape()
public void doDraw(boolean a)
draw=a;
public void setLoc(int xt,int yt,int xb,int yb)
xL=xt;
yL=yt;
xR=xb;
yR=yb;
public void setColor(int r,int b,int g)
red=r;
blue=b;
green=g;
public void setShape(int thisshape)
shape=thisshape;
public void setFill(int fil)
fill=fil;
public void drawShape(Graphics g)
if(draw==true)
g.setColor(new Color(red,blue,green));
switch(shape)
case 0: makeLine(g);break;
case 1: makeRect(g);break;
case 2: makeOval(g);break;
public void makeLine(Graphics g)
g.drawLine(xL,yL,xR,yR);
public void makeRect(Graphics g)
sortvalue();
if(fill==0)
g.drawRect(xL,yL,xR,yR);
else
g.fillRect(xL,yL,xR,yR);
public void makeOval(Graphics g)
sortvalue();
if(fill==0)
g.drawOval(xL,yL,xR,yR);
else
g.fillOval(xL,yL,xR,yR);
public void sortvalue()
if(xR<xL)
int temp=xR;
xR=xL;
xL=temp;
if(yR<yL)
int temp=yR;
yR=yL;
yL=temp;
yR=(yR-yL);
xR=(xR-xL); -
How do I create an instance of a class only known at runtime?
Hi, thanks for reading - my problem is this:
I am trying to build a program which searches through a folder and locates all *.class files present and forms an array of these classes. These classes will all be children of a parent class, template.class, so a common class interface will be involved.
I have done my background research and have been pointed in the general direction of the .lang package, the reflection package, beans and so forth but frankly I have not a clue. I'm not even sure what this kind of operation is called...
Thanks for your time.String classname = "Abc.class";
Class class = Class.forName(classname); // catch ClassNotFoundException
Object object = class.newInstance(); // catch InstantiationExceptiion
MyIntrface myInterface = (MyInterface)object; // catch ClassCastException -
Saving current Applet using AWT classes only
Hey Guys,
Can any one please help me out for saving current applet view using AWT and not SWING plese .
I tried this code pls check if there is any improvement.
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.lang.*;
import java.net.*;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.*;
import com.sun.image.codec.jpeg.*;
public class temp extends Applet implements ActionListener
Image myImg;
Button b1;
public void init()
myImg = getImage(getCodeBase(),"temp.jpg");
b1 = new Button("Save");
add(b1);
b1.addActionListener(this);
public void paint(Graphics g)
g.drawImage(myImg, 5, 10, this);
g.fillOval(10,10,20,20);
public void actionPerformed(ActionEvent ev)
BufferedImage bin = new BufferedImage( 200, 200,BufferedImage.TYPE_INT_RGB );
Graphics page = bin.getGraphics();
page.setColor( java.awt.Color.BLUE );
page.drawString( "BLUE", 100, 100 );
ImageIO.write( bin, "JPEG", new java.io.File( "Test7.jpeg" ) );
PLESE HELP ME SOOOONHi ,Thanx for your concern.
I am the same sayjava but I lost my password dats why the name is changed.
Now about the querry i have completely changed the coding and have successfully created a new JPEG image .
Can u please tell me how can I save it I have tried the following coding but it doent seem to work...
File file = new File("images", "imgOne.jpg");
FileOutputStream out = new FileOutputStream(file);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
param.setQuality(1.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(bi); //bi is the BufferedImage
Thanks Again. -
Does anyone know a good resource for Skinning Comboboxes? I know basic skining, and have been able to skin the text fields, and the 'openButton' for comboBox, however I am looking to do more.
Specifically, I want to skin the BG of the dropDown so it will look similiar to this: http://screencast.com/t/NzY5YjYx however, with the BG scaling properly.
Right now the BG is a MC i made in Flash (cs4) with 9 Slice enabled, and turned on. The skin that I currently have set on the box is as follows:
<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<!-- host component -->
<fx:Metadata>
[HostComponent("spark.components.ComboBox")]
</fx:Metadata>
<!-- states -->
<s:states>
<s:State name="open" />
<s:State name="disabled" />
<s:State name="normal" />
</s:states>
<!-- SkinParts
name=textInput, type=spark.components.TextInput, required=false
name=openButton, type=spark.components.supportClasses.ButtonBase, required=true
name=dropDown, type=flash.display.DisplayObject, required=false
name=scroller, type=spark.components.Scroller, required=false
name=dropIndicator, type=mx.core.IFactory, required=false
name=dataGroup, type=spark.components.DataGroup, required=false
-->
<s:PopUpAnchor id="popUp" displayPopUp.normal="false" displayPopUp.open="true" includeIn="open"
left="0" right="0" top="0" bottom="0" itemDestructionPolicy="auto"
popUpPosition="below" popUpWidthMatchesAnchorWidth="true">
<s:Group id="dropDown" maxHeight="184" minHeight="50" >
<!-- drop shadow -->
<!--- @private -->
<s:RectangularDropShadow id="dropShadow" blurX="20" blurY="20" alpha="0.45" distance="7"
angle="90" color="#FF0000" left="0" top="0" right="0" bottom="0"/>
<!-- border -->
<!--- @private -->
<s:Rect id="border" left="0" right="0" top="0" bottom="0">
<s:fill>
<s:SolidColor color="0xff0000" alpha="0"/>
</s:fill>
<s:stroke>
<!--- @private -->
<s:SolidColorStroke id="borderStroke" weight="1" alpha="0" />
</s:stroke>
</s:Rect>
<mx:Image source="@Embed('src/com/mindspark/SkinTest1/assets/testSwf.swf#box2')" id="background" height="{dropDown.height}" width="{dropDown.width}"/>
<!-- fill -->
<!--- Defines the appearance of drop-down list's background fill. -->
<s:Rect id="background2" left="1" right="1" top="1" bottom="1" >
<s:fill>
<!---
@private
The color of the drop down's background fill.
The default color is 0xFFFFFF.
-->
<s:SolidColor id="bgFill" color="0x000000" alpha="0"/>
</s:fill>
</s:Rect>
<!--- @private -->
<s:Scroller id="scroller" left="0" top="0" right="0" bottom="0" hasFocusableChildren="false" minViewportInset="1">
<!--- @copy spark.components.SkinnableDataContainer#dataGroup-->
<s:DataGroup id="dataGroup" itemRenderer="spark.skins.spark.DefaultItemRenderer">
<s:layout>
<s:VerticalLayout gap="0" horizontalAlign="contentJustify"/>
</s:layout>
</s:DataGroup>
</s:Scroller>
</s:Group>
</s:PopUpAnchor>
<s:TextInput id="textInput" text="DOOOGs" skinClass="com.mindspark.SkinTest1.view.skin.TextInputSkin" />
<!--- The default skin is ComboBoxButtonSkin.
@copy spark.components.supportClasses.DropDownListBase#openButton
@see spark.skins.spark.ComboBoxButtonSkin -->
<s:Button id="openButton" width="19" right="0" top="0" bottom="0" focusEnabled="false"
skinClass="com.mindspark.SkinTest1.view.skin.OpenButtonSkin" />
</s:Skin>
Any help to what i am doing wrong, or a point to a good resource would be really super. Thanks for the help.Hi,
If you set the constraints rather than width and height it should work
<mx:Image source="@Embed('src/com/mindspark/SkinTest1/assets/testSwf.swf#box2')" id="background"
top="1" left="1" bottom="1" right="1"/>
David.
Maybe you are looking for
-
Wi-Fi Printer says it is ONLINE. computer says it is OFFLINE.
HP Photosmart 110a. Have been using it for more then a year when it stopped responding to pring requests and I get an error message saying: Printer is OFFLINE. When I conduct a Wi-Fi directly on the printer, it says I am connected to kmy network an
-
recently i upgraded my iphone 3gs to IOS5. currently , after a week my iphone keep on crashing and restarting. Please help me.
-
Firstly Agent running and ready but 1 minutes later is not running
firat:/oracle/product/10.2.0.4/agent10g/bin > ./emctl status agent Oracle Enterprise Manager 10g Release 4 Grid Control 10.2.0.4.0. Copyright (c) 1996, 2007 Oracle Corporation. All rights reserved. Agent is Not Running firat:/oracle/product/10.2.0.4/
-
Convert these VIs ZLibInflate.vi,ZLibDeflate.vi of LabVIEW version 5.0 into LabVIEW 2009
-
A scenario to show VC functionality
Hi folks Can you please help me with some sample scenarios to built an application on Visual Composer to show the nice look-and-feel of the technology Thanks Mandeep Virk