subclass

Custom NSButtonCell, drawBezelWithFrame not called

断了今生、忘了曾经 提交于 2019-12-23 02:17:29
问题 I'm trying to figure out how to custom draw Buttons in Cocoa/OSX. Since my view is custom drawn I will not use IB and want to do it all in code. I created a subclass of NSButtonCell and a subclass of NSButton. In the Subclass of NSButtonCell I override the Method drawBezelWithFrame:inView: and in the initWithFrame Method of my subclassed NSButton I use setCell to set my CustomCell in the Button. However, drawBezelWithFrame gets not called and I don't understand why. Can someone point out what

How to serialize ArrayList of objects?

别等时光非礼了梦想. 提交于 2019-12-22 19:42:48
问题 I want to serialize an arraylist of Item but it doesn't work.... my Item class extends Stuff class and has some subclasses . all of my classes implement Serilalizable. i have this part : try{ // Serialize data object to a file ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("MyData.ser")); out.writeObject(myData); out.close(); // Serialize data object to a byte array ByteArrayOutputStream bos = new ByteArrayOutputStream() ; out = new ObjectOutputStream(bos) ; out

How to serialize ArrayList of objects?

时光毁灭记忆、已成空白 提交于 2019-12-22 19:42:28
问题 I want to serialize an arraylist of Item but it doesn't work.... my Item class extends Stuff class and has some subclasses . all of my classes implement Serilalizable. i have this part : try{ // Serialize data object to a file ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("MyData.ser")); out.writeObject(myData); out.close(); // Serialize data object to a byte array ByteArrayOutputStream bos = new ByteArrayOutputStream() ; out = new ObjectOutputStream(bos) ; out

How to cast subclass object to superclass object

别说谁变了你拦得住时间么 提交于 2019-12-22 12:53:49
问题 i have 2 classes, called superclass and subclass, i tried to cast the subclass object to superclass, but its seems does not work when i want to use the subclass object from the superclass. Please help to explain. Thanks. These are the code:- public class superclass { public void displaySuper() } System.out.println("Display Superclass"); } } public class subclass extends superclass { public void displaySub() { System.out.println("Display Subclass"); } } public class Testing { public static

Subclass of EditText isn't behaving like EditText

随声附和 提交于 2019-12-22 10:46:43
问题 I've written a subclass of EditText . Here is that subclass: package com.package.foo; import android.content.Context; import android.graphics.Typeface; import android.util.AttributeSet; import android.widget.EditText; public class FuturaEditText extends EditText{ public FuturaEditText(Context context) { this(context, null, 0); } public FuturaEditText(Context context, AttributeSet attrs) { this(context, attrs, 0); } public FuturaEditText(Context context, AttributeSet attrs, int defStyle) {

Subclassing UINavigationBar in Swift

谁都会走 提交于 2019-12-22 08:42:12
问题 I'm trying to create a custom UINavigationBar class and then use the Storyboard to set it as the class of my UINavigationController 's NavigationBar. Here's the code of my UINavigationBar class: class CustomNavBar: UINavigationBar { override func drawRect(rect: CGRect) { super.drawRect(rect) // Drawing code self.backgroundColor = UIColor.orangeColor() let myLabel = UILabel(frame: CGRect(x: 0, y: 4, width: 600, height: 36)) myLabel.backgroundColor = UIColor.purpleColor() myLabel.textColor =

Subclassing UINavigationBar in Swift

旧巷老猫 提交于 2019-12-22 08:41:31
问题 I'm trying to create a custom UINavigationBar class and then use the Storyboard to set it as the class of my UINavigationController 's NavigationBar. Here's the code of my UINavigationBar class: class CustomNavBar: UINavigationBar { override func drawRect(rect: CGRect) { super.drawRect(rect) // Drawing code self.backgroundColor = UIColor.orangeColor() let myLabel = UILabel(frame: CGRect(x: 0, y: 4, width: 600, height: 36)) myLabel.backgroundColor = UIColor.purpleColor() myLabel.textColor =

Cocoa: Stopping the field editor from auto-completing on space key

北城余情 提交于 2019-12-22 08:12:38
问题 I have a custom view with several NSTextField controls for which I want to supply custom auto-completions and I have successfully implemented all that using the NSTextFieldDelegate Protocol. The auto-completions are full names or place names, depending on which text field is being edited. The issue is that the auto-completions almost always contain a space character and so if the user is typing something that matches a suggestion, but doesn't want to accept that suggestion, the field editor

How to count the number of CRTP subclasses of a template class?

我只是一个虾纸丫 提交于 2019-12-22 06:15:10
问题 Does anyone know of a method to use CRTP to count the number of subclasses of an object? Suppose we had a setup similar to the following one: template <typename T> class Object { .... }; const unsigned int ObjectSubClassCount = ...; class Subobject : public Object<SubObject> { .... }; class Second : public Object<Second> { .... }; and so on, such that, using TMP, we might have a constant ( ObjectSubClassCount ) that represents the total number of subclasses? Does anyone know a way to do this?

Cloning subclasses in Java

对着背影说爱祢 提交于 2019-12-22 05:39:35
问题 I need to clone a subclass in Java, but at the point in the code where this happens, I won't know the subclass type, only the super class. What's the best design pattern for doing this? Example: class Foo { String myFoo; public Foo(){} public Foo(Foo old) { this.myFoo = old.myFoo; } } class Bar extends Foo { String myBar; public Bar(){} public Bar(Bar old) { super(old); // copies myFoo this.myBar = old.myBar; } } class Copier { Foo foo; public Foo makeCopy(Foo oldFoo) { // this doesn't work