我正在使用Swift语言为iOS系统构建应用程序.所以我添加了我的项目核心数据.
我还创建了'CoreDataController'
这是它的代码:
import Foundation
import CoreData
import UIKit
class CoreDataController {
static let shared = CoreDataController()
private var context: NSManagedObjectContext
private init() {
let application = UIApplication.shared.delegate as! AppDelegate
self.context = application.persistentContainer.viewContext
}
}
Run Code Online (Sandbox Code Playgroud)
在线UIApplication.shared.delegate .....我有一个错误
类型'UIApplication'没有成员共享
这是我的appdelegade文件
import UIKit
import CoreData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when …Run Code Online (Sandbox Code Playgroud) 我尝试编写此类:
public class ModelManager
{
public OmniacareHomeProductionEntities _db;
public CategoriaManager categoriaManager
{
get { return categoriaManager; }
set
{
if (categoriaManager == null)
{
categoriaManager = new CategoriaManagerImpl();
}
}
}
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(ModelManager));
public ModelManager()
{
_db = new OmniacareHomeProductionEntities();
}
}
Run Code Online (Sandbox Code Playgroud)
CategoriaManager是一个接口,CategoriaManagerImpl是一个实现CategoriaManager的类。
我在这种模式下使用ModelManager类:
ModelManager modelManager = new ModelManager();
modelManager.categoriaManager.saveLocalCategory(category, true);
Run Code Online (Sandbox Code Playgroud)
因此,当我尝试运行此代码时,此行有一个StackOverflowError
get
{
return categoriaManager;
}
Run Code Online (Sandbox Code Playgroud)
我的错误在哪里?你能帮助我吗?
我有一个扩展JLabel的类.这是班级:
public class LabelFormat extends JLabel {
public LabelFormat(String string){
Font myFont=UtilitySwing.getLabelFont();
this.setText(string);
this.setFont(myFont);
}
}
Run Code Online (Sandbox Code Playgroud)
这是UtilitySwing类中的方法:
public static Font getLabelFont(){
Toolkit t = Toolkit.getDefaultToolkit();
Dimension screenSize = t.getScreenSize();
double width = screenSize.getWidth();
double height= screenSize.getHeight();
Font myFont;
if ((width == 1600.0) && (height == 900.0) ||
(width == 1440.0) && (height == 900.0) ||
(width == 1280) && (height== 800) ||
((width == 1280) && (height== 768)))
{
myFont = new Font("Century Gothic", Font.PLAIN, 14);
}
else if((width==1024) && …Run Code Online (Sandbox Code Playgroud) 我想在我的html页面中设置背景图像.
所以我有这个代码:
body{
background: url("background_image.jpg") no-repeat scroll center center / 100% auto;
}
Run Code Online (Sandbox Code Playgroud)
这是我的HTML页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" rel="stylesheet" href="css/style.css" />
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
因此,使用此代码,背景图像不会填满屏幕.
我想以全宽和高度显示图像
我想创建一个多重类型的Object列表.所以我构建了这段代码:
List<Entrate>lista = modelManager.getEntrataManager().getEntrate();
List<NotaSpese>listaSpese=modelManager.getNotaSpesaManager().getNotaSpese();
List<Object> listaMovimenti = new ArrayList<Object>();
listaMovimenti.addAll(lista);
listaMovimenti.addAll(listaSpese);
Run Code Online (Sandbox Code Playgroud)
现在我想通过Entrate和NotaSpese数据字段来订购这个集合.
我该如何订购清单?
我正在使用Android Studio构建应用程序.在我的活动中,我想创建一个PDF文件,所以我从互联网上复制这段代码来创建和打开一个简单的PDF文件.
public void createandDisplayPdf(String text) {
Document doc = new Document();
try {
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Dir";
File dir = new File(path);
if(!dir.exists())
dir.mkdirs();
File file = new File(dir, "newFile.pdf");
FileOutputStream fOut = new FileOutputStream(file);
PdfWriter.getInstance(doc, fOut);
//open the document
doc.open();
Paragraph p1 = new Paragraph(text);
Font paraFont= new Font(Font.COURIER);
p1.setAlignment(Paragraph.ALIGN_CENTER);
p1.setFont(paraFont);
//add paragraph to document
doc.add(p1);
} catch (DocumentException de) {
Log.e("PDFCreator", "DocumentException:" + de);
} catch (IOException e) {
Log.e("PDFCreator", "ioException:" + e);
}
finally …Run Code Online (Sandbox Code Playgroud) 我有一个Java Swing应用程序.我想插入一个带有png图像的JLabel作为背景,我想在此图像的中心插入另一个JLabel.所以我构建了这段代码:
ImageIcon icon = new ImageIcon(getClass().getResource("/resources/cornometro_white.png"));
labelSfondoTimer = new JLabel(icon);
labelTempoGara = new JLabel();
labelTempoGara.text("pippo");
GridBagConstraints GBC2 = new GridBagConstraints();
Container CR2 = new Container();
GridBagLayout GBL2 = new GridBagLayout();
CR2.setComponentOrientation(ComponentOrientation.UNKNOWN);
CR2.setLayout(GBL2);
labelSfondoTimer.add(CR2);
GBC2 = new GridBagConstraints();
CR2.add(labelTempoGara);
GBC2.gridx=2;
GBC2.gridy=0;
GBC2.anchor= GridBagConstraints.CENTER;
GBL2.setConstraints(labelTempoGara,GBC2);
Run Code Online (Sandbox Code Playgroud)
使用此代码,我可以在屏幕上看到图像,但我看不到带有文本"pippo"的secondo标签
我也尝试插入此代码:
labelSfondoTimer.setObaque(真); 但不行.
我正在构建水晶报告。我想为每页插入页码。所以,我在报告的每一页中插入页码,我可以看到
1
2
3
4
Run Code Online (Sandbox Code Playgroud)
但现在我想插入这个数字:
1 of 4
2 of 4
3 of 4
4 of 4
Run Code Online (Sandbox Code Playgroud)
我该怎么做?